2

Solved, reading mail-archive I can understand that there is a conflict between:

  • gt-epsg-wkt-9.2.jar
  • gt-epsg-hsql-9.2.jar

I tested removing each one, with 'hsql' I get the same wrong result, but with 'wkt' the result is apparently correct:

POLYGON ((1008607.2669034603 934072.2524703469, 1119664.4273319552 934150.3439472048, 1119791.4166697538 823552.3609040213, 1008616.3988750693 823493.7092892379, 1008607.2669034603 934072.2524703469))

I slightly understand that there is a problem with the coordinate axis, as sugested a comment below, but I tried with both libraries:

 System.setProperty("org.geotools.referencing.forceXY", "true");

The result is still wrong, I suppose that must exist a solution without exclude a library gt-epsg-hsql-9.2.jar.


I tried to project a square with KML coordinates:

POLYGON ((-74 4.00000000013149, -73 4.00000000013149, -73 3.0000000000987583, -74 3.0000000000987583, -74 4.00000000013149))

enter image description here

Into the EPSG:3116, Magna-Sirgas-Bogota coordinates, so the result is:

POLYGON ((-9130927.896477975 2771311.8407411724, -9105351.47332166 2884393.3410715847, -9072295.496257499 2876530.4903936666, -9099848.751098553 2763923.9776131, -9130927.896477975 2771311.8407411724))

So, the result is between Cuba and Miami: enter image description here

The code that i use is:

CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:3116");
MathTransform   transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
OutGeometry = JTS.transform(myGeometry, transform);

Is possible that the code below is wrong? or the library has a bug?, i've see the reported bug: Swiss Issue

And i think that is something like that, what do you think about this issue?, I'm using the Geotools Api 9.2.

  • 1
    It may be a coordinate order issue - see docs.geotools.org/latest/tutorials/geometry/… – Ian Turton Apr 23 '14 at 18:45
  • I think @iant is right. I tried projecting lon:4 lat:-74 into 3116 using Esri projection engine and got easting: 2771312, northing: -9130928 (no geotransformation). Using lon: -74 lat:4, easting: 1008607, northing: 934072. – mkennedy Apr 23 '14 at 19:40
1

I can confirm that the output is wrong. Using QGIS, the reprojected polygon would be:

POLYGON ((1008607.2669 934072.252456,1119664.42733 934150.343933,1119791.41667 823552.360893, 1008616.39888 823493.709278, 1008607.2669 934072.252456))

The coordinates have to be positive for the whole of Colombia:

enter image description here

But it has nothing to do with the swiss projection bug, which uses an oblique mercator projection. Your target CRS uses standard transverse mercator, and that should be handled correct in Geotools.

BTW: Your second picture is in EPSG:3857 if the rectangle is between Cuba and Florida. With EPSG:3116, it is squeezed south east of Tucson.


EDIT

Following iants remark, if I exchange x and y degree coordinates, and reproject from EPSG:4326 to EPSG:3116, I get the same coordinates as you:

"shapeid","x","y"
"0","2771311.8415","-9130927.8963"
"0","2763923.97837","-9099848.75091"
"0","2876530.49128","-9072295.49604"
"0","2884393.34196","-9105351.47311"
"0","2771311.8415","-9130927.8963"

(To be precise, the result has to be swapped back again)

  • Yes, you're right, the projection is somewhere in Tucson, sorry. – Dinl Apr 23 '14 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.