Pooja444 commented on code in PR #621:
URL: https://github.com/apache/incubator-sedona/pull/621#discussion_r856843811


##########
core/src/main/java/org/apache/sedona/core/utils/GeomUtils.java:
##########
@@ -81,6 +84,38 @@ public static Geometry getInteriorPoint(Geometry geometry) {
         return geometry.getInteriorPoint();
     }
 
+    /**
+     * Return the nth point from the given geometry (which could be a 
linestring or a circular linestring)
+     * If the value of n is negative, return a point backwards
+     * E.g. if n = 1, return 1st point, if n = -1, return last point
+     *
+     * @param lineString from which the nth point is to be returned
+     * @param n is the position of the point in the geometry
+     * @return a point
+     */
+    public static Geometry getNthPoint(LineString lineString, int n) {
+        if (lineString == null || n == 0) {
+            return null;
+        }
+
+        int p = lineString.getNumPoints();
+        if (Math.abs(n) > p) {
+            return null;
+        }
+
+        Coordinate[] nthCoordinate = new Coordinate[1];
+        if (n > 0) {
+            nthCoordinate[0] = lineString.getCoordinates()[n - 1];
+        } else {
+            nthCoordinate[0] = lineString.getCoordinates()[p + n];
+        }
+        return new Point(new CoordinateArraySequence(nthCoordinate), 
lineString.getFactory());
+    }
+
+    public static Geometry getExteriorRing(Geometry geometry) {
+        return 
geometry.getFactory().createLinearRing(geometry.getCoordinates());

Review Comment:
   Sure, I updated this



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