本文整理汇总了Java中mil.nga.geopackage.GeoPackage.getFeatureDao方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.getFeatureDao方法的具体用法?Java GeoPackage.getFeatureDao怎么用?Java GeoPackage.getFeatureDao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.GeoPackage
的用法示例。
在下文中一共展示了GeoPackage.getFeatureDao方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFeatureDao
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Create feature dao
*
* @return
*/
public static FeatureDao createFeatureDao(GeoPackage geoPackage) {
BoundingBox boundingBox = new BoundingBox();
GeometryColumns geometryColumns = new GeometryColumns();
geometryColumns.setId(new TableColumnKey("feature_tiles",
"geom"));
geometryColumns.setGeometryType(GeometryType.GEOMETRY);
geometryColumns.setZ((byte) 0);
geometryColumns.setM((byte) 0);
geoPackage.createFeatureTableWithMetadata(
geometryColumns, boundingBox, ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns);
return featureDao;
}
示例2: infoFeatureClick
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Info feature click
*
* @param marker
* @param markerFeature
*/
private void infoFeatureClick(final Marker marker, MarkerFeature markerFeature) {
final GeoPackage geoPackage = manager.open(markerFeature.database);
final FeatureDao featureDao = geoPackage
.getFeatureDao(markerFeature.tableName);
final FeatureRow featureRow = featureDao.queryForIdRow(markerFeature.featureId);
if (featureRow != null) {
final GeoPackageGeometryData geomData = featureRow.getGeometry();
final GeometryType geometryType = geomData.getGeometry()
.getGeometryType();
String title = getTitle(geometryType, marker);
infoExistingFeatureOption(geoPackage, featureRow, title, geomData);
} else {
geoPackage.close();
}
}
示例3: createFeatureDao
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Create feature dao
*
* @return feature dao
*/
public static FeatureDao createFeatureDao(GeoPackage geoPackage) {
BoundingBox boundingBox = new BoundingBox();
GeometryColumns geometryColumns = new GeometryColumns();
geometryColumns.setId(new TableColumnKey(TABLE_NAME, "geom"));
geometryColumns.setGeometryType(GeometryType.GEOMETRY);
geometryColumns.setZ((byte) 0);
geometryColumns.setM((byte) 0);
geoPackage.createFeatureTableWithMetadata(geometryColumns, boundingBox,
ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns);
return featureDao;
}
示例4: addEditableShapeBack
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Add editable shape back after editing is complete
*/
private void addEditableShapeBack() {
Long featureId = editFeatureIds.get(editFeatureMarker.getId());
final GeoPackage geoPackage = manager.open(editFeaturesDatabase);
try {
final FeatureDao featureDao = geoPackage
.getFeatureDao(editFeaturesTable);
final FeatureRow featureRow = featureDao.queryForIdRow(featureId);
GeoPackageGeometryData geomData = featureRow.getGeometry();
if (geomData != null) {
Geometry geometry = geomData.getGeometry();
if (geometry != null) {
GoogleMapShapeConverter converter = new GoogleMapShapeConverter(
featureDao.getProjection());
GoogleMapShape shape = converter.toShape(geometry);
prepareShapeOptions(shape, true, true);
GoogleMapShape mapShape = GoogleMapShapeConverter
.addShapeToMap(map, shape);
addEditableShape(featureId, mapShape);
}
}
} finally {
if (geoPackage != null) {
geoPackage.close();
}
}
}
示例5: indexFeatures
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Index features
*
* @param activity
* @param callback
* @param database
* @param tableName
* @param indexLocation
*/
public static void indexFeatures(Activity activity, IIndexerTask callback,
String database, String tableName,
FeatureIndexType indexLocation) {
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
GeoPackage geoPackage = manager.open(database);
FeatureDao featureDao = geoPackage.getFeatureDao(tableName);
FeatureIndexManager indexer = new FeatureIndexManager(activity, geoPackage, featureDao);
indexer.setIndexLocation(indexLocation);
ProgressDialog progressDialog = new ProgressDialog(activity);
final IndexerTask indexTask = new IndexerTask(activity,
callback, progressDialog, geoPackage, indexer);
int max = featureDao.count();
indexTask.setMax(max);
indexer.setProgress(indexTask);
progressDialog.setMessage(activity
.getString(R.string.geopackage_table_index_features_index_title)
+ ": "
+ geoPackage.getName() + " - " + tableName);
progressDialog.setCancelable(false);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setIndeterminate(false);
progressDialog.setMax(max);
progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
activity.getString(R.string.button_cancel_label),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
indexTask.cancel(true);
}
});
indexTask.execute();
}
示例6: testDelete
import mil.nga.geopackage.GeoPackage; //导入方法依赖的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);
FeatureResultSet 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
TestCase.assertEquals(1, dao.delete(featureRow));
// Verify deleted
FeatureRow queryFeatureRow = dao.queryForIdRow(featureRow
.getId());
TestCase.assertNull(queryFeatureRow);
cursor = dao.queryForAll();
TestCase.assertEquals(count - 1, cursor.getCount());
cursor.close();
}
cursor.close();
}
}
}
示例7: testDeleteAll
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test table index delete all
*
* @param geoPackage
* @throws SQLException
*/
public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {
// Test indexing each feature table
List<String> featureTables = geoPackage.getFeatureTables();
for (String featureTable : featureTables) {
FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
FeatureTableIndex featureTableIndex = new FeatureTableIndex(
geoPackage, featureDao);
TestCase.assertFalse(featureTableIndex.isIndexed());
TestUtils.validateGeoPackage(geoPackage);
// Test indexing
featureTableIndex.index();
TestUtils.validateGeoPackage(geoPackage);
TestCase.assertTrue(featureTableIndex.isIndexed());
}
ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
GeometryIndexDao geometryIndexDao = geoPackage.getGeometryIndexDao();
TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();
TestCase.assertTrue(geometryIndexDao.isTableExists());
TestCase.assertTrue(tableIndexDao.isTableExists());
TestCase.assertTrue(extensionsDao.queryByExtension(
FeatureTableIndex.EXTENSION_NAME).size() > 0);
TestCase.assertTrue(geometryIndexDao.countOf() > 0);
long count = tableIndexDao.countOf();
TestCase.assertTrue(count > 0);
int deleteCount = tableIndexDao.deleteAllCascade();
TestCase.assertEquals(count, deleteCount);
TestCase.assertTrue(geometryIndexDao.countOf() == 0);
TestCase.assertTrue(tableIndexDao.countOf() == 0);
}
示例8: testDelete
import mil.nga.geopackage.GeoPackage; //导入方法依赖的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();
}
}
}
示例9: testGeometryProjectionTransform
import mil.nga.geopackage.GeoPackage; //导入方法依赖的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();
}
}
}
示例10: validateFeatureTableWithMetadata
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Validate feature table with metadata
*
* @param geoPackage
* @throws SQLException
*/
private static void validateFeatureTableWithMetadata(GeoPackage geoPackage,
GeometryColumns geometryColumns, String idColumn,
List<FeatureColumn> additionalColumns) throws SQLException {
GeometryColumnsDao dao = geoPackage.getGeometryColumnsDao();
GeometryColumns queryGeometryColumns = dao.queryForId(geometryColumns
.getId());
TestCase.assertNotNull(queryGeometryColumns);
TestCase.assertEquals(geometryColumns.getTableName(),
queryGeometryColumns.getTableName());
TestCase.assertEquals(geometryColumns.getColumnName(),
queryGeometryColumns.getColumnName());
TestCase.assertEquals(GeometryType.POINT,
queryGeometryColumns.getGeometryType());
TestCase.assertEquals(geometryColumns.getZ(),
queryGeometryColumns.getZ());
TestCase.assertEquals(geometryColumns.getM(),
queryGeometryColumns.getM());
FeatureDao featureDao = geoPackage.getFeatureDao(geometryColumns
.getTableName());
FeatureRow featureRow = featureDao.newRow();
TestCase.assertEquals(
2 + (additionalColumns != null ? additionalColumns.size() : 0),
featureRow.columnCount());
if (idColumn == null) {
idColumn = "id";
}
TestCase.assertEquals(idColumn, featureRow.getColumnName(0));
TestCase.assertEquals(geometryColumns.getColumnName(),
featureRow.getColumnName(1));
if (additionalColumns != null) {
TestCase.assertEquals("test_text", featureRow.getColumnName(2));
TestCase.assertEquals("test_real", featureRow.getColumnName(3));
TestCase.assertEquals("test_boolean", featureRow.getColumnName(4));
TestCase.assertEquals("test_blob", featureRow.getColumnName(5));
TestCase.assertEquals("test_integer", featureRow.getColumnName(6));
TestCase.assertEquals("test_text_limited",
featureRow.getColumnName(7));
TestCase.assertEquals("test_blob_limited",
featureRow.getColumnName(8));
}
}
示例11: setEditType
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Set the edit type
*
* @param editType
*/
private void setEditType(EditType previousType, EditType editType) {
if (editType != null && previousType != editType) {
editFeatureType = editType;
switch (editType) {
case POINT:
editPointButton
.setImageResource(R.drawable.ic_edit_point_active);
break;
case LINESTRING:
editLinestringButton
.setImageResource(R.drawable.ic_edit_linestring_active);
break;
case POLYGON_HOLE:
editFeatureType = EditType.POLYGON;
case POLYGON:
editPolygonButton
.setImageResource(R.drawable.ic_edit_polygon_active);
editFeaturesPolygonHoleView.setVisibility(View.VISIBLE);
break;
case EDIT_FEATURE:
editFeatureMarker = tempEditFeatureMarker;
tempEditFeatureMarker = null;
Long featureId = editFeatureIds.get(editFeatureMarker.getId());
final GeoPackage geoPackage = manager
.open(editFeaturesDatabase);
try {
final FeatureDao featureDao = geoPackage
.getFeatureDao(editFeaturesTable);
final FeatureRow featureRow = featureDao
.queryForIdRow(featureId);
Geometry geometry = featureRow.getGeometry().getGeometry();
GoogleMapShapeConverter converter = new GoogleMapShapeConverter(
featureDao.getProjection());
GoogleMapShape shape = converter.toShape(geometry);
editFeatureMarker.remove();
GoogleMapShape featureObject = editFeatureObjects
.remove(editFeatureMarker.getId());
if (featureObject != null) {
featureObject.remove();
}
MarkerOptions editFeatureShapeMarker = getEditFeatureShapeMarker();
editFeatureShape = converter.addShapeToMapAsMarkers(map,
shape, getEditFeatureMarker(),
editFeatureShapeMarker, editFeatureShapeMarker,
getEditFeatureShapeHoleMarker(),
getDrawPolylineOptions(), getDrawPolygonOptions());
updateEditState(true);
} finally {
if (geoPackage != null) {
geoPackage.close();
}
}
break;
}
}
}
示例12: testDeleteAll
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test table index delete all
*
* @param geoPackage
* @throws SQLException
*/
public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {
// Test indexing each feature table
List<String> featureTables = geoPackage.getFeatureTables();
for (String featureTable : featureTables) {
FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
FeatureTableIndex featureTableIndex = new FeatureTableIndex(
geoPackage, featureDao);
TestCase.assertFalse(featureTableIndex.isIndexed());
TestUtils.validateGeoPackage(geoPackage);
// Test indexing
featureTableIndex.index();
TestUtils.validateGeoPackage(geoPackage);
TestCase.assertTrue(featureTableIndex.isIndexed());
}
ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
GeometryIndexDao geometryIndexDao = geoPackage.getGeometryIndexDao();
TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();
TestCase.assertTrue(geometryIndexDao.isTableExists());
TestCase.assertTrue(tableIndexDao.isTableExists());
TestCase.assertTrue(extensionsDao.queryByExtension(
FeatureTableIndex.EXTENSION_NAME).size() > 0);
TestCase.assertTrue(geometryIndexDao.countOf() > 0);
long count = tableIndexDao.countOf();
TestCase.assertTrue(count > 0);
int deleteCount = tableIndexDao.deleteAllCascade();
TestCase.assertEquals(count, deleteCount);
TestCase.assertTrue(geometryIndexDao.countOf() == 0);
TestCase.assertTrue(tableIndexDao.countOf() == 0);
}
示例13: testGeometryProjectionTransform
import mil.nga.geopackage.GeoPackage; //导入方法依赖的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);
FeatureResultSet 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();
}
}
}
示例14: testDeleteTables
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test deleting tables by name
*
* @param geoPackage
* @throws SQLException
*/
public static void testDeleteTables(GeoPackage geoPackage)
throws SQLException {
GeometryColumnsDao geometryColumnsDao = geoPackage
.getGeometryColumnsDao();
TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();
TestCase.assertTrue(geometryColumnsDao.isTableExists()
|| tileMatrixSetDao.isTableExists());
if (geometryColumnsDao.isTableExists()) {
for (String featureTable : geoPackage.getFeatureTables()) {
FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
featureDao.dropTable();
}
geoPackage.dropTable(GeometryColumns.TABLE_NAME);
TestCase.assertFalse(geometryColumnsDao.isTableExists());
}
if (tileMatrixSetDao.isTableExists()) {
TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao();
TestCase.assertTrue(tileMatrixSetDao.isTableExists());
TestCase.assertTrue(tileMatrixDao.isTableExists());
for (String tileTable : geoPackage.getTileTables()) {
TileDao tileDao = geoPackage.getTileDao(tileTable);
tileDao.dropTable();
}
geoPackage.dropTable(TileMatrix.TABLE_NAME);
geoPackage.dropTable(TileMatrixSet.TABLE_NAME);
TestCase.assertFalse(tileMatrixSetDao.isTableExists());
TestCase.assertFalse(tileMatrixDao.isTableExists());
}
}