本文整理汇总了Java中mil.nga.geopackage.GeoPackage.getSpatialReferenceSystemDao方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.getSpatialReferenceSystemDao方法的具体用法?Java GeoPackage.getSpatialReferenceSystemDao怎么用?Java GeoPackage.getSpatialReferenceSystemDao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.GeoPackage
的用法示例。
在下文中一共展示了GeoPackage.getSpatialReferenceSystemDao方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: viewDatabaseOption
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* View database information
*
* @param database
*/
private void viewDatabaseOption(final String database) {
StringBuilder databaseInfo = new StringBuilder();
GeoPackage geoPackage = manager.open(database);
try {
SpatialReferenceSystemDao srsDao = geoPackage
.getSpatialReferenceSystemDao();
List<SpatialReferenceSystem> srsList = srsDao.queryForAll();
databaseInfo.append("Size: ")
.append(manager.readableSize(database));
databaseInfo.append("\n\nLocation: ").append(
manager.isExternal(database) ? "External" : "Local");
databaseInfo.append("\nPath: ").append(manager.getPath(database));
databaseInfo.append("\n\nFeature Tables: ").append(
geoPackage.getFeatureTables().size());
databaseInfo.append("\nTile Tables: ").append(
geoPackage.getTileTables().size());
databaseInfo.append("\n\nSpatial Reference Systems: ").append(
srsList.size());
for (SpatialReferenceSystem srs : srsList) {
databaseInfo.append("\n");
addSrs(databaseInfo, srs);
}
} catch (Exception e) {
databaseInfo.append(e.getMessage());
} finally {
geoPackage.close();
}
AlertDialog viewDialog = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle)
.setTitle(database)
.setPositiveButton(getString(R.string.button_ok_label),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).setMessage(databaseInfo.toString()).create();
viewDialog.show();
}
示例3: 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();
}
}
}