Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Distance3Dop geometries order #480

Merged

Conversation

piomar123
Copy link
Contributor

Coordinates returned by Distance3Dop.nearestPoints() had a reversed order.
Additionally, the javadoc has been clarified to note that Distance3Dop does not interpolate Z ordinate which was not obvious.

Signed-off-by: Piotr Marcińczyk <piomar123@gmail.com>
@piomar123 piomar123 force-pushed the distance3dop-fix-coordinates-order branch from 2274b2e to 6cf5c0c Compare September 25, 2019 12:52
@piomar123
Copy link
Contributor Author

Maybe it would be better to create a separate method and deprecate the old one?

@dr-jts
Copy link
Contributor

dr-jts commented Sep 25, 2019

This looks good. Thanks for the patch.

@dr-jts dr-jts merged commit ddbedd0 into locationtech:master Sep 25, 2019
@radi2015
Copy link

radi2015 commented Aug 27, 2020

why different
Distance3DOp distance3DOp1=new Distance3DOp(g1,g2);
Distance3DOp distance3DOp1=new Distance3DOp(g2,g1);

code:
WKTReader wktReader=new WKTReader();
String wkt1="LineString Z (13520263.3311040997505188 3654113.41769909998401999 14.55408463999999924," +
" 13520263.98897077143192291 3654108.78580632992088795 14.56306395999999914," +
" 13520265.05638116039335728 3654101.43723948998376727 14.5861752899999999)";
String wkt2="LineString Z (13520262.04566529020667076 3654122.22497142991051078 14.53834022000000026, " +
"13520263.19403318502008915 3654114.04906051000580192 14.55408463999999924)";

Geometry g1 = wktReader.read(wkt1);
Geometry g2 = wktReader.read(wkt2);

Distance3DOp distance3DOp1=new Distance3DOp(g1,g2);
Coordinate[] coordinates1 = distance3DOp1.nearestPoints();
System.out.println(geometryFactory.createPoint(coordinates1[0]).distance(geometryFactory.createPoint(coordinates1[1])));
Distance3DOp distance3DOp2=new Distance3DOp(g2,g1);
Coordinate[] coordinates2 = distance3DOp2.nearestPoints();
System.out.println(geometryFactory.createPoint(coordinates2[0]).distance(geometryFactory.createPoint(coordinates2[1])));`
out:
0.6460693969920951
5.322947522798961

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants