yyy1000 commented on code in PR #877:
URL: https://github.com/apache/sedona/pull/877#discussion_r1248382018
##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -447,6 +448,17 @@ public static Geometry lineFromMultiPoint(Geometry
geometry) {
return GEOMETRY_FACTORY.createLineString(coordinates.toArray(new
Coordinate[0]));
}
+ public static Geometry closestPoint(Geometry left, Geometry right) {
+ DistanceOp distanceOp = new DistanceOp(left, right);
+ try {
+ Coordinate[] closestPoints = distanceOp.nearestPoints();
+ return GEOMETRY_FACTORY.createPoint(closestPoints[0]);
+ }
+ catch (Exception e) {
+ return null;
Review Comment:
Should we throw an exception or just return a null value? I think postgis
return an empty value:
```
postgres=# select ST_AsText(ST_ClosestPoint(ST_GeomFromText('POINT EMPTY'),
ST_GeomFromText('LINESTRING (0 0, 1 0, 2
0, 3 0, 4 0, 5 0)')));
st_astext
-----------
(1 row)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]