Estoy intentando convertir EPSG: 3857 a EPSG: 4326 con geotools. Aquí está mi código :
public void convertEPSG3857toEPSG4326() throws FactoryException, TransformException {
try {
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3857");
MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, false);
GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326);
Point point = geometryFactory.createPoint(new Coordinate(x, y));
Point targetPoint = (Point) JTS.transform(point, transform);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Problem for : x = " + x + " y = " + y);
}
}
Para el geojson :
{"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::3857"}},"type":"FeatureCollection","features":[{"type":"Feature","properties":{"FID":123,"TEXT":"yolo","attaches":[]},"geometry":{"type":"Polygon","coordinates":[[[9830100,3500101.25],[9699943,2332626],[10394759,2332626],[9830100,3500101.25]]]}}]}
Sigo recibiendo este error :
Problem for : x = 9830100.0 y = 3500101.25
Problem for : x = 9699943.0 y = 2332626.0
Problem for : x = 1.0394759E7 y = 2332626.0
2017-05-15T10:59:39.710+0530 WARNING Possible use of "Popular Visualisation Pseudo Mercator" projection outside its valid area.
Longitude 3499741°15.0'E is out of range (±180°).
Latitude 9829740°00.0'N is out of range (±90°).
org.geotools.referencing.operation.projection.ProjectionException: Latitude 9829740°00.0'N is too close to a pole.
at org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:209)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:897)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:938)
at org.geotools.referencing.operation.transform.ConcatenatedTransformDirect.transform(ConcatenatedTransformDirect.java:81)
at org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:123)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:295)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:282)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:148)
at org.geotools.geometry.jts.JTS.transform(JTS.java:442)
at gis.GISCoordinate.convertEPSG3857toEPSG4326(GISCoordinate.java:52)
at gis.FeatureCollector.getAllGisFeature(FeatureCollector.java:65)
at MergeGis.main(MergeGis.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
org.geotools.referencing.operation.projection.ProjectionException: Latitude 9699583°00.0'N is too close to a pole.
at org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:209)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:897)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:938)
at org.geotools.referencing.operation.transform.ConcatenatedTransformDirect.transform(ConcatenatedTransformDirect.java:81)
at org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:123)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:295)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:282)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:148)
at org.geotools.geometry.jts.JTS.transform(JTS.java:442)
at gis.GISCoordinate.convertEPSG3857toEPSG4326(GISCoordinate.java:52)
at gis.FeatureCollector.getAllGisFeature(FeatureCollector.java:65)
at MergeGis.main(MergeGis.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
org.geotools.referencing.operation.projection.ProjectionException: Latitude 10394399°00.0'N is too close to a pole.
at org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:209)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:897)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:938)
at org.geotools.referencing.operation.transform.ConcatenatedTransformDirect.transform(ConcatenatedTransformDirect.java:81)
at org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:123)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:295)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:282)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:148)
at org.geotools.geometry.jts.JTS.transform(JTS.java:442)
at gis.GISCoordinate.convertEPSG3857toEPSG4326(GISCoordinate.java:52)
at gis.FeatureCollector.getAllGisFeature(FeatureCollector.java:65)
at MergeGis.main(MergeGis.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
org.geotools.referencing.operation.projection.ProjectionException: Latitude 9829740°00.0'N is too close to a pole.
at org.geotools.referencing.operation.projection.Mercator$Spherical.transformNormalized(Mercator.java:209)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:897)
at org.geotools.referencing.operation.projection.MapProjection.transform(MapProjection.java:938)
at org.geotools.referencing.operation.transform.ConcatenatedTransformDirect.transform(ConcatenatedTransformDirect.java:81)
at org.geotools.geometry.jts.DefaultCoordinateSequenceTransformer.transform(DefaultCoordinateSequenceTransformer.java:123)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.projectCoordinateSequence(GeometryCoordinateSequenceTransformer.java:295)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transformPoint(GeometryCoordinateSequenceTransformer.java:282)
at org.geotools.geometry.jts.GeometryCoordinateSequenceTransformer.transform(GeometryCoordinateSequenceTransformer.java:148)
at org.geotools.geometry.jts.JTS.transform(JTS.java:442)
at gis.GISCoordinate.convertEPSG3857toEPSG4326(GISCoordinate.java:52)
at gis.FeatureCollector.getAllGisFeature(FeatureCollector.java:65)
at MergeGis.main(MergeGis.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
¿Cuál es el problema?