org.geotools.geometry.jts.JTS.toGeographic()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(377)

本文整理了Java中org.geotools.geometry.jts.JTS.toGeographic()方法的一些代码示例,展示了JTS.toGeographic()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTS.toGeographic()方法的具体详情如下:
包路径:org.geotools.geometry.jts.JTS
类名称:JTS
方法名:toGeographic

JTS.toGeographic介绍

[英]Transforms the envelope from its current crs to WGS84 coordinate reference system. If the specified envelope is already in WGS84, then it is returned unchanged.
[中]将封套从其当前crs转换为WGS84坐标系。如果指定的信封已在WGS84中,则会原封不动地返回。

代码示例

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Transforms the envelope from its current crs to {@link DefaultGeographicCRS#WGS84}. If the
  3. * specified envelope is already in WGS84, then it is returned unchanged.
  4. *
  5. * <p>The method {@link CRS#equalsIgnoreMetadata(Object, Object)} is used to compare the numeric
  6. * values and axis order (so {@code CRS.decode("CRS.84")} or {@code CRS.decode("4326",true)}
  7. * provide an appropriate match).
  8. *
  9. * @param envelope The envelope to transform.
  10. * @param crs The CRS the envelope is currently in.
  11. * @return The envelope transformed to be in {@link DefaultGeographicCRS#WGS84}.
  12. * @throws TransformException If at least one coordinate can't be transformed.
  13. */
  14. public static Envelope toGeographic(
  15. final Envelope envelope, final CoordinateReferenceSystem crs)
  16. throws TransformException {
  17. if (CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) {
  18. if (envelope instanceof ReferencedEnvelope) {
  19. return envelope;
  20. }
  21. return ReferencedEnvelope.create(envelope, DefaultGeographicCRS.WGS84);
  22. }
  23. ReferencedEnvelope initial = ReferencedEnvelope.create(envelope, crs);
  24. return toGeographic(initial);
  25. }
  26. /**

代码示例来源:origin: geotools/geotools

  1. @Test
  2. public void testToGeographicGeometry() throws Exception {
  3. // This time we are in north / east order
  4. CoordinateReferenceSystem gda94 = CRS.decode("EPSG:4939", true);
  5. GeometryFactory gf = new GeometryFactory();
  6. Point point =
  7. gf.createPoint(
  8. new Coordinate(130.882672103999, -16.4463909341494, 97.009018073082));
  9. Point world = (Point) JTS.toGeographic(point, gda94);
  10. assertEquals(point.getX(), world.getX(), 0.00000005);
  11. assertEquals(point.getY(), world.getY(), 0.00000005);
  12. }

代码示例来源:origin: geotools/geotools

  1. gda94);
  2. ReferencedEnvelope worldBounds = JTS.toGeographic(bounds);
  3. assertEquals(DefaultGeographicCRS.WGS84, worldBounds.getCoordinateReferenceSystem());
  4. 130.875825803896, 130.898939990319, -16.4491956225999, -16.4338185791628);
  5. Envelope worldBounds2 = JTS.toGeographic(envelope, gda94);
  6. if (worldBounds2 instanceof BoundingBox) {
  7. assertEquals(

代码示例来源:origin: geotools/geotools

  1. @Test
  2. public void testBounds() throws Exception {
  3. ReferencedEnvelope bounds2d = point_test_2d.getBounds();
  4. ReferencedEnvelope bounds3d = point_test.getBounds();
  5. double aspect2d = bounds2d.getWidth() / bounds2d.getHeight();
  6. double aspect3d = bounds3d.getWidth() / bounds3d.getHeight();
  7. assertEquals(aspect2d, aspect3d, 0.0005);
  8. ReferencedEnvelope bbox2d = JTS.toGeographic(bounds2d);
  9. ReferencedEnvelope bbox3d = JTS.toGeographic(bounds3d);
  10. aspect2d = bbox2d.getWidth() / bbox2d.getHeight();
  11. aspect3d = bbox3d.getWidth() / bbox3d.getHeight();
  12. assertEquals(aspect2d, aspect3d, 0.000005);
  13. }

代码示例来源:origin: geotools/geotools

  1. @Test
  2. public void testToGeographic() throws Exception {
  3. String wkt =
  4. "GEOGCS[\"GDA94\","
  5. + " DATUM[\"Geocentric Datum of Australia 1994\","
  6. + " SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
  7. + " TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
  8. + " AUTHORITY[\"EPSG\",\"6283\"]], "
  9. + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
  10. + " UNIT[\"degree\", 0.017453292519943295], "
  11. + " AXIS[\"Geodetic longitude\", EAST], "
  12. + " AXIS[\"Geodetic latitude\", NORTH], "
  13. + " AXIS[\"Ellipsoidal height\", UP], "
  14. + " AUTHORITY[\"EPSG\",\"4939\"]]";
  15. CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
  16. GeometryFactory gf = new GeometryFactory();
  17. Point point = gf.createPoint(new Coordinate(130.875825803896, -16.4491956225999, 0.0));
  18. Geometry worldPoint = JTS.toGeographic(point, gda94);
  19. assertTrue(worldPoint instanceof Point);
  20. assertEquals(point.getX(), worldPoint.getCoordinate().x, 0.00000001);
  21. }

代码示例来源:origin: geotools/geotools

  1. @Test
  2. public void testToGeographicGeometry() throws Exception {
  3. // This time we are in north / east order
  4. String wkt =
  5. "GEOGCS[\"GDA94\","
  6. + " DATUM[\"Geocentric Datum of Australia 1994\","
  7. + " SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
  8. + " TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
  9. + " AUTHORITY[\"EPSG\",\"6283\"]], "
  10. + " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
  11. + " UNIT[\"degree\", 0.017453292519943295], "
  12. + " AXIS[\"Geodetic latitude\", NORTH], "
  13. + " AXIS[\"Geodetic longitude\", EAST], "
  14. + " AXIS[\"Ellipsoidal height\", UP], "
  15. + " AUTHORITY[\"EPSG\",\"4939\"]]";
  16. CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
  17. GeometryFactory gf = new GeometryFactory();
  18. Point point =
  19. gf.createPoint(
  20. new Coordinate(-16.4463909341494, 130.882672103999, 97.009018073082));
  21. Point world = (Point) JTS.toGeographic(point, gda94);
  22. assertEquals(point.getX(), world.getY(), 0.00000005);
  23. assertEquals(point.getY(), world.getX(), 0.00000005);
  24. }

代码示例来源:origin: geotools/geotools

  1. assertFalse(typeName + " bounds null", dataBounds.isNull());
  2. ReferencedEnvelope bounds = JTS.toGeographic(dataBounds);
  3. assertNotNull(typeName + " world", bounds);
  4. assertTrue(
  5. assertFalse(typeName + " world null", bounds.isNull());
  6. ReferencedEnvelope reference = JTS.toGeographic(point_test_2d.getBounds());
  7. assertNotNull("reference point_test_2d bounds", reference);
  8. assertTrue(

代码示例来源:origin: org.geotools/gt2-postgis-versioned

  1. Envelope env = geom.getEnvelopeInternal();
  2. if (crs != null)
  3. env = JTS.toGeographic(env, crs);
  4. result.expandToInclude(env);

代码示例来源:origin: org.geotools/gt2-postgis-versioned

  1. .getCoordinateSystem();
  2. if (crs != null)
  3. envelope = JTS.toGeographic(envelope, crs);
  4. state.expandDirtyBounds(envelope);

代码示例来源:origin: org.geotools/gt2-postgis-versioned

  1. .getCoordinateSystem();
  2. if (crs != null)
  3. envelope = JTS.toGeographic(envelope, crs);
  4. state.expandDirtyBounds(envelope);

相关文章