本文整理汇总了Java中mil.nga.geopackage.features.user.FeatureCursor.close方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureCursor.close方法的具体用法?Java FeatureCursor.close怎么用?Java FeatureCursor.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.features.user.FeatureCursor
的用法示例。
在下文中一共展示了FeatureCursor.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例4: 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;
}
示例5: 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();
}
}
}
示例6: 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();
}
}
}