本文整理汇总了Java中mil.nga.geopackage.GeoPackage.getGeometryColumnsDao方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.getGeometryColumnsDao方法的具体用法?Java GeoPackage.getGeometryColumnsDao怎么用?Java GeoPackage.getGeometryColumnsDao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.GeoPackage
的用法示例。
在下文中一共展示了GeoPackage.getGeometryColumnsDao方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: 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();
}
}
}
示例3: testDelete
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test delete
*
* @param geoPackage
* @throws SQLException
*/
public static void testDelete(GeoPackage geoPackage) throws SQLException {
GeometryColumnsDao dao = geoPackage.getGeometryColumnsDao();
if (dao.isTableExists()) {
List<GeometryColumns> results = dao.queryForAll();
if (!results.isEmpty()) {
// Choose random geometry columns
int random = (int) (Math.random() * results.size());
GeometryColumns geometryColumns = results.get(random);
// Delete the geometry columns
dao.delete(geometryColumns);
// Verify deleted
GeometryColumns queryGeometryColumns = dao
.queryForId(geometryColumns.getId());
TestCase.assertNull(queryGeometryColumns);
// Prepared deleted
results = dao.queryForAll();
if (!results.isEmpty()) {
// Choose random geometry columns
random = (int) (Math.random() * results.size());
geometryColumns = results.get(random);
// Find which geometry columns to delete
QueryBuilder<GeometryColumns, TableColumnKey> qb = dao
.queryBuilder();
qb.where().eq(GeometryColumns.COLUMN_GEOMETRY_TYPE_NAME,
geometryColumns.getGeometryType().getName());
PreparedQuery<GeometryColumns> query = qb.prepare();
List<GeometryColumns> queryResults = dao.query(query);
int count = queryResults.size();
// Delete
DeleteBuilder<GeometryColumns, TableColumnKey> db = dao
.deleteBuilder();
db.where().eq(GeometryColumns.COLUMN_GEOMETRY_TYPE_NAME,
geometryColumns.getGeometryType().getName());
PreparedDelete<GeometryColumns> deleteQuery = db.prepare();
int deleted = dao.delete(deleteQuery);
TestCase.assertEquals(count, deleted);
}
}
}
}
示例4: 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();
}
}
}
示例5: 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));
}
}
示例6: 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();
}
}
}
示例7: 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());
}
}