iGN5117 commented on code in PR #877:
URL: https://github.com/apache/sedona/pull/877#discussion_r1248455264


##########
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:
   It is better to throw an exception, in a case where multiple functions are 
stringed together, which is what happens usually, throwing null means user 
would see an unexplainable NullPointerException eventually.
   
   By throwing an IllegalArgumentException with a proper message, we will end 
up helping the user.



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

Reply via email to