<div dir="ltr"><div>Hello,</div><div><br></div><div>Geotk referencing engine is strict about CRS definition, and as stated by the official EPSG database[1], The 4326 CRS axes order is latitude first then longitude.</div><div>If you want a longitude first system, the easiest way is to use "CRS:84" code instead of "EPSG:4326", which indicates official OGC CRS for WGS84, whose axes order is longitude then latitude.</div><div><br></div><div>The jts transform does not update crs definition. You'll have to do it yourself by calling JTS.setCRS(geometry, crs)[2];<br></div><div><div><br></div><div>Regards,</div><div><br></div></div><div>[1] <a href="https://epsg.org/crs_4326/WGS-84.html">https://epsg.org/crs_4326/WGS-84.html</a></div><div>[2] <a href="https://github.com/Geomatys/geotoolkit/blob/97cfa40dca66617069afc23cbb8a21a667e1b5c1/modules/feature/geotk-geometry/src/main/java/org/geotoolkit/geometry/jts/JTS.java#L761">https://github.com/Geomatys/geotoolkit/blob/97cfa40dca66617069afc23cbb8a21a667e1b5c1/modules/feature/geotk-geometry/src/main/java/org/geotoolkit/geometry/jts/JTS.java#L761</a></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 19 mars 2021 à 12:48, juergen sorg <<a href="mailto:j.sorg@fz-juelich.de">j.sorg@fz-juelich.de</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">hi,<br>
<br>
i have a question about transforming coordinates from epsg:3857 (google) <br>
to epsg:4326 (lon lat). (i am not sure if this is the right place to ask <br>
for - but i am using geotk with jts).<br>
in [0] you can find a code snippet to transform a point and in [1] the <br>
results.<br>
my questions are:<br>
<br>
1. why are the coordinates not swapped, because after the transformation <br>
x-coord and the y-coord are at the wrong place.<br>
2. do i have to swap it by my own and if yes then how can i do it with <br>
e.g. polygons<br>
3. why the crs is still 3857 after transformation (it should 4326) and <br>
if i have to change it by my own how this can be accomplished?<br>
<br>
thanks in advance<br>
<br>
regards,<br>
juergen<br>
<br>
<br>
<br>
[0]<br>
<br>
WKTReader WKT_READER = new WKTReader(<br>
                                new GeometryFactory(new PrecisionModel(PrecisionModel.FLOATING), 3857));<br>
                String pt_google="POINT(704377.78268943 6533181.663612)";<br>
                Geometry pt_google_geom=WKT_READER.read(pt_google);<br>
<br>
                Geometry pt_wgs84_geom=JTS.transform(pt_google_geom,<br>
                                CRS.findOperation(CRS.forCode("EPSG:3857"), <br>
CRS.forCode("EPSG:4326"), null).getMathTransform());<br>
                Geometry pt_google_geom_transformed=JTS.transform(pt_wgs84_geom,<br>
                                CRS.findOperation(CRS.forCode("EPSG:4326"), <br>
CRS.forCode("EPSG:3857"), null).getMathTransform());<br>
System.out.println(pt_google_geom);<br>
System.out.println(pt_google_geom.getSRID());<br>
System.out.println(pt_wgs84_geom);<br>
System.out.println(pt_wgs84_geom.getSRID());<br>
System.out.println(pt_google_geom_transformed); <br>
System.out.println(pt_google_geom_transformed.getSRID());<br>
<br>
<br>
[1]<br>
<br>
POINT (704377.78268943 6533181.663612)<br>
3857<br>
POINT (50.499200582184564 6.327533279841338)<br>
3857<br>
POINT (704377.7826894299 6533181.663611999)<br>
3857<br>
<br>
_______________________________________________<br>
Geotoolkit mailing list<br>
<a href="mailto:Geotoolkit@lists.osgeo.org" target="_blank">Geotoolkit@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geotoolkit" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/geotoolkit</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Alexis Manin,<br>Développeur JAVA/JEE.<br>Geomatys.<br><br><img src="https://drive.google.com/a/geomatys.com/uc?id=0BzSiAcVRHmQcdXhxZjgwQlM4ODJIUXRrRk5Fa1ZQT3prTm5Z&export=download"><br><img alt=""></div></div></div></div></div></div></div></div></div></div></div></div></div>