本文整理了Java中org.geotools.geometry.jts.JTS.toGeographic()
方法的一些代码示例,展示了JTS.toGeographic()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTS.toGeographic()
方法的具体详情如下:
包路径:org.geotools.geometry.jts.JTS
类名称: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
/**
* Transforms the envelope from its current crs to {@link DefaultGeographicCRS#WGS84}. If the
* specified envelope is already in WGS84, then it is returned unchanged.
*
* <p>The method {@link CRS#equalsIgnoreMetadata(Object, Object)} is used to compare the numeric
* values and axis order (so {@code CRS.decode("CRS.84")} or {@code CRS.decode("4326",true)}
* provide an appropriate match).
*
* @param envelope The envelope to transform.
* @param crs The CRS the envelope is currently in.
* @return The envelope transformed to be in {@link DefaultGeographicCRS#WGS84}.
* @throws TransformException If at least one coordinate can't be transformed.
*/
public static Envelope toGeographic(
final Envelope envelope, final CoordinateReferenceSystem crs)
throws TransformException {
if (CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) {
if (envelope instanceof ReferencedEnvelope) {
return envelope;
}
return ReferencedEnvelope.create(envelope, DefaultGeographicCRS.WGS84);
}
ReferencedEnvelope initial = ReferencedEnvelope.create(envelope, crs);
return toGeographic(initial);
}
/**
代码示例来源:origin: geotools/geotools
@Test
public void testToGeographicGeometry() throws Exception {
// This time we are in north / east order
CoordinateReferenceSystem gda94 = CRS.decode("EPSG:4939", true);
GeometryFactory gf = new GeometryFactory();
Point point =
gf.createPoint(
new Coordinate(130.882672103999, -16.4463909341494, 97.009018073082));
Point world = (Point) JTS.toGeographic(point, gda94);
assertEquals(point.getX(), world.getX(), 0.00000005);
assertEquals(point.getY(), world.getY(), 0.00000005);
}
代码示例来源:origin: geotools/geotools
gda94);
ReferencedEnvelope worldBounds = JTS.toGeographic(bounds);
assertEquals(DefaultGeographicCRS.WGS84, worldBounds.getCoordinateReferenceSystem());
130.875825803896, 130.898939990319, -16.4491956225999, -16.4338185791628);
Envelope worldBounds2 = JTS.toGeographic(envelope, gda94);
if (worldBounds2 instanceof BoundingBox) {
assertEquals(
代码示例来源:origin: geotools/geotools
@Test
public void testBounds() throws Exception {
ReferencedEnvelope bounds2d = point_test_2d.getBounds();
ReferencedEnvelope bounds3d = point_test.getBounds();
double aspect2d = bounds2d.getWidth() / bounds2d.getHeight();
double aspect3d = bounds3d.getWidth() / bounds3d.getHeight();
assertEquals(aspect2d, aspect3d, 0.0005);
ReferencedEnvelope bbox2d = JTS.toGeographic(bounds2d);
ReferencedEnvelope bbox3d = JTS.toGeographic(bounds3d);
aspect2d = bbox2d.getWidth() / bbox2d.getHeight();
aspect3d = bbox3d.getWidth() / bbox3d.getHeight();
assertEquals(aspect2d, aspect3d, 0.000005);
}
代码示例来源:origin: geotools/geotools
@Test
public void testToGeographic() throws Exception {
String wkt =
"GEOGCS[\"GDA94\","
+ " DATUM[\"Geocentric Datum of Australia 1994\","
+ " SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
+ " TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
+ " AUTHORITY[\"EPSG\",\"6283\"]], "
+ " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
+ " UNIT[\"degree\", 0.017453292519943295], "
+ " AXIS[\"Geodetic longitude\", EAST], "
+ " AXIS[\"Geodetic latitude\", NORTH], "
+ " AXIS[\"Ellipsoidal height\", UP], "
+ " AUTHORITY[\"EPSG\",\"4939\"]]";
CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
GeometryFactory gf = new GeometryFactory();
Point point = gf.createPoint(new Coordinate(130.875825803896, -16.4491956225999, 0.0));
Geometry worldPoint = JTS.toGeographic(point, gda94);
assertTrue(worldPoint instanceof Point);
assertEquals(point.getX(), worldPoint.getCoordinate().x, 0.00000001);
}
代码示例来源:origin: geotools/geotools
@Test
public void testToGeographicGeometry() throws Exception {
// This time we are in north / east order
String wkt =
"GEOGCS[\"GDA94\","
+ " DATUM[\"Geocentric Datum of Australia 1994\","
+ " SPHEROID[\"GRS 1980\", 6378137.0, 298.257222101, AUTHORITY[\"EPSG\",\"7019\"]],"
+ " TOWGS84[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "
+ " AUTHORITY[\"EPSG\",\"6283\"]], "
+ " PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]],"
+ " UNIT[\"degree\", 0.017453292519943295], "
+ " AXIS[\"Geodetic latitude\", NORTH], "
+ " AXIS[\"Geodetic longitude\", EAST], "
+ " AXIS[\"Ellipsoidal height\", UP], "
+ " AUTHORITY[\"EPSG\",\"4939\"]]";
CoordinateReferenceSystem gda94 = CRS.parseWKT(wkt);
GeometryFactory gf = new GeometryFactory();
Point point =
gf.createPoint(
new Coordinate(-16.4463909341494, 130.882672103999, 97.009018073082));
Point world = (Point) JTS.toGeographic(point, gda94);
assertEquals(point.getX(), world.getY(), 0.00000005);
assertEquals(point.getY(), world.getX(), 0.00000005);
}
代码示例来源:origin: geotools/geotools
assertFalse(typeName + " bounds null", dataBounds.isNull());
ReferencedEnvelope bounds = JTS.toGeographic(dataBounds);
assertNotNull(typeName + " world", bounds);
assertTrue(
assertFalse(typeName + " world null", bounds.isNull());
ReferencedEnvelope reference = JTS.toGeographic(point_test_2d.getBounds());
assertNotNull("reference point_test_2d bounds", reference);
assertTrue(
代码示例来源:origin: org.geotools/gt2-postgis-versioned
Envelope env = geom.getEnvelopeInternal();
if (crs != null)
env = JTS.toGeographic(env, crs);
result.expandToInclude(env);
代码示例来源:origin: org.geotools/gt2-postgis-versioned
.getCoordinateSystem();
if (crs != null)
envelope = JTS.toGeographic(envelope, crs);
state.expandDirtyBounds(envelope);
代码示例来源:origin: org.geotools/gt2-postgis-versioned
.getCoordinateSystem();
if (crs != null)
envelope = JTS.toGeographic(envelope, crs);
state.expandDirtyBounds(envelope);
内容来源于网络,如有侵权,请联系作者删除!