jiayuasu commented on code in PR #1765:
URL: https://github.com/apache/sedona/pull/1765#discussion_r1929028115


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -1156,6 +1156,35 @@ public static Geometry lineMerge(Geometry geometry) {
     return geometry.getFactory().createGeometryCollection();
   }
 
+  public static Geometry[] lineSegments(Geometry geometry, boolean lenient) {
+    if (!(geometry instanceof LineString)) {
+      if (lenient) {
+        return new Geometry[] {};
+      } else {
+        throw new IllegalArgumentException(
+            "Geometry is not a LineString. This function expects input 
geometry to be a LineString.");
+      }
+    }
+
+    LineString line = (LineString) geometry;
+    Coordinate[] coords = line.getCoordinates();
+    if (coords.length == 2 || coords.length == 0) {
+      return new Geometry[] {line};
+    }
+
+    GeometryFactory geometryFactory = geometry.getFactory();
+    List<Geometry> resultList = new ArrayList<>();

Review Comment:
   Why not use Array directly? You already know the size of the array in 
advance.



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