Java Code Examples for mil.nga.sf.proj.ProjectionConstants#EPSG_WORLD_GEODETIC_SYSTEM
The following examples show how to use
mil.nga.sf.proj.ProjectionConstants#EPSG_WORLD_GEODETIC_SYSTEM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 6 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 2
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 5 votes |
public static void setPoint(FeatureRow featureRow, double x, double y) { GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Point point = new Point(false, false, x, y); geomData.setGeometry(point); featureRow.setGeometry(geomData); }
Example 3
Source File: FeatureTileUtils.java From geopackage-android with MIT License | 5 votes |
public static long insertLine(FeatureDao featureDao, double[][] points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); LineString lineString = getLineString(points); geomData.setGeometry(lineString); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 4
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static void setPoint(FeatureRow featureRow, double x, double y) { GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Point point = new Point(false, false, x, y); geomData.setGeometry(point); featureRow.setGeometry(geomData); }
Example 5
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static long insertLine(FeatureDao featureDao, double[][] points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); LineString lineString = getLineString(points); geomData.setGeometry(lineString); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 6
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static long insertPolygon(FeatureDao featureDao, double[][]... points) { FeatureRow featureRow = featureDao.newRow(); GeoPackageGeometryData geomData = new GeoPackageGeometryData( ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); Polygon polygon = new Polygon(false, false); for (double[][] ring : points) { LineString lineString = getLineString(ring); polygon.addRing(lineString); } geomData.setGeometry(polygon); featureRow.setGeometry(geomData); return featureDao.insert(featureRow); }
Example 7
Source File: GeoPackageGeometryDataUtils.java From geopackage-android with MIT License | 4 votes |
/** * 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 = srs.getProjection(); 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 = srs.getTransformation(transformTo .getToProjection()); 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(); } } }
Example 8
Source File: SpatialReferenceSystemDao.java From geopackage-core-java with MIT License | 4 votes |
/** * Create the srs if needed * * @param srs * srs if exists or null * @param organization * organization * @param id * coordinate id * @return srs * @throws SQLException */ private SpatialReferenceSystem createIfNeeded(SpatialReferenceSystem srs, String organization, long id) throws SQLException { if (srs == null) { if (organization .equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG)) { switch ((int) id) { case ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM: srs = createWgs84(); break; case ProjectionConstants.EPSG_WEB_MERCATOR: srs = createWebMercator(); break; case ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM_GEOGRAPHICAL_3D: srs = createWgs84Geographical3D(); break; default: throw new GeoPackageException( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id); } } else if (organization .equalsIgnoreCase(ProjectionConstants.AUTHORITY_NONE)) { switch ((int) id) { case ProjectionConstants.UNDEFINED_CARTESIAN: srs = createUndefinedCartesian(); break; case ProjectionConstants.UNDEFINED_GEOGRAPHIC: srs = createUndefinedGeographic(); break; default: throw new GeoPackageException( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id); } } else { throw new GeoPackageException( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id); } } else { setDefinition_12_063(srs); } return srs; }
Example 9
Source File: GeoPackageGeometryDataUtils.java From geopackage-java with MIT License | 4 votes |
/** * 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 = srs.getProjection(); 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 = srs .getTransformation(transformTo .getToProjection()); 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(); } } }