本文整理汇总了Java中mil.nga.geopackage.features.user.FeatureCursor类的典型用法代码示例。如果您正苦于以下问题:Java FeatureCursor类的具体用法?Java FeatureCursor怎么用?Java FeatureCursor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FeatureCursor类属于mil.nga.geopackage.features.user包,在下文中一共展示了FeatureCursor类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawTile
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Bitmap drawTile(int zoom, BoundingBox boundingBox, FeatureCursor cursor) {
Bitmap bitmap = createNewBitmap();
Canvas canvas = new Canvas(bitmap);
ProjectionTransform transform = getProjectionToWebMercatorTransform(featureDao.getProjection());
while (cursor.moveToNext()) {
FeatureRow row = cursor.getRow();
drawFeature(zoom, boundingBox, transform, canvas, row);
}
cursor.close();
return bitmap;
}
示例2: indexRows
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Index the feature rows in the cursor
*
* @param tableIndex table index
* @param cursor feature cursor
* @return count
*/
private int indexRows(TableIndex tableIndex, FeatureCursor cursor) {
int count = 0;
try {
while ((progress == null || progress.isActive())
&& cursor.moveToNext()) {
try {
FeatureRow row = cursor.getRow();
if (row.isValid()) {
boolean indexed = index(tableIndex,
row.getId(), row.getGeometry());
if (indexed) {
count++;
}
if (progress != null) {
progress.addProgress(1);
}
}
} catch (Exception e) {
Log.e(FeatureTableIndex.class.getSimpleName(), "Failed to index feature. Table: "
+ tableIndex.getTableName() + ", Position: " + cursor.getPosition(), e);
}
}
} finally {
cursor.close();
}
return count;
}
示例3: getFeatureDao
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public FeatureDao getFeatureDao(GeometryColumns geometryColumns) {
if (geometryColumns == null) {
throw new GeoPackageException("Non null "
+ GeometryColumns.class.getSimpleName()
+ " is required to create "
+ FeatureDao.class.getSimpleName());
}
// Read the existing table and create the dao
FeatureTableReader tableReader = new FeatureTableReader(geometryColumns);
final FeatureTable featureTable = tableReader.readTable(new FeatureWrapperConnection(database));
FeatureConnection userDb = new FeatureConnection(database);
FeatureDao dao = new FeatureDao(getName(), database, userDb, geometryColumns, featureTable);
// Register the table name (with and without quotes) to wrap cursors with the feature cursor
cursorFactory.registerTable(geometryColumns.getTableName(),
new GeoPackageCursorWrapper() {
@Override
public Cursor wrapCursor(Cursor cursor) {
return new FeatureCursor(featureTable, cursor);
}
});
// TODO
// GeoPackages created with SQLite version 4.2.0+ with GeoPackage support are not supported
// in Android (Nougat uses SQLite version 3.9.2)
dropSQLiteTriggers(geometryColumns);
return dao;
}
示例4: drawUnindexedTile
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Bitmap drawUnindexedTile(int tileWidth, int tileHeight, long totalFeatureCount, FeatureCursor allFeatureResults) {
Bitmap bitmap = null;
if (drawUnindexedTiles) {
// Draw a tile indicating we have no idea if there are features inside.
// The table is not indexed and more features exist than the max feature count set.
bitmap = drawTile(tileWidth, tileHeight, "?");
}
return bitmap;
}
示例5: drawTileQueryAll
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Draw a tile bitmap from the x, y, and zoom level by querying all features. This could
* be very slow if there are a lot of features
*
* @param x
* @param y
* @param zoom
* @return drawn bitmap, or null
*/
public Bitmap drawTileQueryAll(int x, int y, int zoom) {
BoundingBox boundingBox = TileBoundingBoxUtils
.getWebMercatorBoundingBox(x, y, zoom);
Bitmap bitmap = null;
// Query for all features
FeatureCursor cursor = featureDao.queryForAll();
try {
Integer totalCount = null;
if (maxFeaturesPerTile != null) {
totalCount = cursor.getCount();
}
if (maxFeaturesPerTile == null || totalCount <= maxFeaturesPerTile) {
// Draw the tile bitmap
bitmap = drawTile(zoom, boundingBox, cursor);
} else if (maxFeaturesTileDraw != null) {
// Draw the unindexed max features tile
bitmap = maxFeaturesTileDraw.drawUnindexedTile(tileWidth, tileHeight, totalCount, cursor);
}
} finally {
cursor.close();
}
return bitmap;
}
示例6: indexTable
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Index the feature table
*
* @return count
*/
private int indexTable() {
int count = 0;
// Get or create the table metadata
TableMetadataDataSource tableDs = new TableMetadataDataSource(db);
TableMetadata metadata = tableDs.getOrCreate(featureDao.getDatabase(), featureDao.getTableName());
// Delete existing index rows
geometryMetadataDataSource.delete(featureDao.getDatabase(), featureDao.getTableName());
// Index all features
FeatureCursor cursor = featureDao.queryForAll();
try {
while ((progress == null || progress.isActive()) && cursor.moveToNext()) {
try {
FeatureRow row = cursor.getRow();
boolean indexed = index(metadata.getGeoPackageId(), row, false);
if (indexed) {
count++;
}
if (progress != null) {
progress.addProgress(1);
}
} catch (Exception e) {
Log.e(FeatureIndexer.class.getSimpleName(), "Failed to index feature. Table: "
+ featureDao.getTableName() + ", Position: " + cursor.getPosition(), e);
}
}
} finally {
cursor.close();
}
// Update the last indexed time
if (progress == null || progress.isActive()) {
updateLastIndexed(db, metadata.getGeoPackageId());
}
return count;
}
示例7: testDelete
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Test delete
*
* @param geoPackage
* @throws SQLException
*/
public static void testDelete(GeoPackage geoPackage) throws SQLException {
GeometryColumnsDao geometryColumnsDao = geoPackage
.getGeometryColumnsDao();
if (geometryColumnsDao.isTableExists()) {
List<GeometryColumns> results = geometryColumnsDao.queryForAll();
for (GeometryColumns geometryColumns : results) {
FeatureDao dao = geoPackage.getFeatureDao(geometryColumns);
TestCase.assertNotNull(dao);
FeatureCursor cursor = dao.queryForAll();
int count = cursor.getCount();
if (count > 0) {
// Choose random feature
int random = (int) (Math.random() * count);
cursor.moveToPosition(random);
FeatureRow featureRow = cursor.getRow();
cursor.close();
// Delete row
try {
TestCase.assertEquals(1, dao.delete(featureRow));
} catch (SQLiteException e) {
if (TestUtils.isFutureSQLiteException(e)) {
continue;
} else {
throw e;
}
}
// Verify deleted
FeatureRow queryFeatureRow = dao.queryForIdRow(featureRow
.getId());
TestCase.assertNull(queryFeatureRow);
cursor = dao.queryForAll();
TestCase.assertEquals(count - 1, cursor.getCount());
cursor.close();
}
cursor.close();
}
}
}
示例8: testGeometryProjectionTransform
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Test transforming geometries between projections
*
* @param geoPackage
* @throws SQLException
* @throws IOException
*/
public static void testGeometryProjectionTransform(GeoPackage geoPackage)
throws SQLException, IOException {
GeometryColumnsDao geometryColumnsDao = geoPackage
.getGeometryColumnsDao();
if (geometryColumnsDao.isTableExists()) {
List<GeometryColumns> results = geometryColumnsDao.queryForAll();
for (GeometryColumns geometryColumns : results) {
FeatureDao dao = geoPackage.getFeatureDao(geometryColumns);
TestCase.assertNotNull(dao);
FeatureCursor cursor = dao.queryForAll();
while (cursor.moveToNext()) {
GeoPackageGeometryData geometryData = cursor.getGeometry();
if (geometryData != null) {
Geometry geometry = geometryData.getGeometry();
if (geometry != null) {
SpatialReferenceSystemDao srsDao = geoPackage
.getSpatialReferenceSystemDao();
long srsId = geometryData.getSrsId();
SpatialReferenceSystem srs = srsDao
.queryForId(srsId);
long epsg = srs.getOrganizationCoordsysId();
Projection projection = ProjectionFactory
.getProjection(srs);
long toEpsg = -1;
if (epsg == ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM) {
toEpsg = ProjectionConstants.EPSG_WEB_MERCATOR;
} else {
toEpsg = ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM;
}
ProjectionTransform transformTo = projection
.getTransformation(toEpsg);
ProjectionTransform transformFrom = transformTo
.getToProjection().getTransformation(srs);
byte[] bytes = geometryData.getWkbBytes();
Geometry projectedGeometry = transformTo
.transform(geometry);
GeoPackageGeometryData projectedGeometryData = new GeoPackageGeometryData(
-1);
projectedGeometryData
.setGeometry(projectedGeometry);
projectedGeometryData.toBytes();
byte[] projectedBytes = projectedGeometryData
.getWkbBytes();
if (epsg > 0) {
TestCase.assertFalse(equalByteArrays(bytes,
projectedBytes));
}
Geometry restoredGeometry = transformFrom
.transform(projectedGeometry);
compareGeometries(geometry, restoredGeometry, .001);
}
}
}
cursor.close();
}
}
}
示例9: drawUnindexedTile
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Draw a custom tile when the number of features within the tile is unknown.
* This is called when a feature table is not indexed and more total features exist than the
* max per tile.
*
* @param tileWidth tile width to draw
* @param tileHeight tile height to draw
* @param totalFeatureCount count of total features in the feature table
* @param allFeatureResults results in a feature cursor
* @return custom bitmap, or null
*/
public Bitmap drawUnindexedTile(int tileWidth, int tileHeight, long totalFeatureCount, FeatureCursor allFeatureResults);
示例10: drawTile
import mil.nga.geopackage.features.user.FeatureCursor; //导入依赖的package包/类
/**
* Draw a tile bitmap from feature geometries in the provided cursor
*
* @param zoom zoom level
* @param webMercatorBoundingBox
* @param cursor
* @return tile
* @since 2.0.0
*/
public abstract Bitmap drawTile(int zoom, BoundingBox webMercatorBoundingBox, FeatureCursor cursor);