locationtech / proj4j

Java port of the Proj.4 library for coordinate reprojection
Other
181 stars 71 forks source link

Conversion problem from EPSG:2393 to EPSG:4326 #66

Closed jsandhol closed 3 years ago

jsandhol commented 3 years ago

Not sure if it's me doing something wrong... When running cs2cs with PROJ I get:

echo 6675487 3385780 0 | cs2cs EPSG:2393 EPSG:4326 -f %.15f
60.174995098323301 24.938895095805286 0.000000000000000

This is correct.

But when I try the same (I assume) with proj4j:

CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
CRSFactory csFactory = new CRSFactory();

CoordinateReferenceSystem crs1 = csFactory.createFromName("EPSG:2393");
CoordinateReferenceSystem crs2 = csFactory.createFromName("EPSG:4326");
CoordinateTransform trans = ctFactory.createTransform(crs1, crs2);

ProjCoordinate p1 = new ProjCoordinate();
ProjCoordinate p2 = new ProjCoordinate();

p1.x = 6675487;
p1.y = 3385780;

trans.transform(p1, p2);

System.out.println(p2.x + ", " + p2.y);

I get:

58.03298223195199, 26.844729418500016

Which is way off. Something wrong with EPSG:2393 proj4j vs proj? I have no experience on this field, just trying to use the library...

jsandhol commented 3 years ago

Looks like this x and y should be the other way around. Closing...