I'm not familiar with the third method, but tried the first two on 21.x:

Plain: GeneralDirectPosition[259878.57433310486, 377178.60575377225]
JTS: POINT (259878.57433310486 377178.60575377225)

and 22.x (has the new EPSG database):

Plain: GeneralDirectPosition[259878.57433310486, 377178.60575377225]
JTS: POINT (259878.57433310486 377178.60575377225)

Also tried out using epsg-wkt instead of epsg-hsql, but results did not
change for me.
I don't know what's going on with your installation, but gut feeling, I'd
check the classpath (are you using Maven)?

Cheers
Andrea


On Fri, Sep 20, 2019 at 10:25 AM Clemens Eisserer <linuxhi...@gmail.com>
wrote:

> 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
>


-- 

Regards, Andrea Aime == GeoServer Professional Services from the experts!
Visit http://goo.gl/it488V for more information. == Ing. Andrea Aime
@geowolf Technical Lead GeoSolutions S.A.S. Via di Montramito 3/A 55054
Massarosa (LU) phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339
8844549 http://www.geo-solutions.it http://twitter.com/geosolutions_it
------------------------------------------------------- *Con riferimento
alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 -
Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni
circostanza inerente alla presente email (il suo contenuto, gli eventuali
allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i
destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per
errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le
sarei comunque grato se potesse darmene notizia. This email is intended
only for the person or entity to which it is addressed and may contain
information that is privileged, confidential or otherwise protected from
disclosure. We remind that - as provided by European Regulation 2016/679
“GDPR” - copying, dissemination or use of this e-mail or the information
herein by anyone other than the intended recipient is prohibited. If you
have received this email by mistake, please notify us immediately by
telephone or e-mail.*
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to