Thanks for testing, GeoTools recently upgraded to EPSG database we use so
you may be seeing some differences.

You may wish to check the definition against https://www.epsg-registry.org
--
Jody Garnett


On Fri, 20 Sep 2019 at 02:57, Clemens Eisserer <linuxhi...@gmail.com> wrote:

> Hi again,
>
> After digging deeper, it seems the different transformation results I
> observe with 21.2 are caused by differing CRS-definitions.
> When exporting the CRSs from 14.3 to WTK and loading those WTKs with
> 21.2, I get the same (valid?) transformation result I get with 14.3.
>
> However the difference between 21.2 WTKs and 14.3 WTKs seem to be
> limited to rounding errors:
>
> WTK 14.3:
>
> PROJCS["MGI (Ferro) / Austria GK West Zone",
>   GEOGCS["MGI (Ferro)",
>     DATUM["Militar-Geographische Institut (Ferro)",
>       SPHEROID["Bessel 1841", 6377397.155, 299.1528128,
> AUTHORITY["EPSG","7004"]],
>       AUTHORITY["EPSG","6805"]],
>     PRIMEM["Ferro", -17.666666666666668, AUTHORITY["EPSG","8909"]],
>     UNIT["degree", 0.017453292519943295],
>     AXIS["Geodetic longitude", EAST],
>     AXIS["Geodetic latitude", NORTH],
>     AUTHORITY["EPSG","4805"]],
>   PROJECTION["Transverse_Mercator"],
>   PARAMETER["central_meridian", 28.0],
>   PARAMETER["latitude_of_origin", 0.0],
>   PARAMETER["scale_factor", 1.0],
>   PARAMETER["false_easting", 0.0],
>   PARAMETER["false_northing", -5000000.0],
>   UNIT["m", 1.0],
>   AXIS["Easting", EAST],
>   AXIS["Northing", NORTH],
>   AUTHORITY["EPSG","31251"]]
>
>
> PROJCS["MGI / Austria Lambert",
>   GEOGCS["MGI",
>     DATUM["Militar-Geographische Institut",
>       SPHEROID["Bessel 1841", 6377397.155, 299.1528128,
> AUTHORITY["EPSG","7004"]],
>       TOWGS84[601.705, 84.263, 485.227, 4.7354, -1.3145, -5.393, -2.3887],
>       AUTHORITY["EPSG","6312"]],
>     PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
>     UNIT["degree", 0.017453292519943295],
>     AXIS["Geodetic longitude", EAST],
>     AXIS["Geodetic latitude", NORTH],
>     AUTHORITY["EPSG","4312"]],
>   PROJECTION["Lambert_Conformal_Conic_2SP"],
>   PARAMETER["central_meridian", 13.333333333333334],
>   PARAMETER["latitude_of_origin", 47.5],
>   PARAMETER["standard_parallel_1", 49.0],
>   PARAMETER["false_easting", 400000.0],
>   PARAMETER["false_northing", 400000.0],
>   PARAMETER["scale_factor", 1.0],
>   PARAMETER["standard_parallel_2", 46.0],
>   UNIT["m", 1.0],
>   AXIS["Easting", EAST],
>   AXIS["Northing", NORTH],
>   AUTHORITY["EPSG","31287"]]
>
>
> WTK 21.2:
>
> PROJCS["MGI (Ferro) / Austria GK West Zone",
>   GEOGCS["MGI (Ferro)",
>     DATUM["Militar-Geographische Institut (Ferro)",
>       SPHEROID["Bessel 1841", 6377397.155, 299.1528128,
> AUTHORITY["EPSG","7004"]],
>       AUTHORITY["EPSG","6805"]],
>     PRIMEM["Ferro", -17.666666666666668, AUTHORITY["EPSG","8909"]],
>     UNIT["degree", 0.017453292519943295],
>     AXIS["Geodetic latitude", NORTH],
>     AXIS["Geodetic longitude", EAST],
>     AUTHORITY["EPSG","4805"]],
>   PROJECTION["Transverse_Mercator", AUTHORITY["EPSG","9807"]],
>   PARAMETER["central_meridian", 28.0],
>   PARAMETER["latitude_of_origin", 0.0],
>   PARAMETER["scale_factor", 1.0],
>   PARAMETER["false_easting", 0.0],
>   PARAMETER["false_northing", -5000000.0],
>   UNIT["m", 1.0],
>   AXIS["Northing", NORTH],
>   AXIS["Easting", EAST],
>   AUTHORITY["EPSG","31251"]]
>
>
> PROJCS["MGI / Austria Lambert",
>   GEOGCS["MGI",
>     DATUM["Militar-Geographische Institut",
>       SPHEROID["Bessel 1841", 6377397.155, 299.1528128,
> AUTHORITY["EPSG","7004"]],
>       TOWGS84[601.705, 84.263, 485.227, 4.7354, -1.3145, -5.393, -2.3887],
>       AUTHORITY["EPSG","6312"]],
>     PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],
>     UNIT["degree", 0.017453292519943295],
>     AXIS["Geodetic latitude", NORTH],
>     AXIS["Geodetic longitude", EAST],
>     AUTHORITY["EPSG","4312"]],
>   PROJECTION["Lambert_Conformal_Conic_2SP", AUTHORITY["EPSG","9802"]],
>   PARAMETER["central_meridian", 13.333333333333336],
>   PARAMETER["latitude_of_origin", 47.5],
>   PARAMETER["standard_parallel_1", 48.99999999999999],
>   PARAMETER["false_easting", 400000.0],
>   PARAMETER["false_northing", 400000.0],
>   PARAMETER["scale_factor", 1.0],
>   PARAMETER["standard_parallel_2", 46.0],
>   UNIT["m", 1.0],
>   AXIS["Northing", NORTH],
>   AXIS["Easting", EAST],
>   AUTHORITY["EPSG","31287"]]
>
> Am Fr., 20. Sept. 2019 um 10:23 Uhr schrieb Clemens Eisserer
> <linuxhi...@gmail.com>:
> >
> > Hi,
> >
> > After upgrading an application from geotools-14.3 to 21.2 I've
> > observed strange behaviour when transforming points from one CRS
> > (EPSG:31251) to another (EPSG:31287).
> > The original code we had dies with an exception, however even two
> > other tries return different results from what I got with 14.3.
> > With an external tool I also get results which are identical to what
> > 14.3 returns.
> >
> > With 14.3 all 3 tries succeed and return the expected result:
> > > OldWay: POINT (259878.57433310486 377178.60575377225)
> > > Plain: GeneralDirectPosition[259878.57433310486, 377178.60575377225]
> > > JTS: POINT (259878.57433310486 377178.60575377225)
> >
> > With 21.2 the geometryBuilder-based way fails, the two others return
> > consistent but different (wrong?) results:
> > > Plain: GeneralDirectPosition[219916.12907210115, 405574.2553041743]
> > > JTS: POINT (219916.12907210115 405574.2553041743)
> > > java.lang.IllegalArgumentException: DirectPosition cannot have a null
> CRS
> > >    at
> org.geotools.geometry.jts.spatialschema.geometry.DirectPositionImpl.setCRS(DirectPositionImpl.java:155)
> > >    at
> org.geotools.geometry.jts.spatialschema.geometry.DirectPositionImpl.<init>(DirectPositionImpl.java:125)
> > >    at
> org.geotools.geometry.jts.spatialschema.geometry.primitive.PrimitiveFactoryImpl.createDirectPosition(PrimitiveFactoryImpl.java:95)
> > >    at
> org.geotools.geometry.jts.spatialschema.geometry.primitive.PrimitiveFactoryImpl.createPoint(PrimitiveFactoryImpl.java:103)
> > >    at
> org.geotools.geometry.GeometryBuilder.createPoint(GeometryBuilder.java:352)
> > >    at
> org.geotools.geometry.GeometryBuilder.createPoint(GeometryBuilder.java:320)
> >
> > Any idea whats going on here?
> >
> > Best regards, Clemens
> >
> >
> > public class CoordinateTransformTest {
> >
> >     @Test
> >     public void testTransform() throws FactoryException,
> TransformException {
> >         CoordinateReferenceSystem gkCRS = CRS.decode("EPSG:31251");
> >         CoordinateReferenceSystem dbCRS = CRS.decode("EPSG:31287");
> >
> >         MathTransform transform = CRS.findMathTransform(gkCRS, dbCRS,
> true);
> >         DirectPosition2D pos2D = new DirectPosition2D(86765.44,
> 238436.25);
> >
> >         DirectPosition posTransformed = transform.transform(pos2D, null);
> >         System.out.println("Plain: "+posTransformed);
> >
> >         Point transformedPoint = (Point)
> > JTS.transform(JTS.toGeometry(pos2D.getDirectPosition()), transform);
> >         System.out.println("JTS: "+transformedPoint);
> >     }
> >
> >     @Test
> >     public void testOldWay()  throws FactoryException,
> TransformException  {
> >         CoordinateReferenceSystem gkCRS = CRS.decode("EPSG:31251");
> >         CoordinateReferenceSystem dbCRS = CRS.decode("EPSG:31287");
> >
> >         GeometryBuilder geometryBuilder = new GeometryBuilder(gkCRS);
> >
> >         org.opengis.geometry.primitive.Point point =
> > geometryBuilder.createPoint(86765.44, 238436.25);
> >
> >         MathTransform mtf = CRS.findMathTransform(gkCRS, dbCRS, true);
> >
> >         Point transformedPoint = (Point)
> > JTS.transform(JTS.toGeometry(point.getDirectPosition()), mtf);
> >         System.out.println("OldWay: "+transformedPoint);
> >     }
> > }
>
>
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to