You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sedona.apache.org by "prantogg (via GitHub)" <gi...@apache.org> on 2024/11/18 23:11:22 UTC

[PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

prantogg opened a new pull request, #1684:
URL: https://github.com/apache/sedona/pull/1684

   
   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest-snapshot/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest-snapshot/community/develop/)
   
   ## Is this PR related to a JIRA ticket?
   
   - Yes, the URL of the associated JIRA ticket is https://issues.apache.org/jira/browse/SEDONA-675. The PR name follows the format `[SEDONA-XXX] my subject`.
   
   
   ## What changes were proposed in this PR?
   
   - This PR implements ST_InterpolatePoint
   - ST_InterpolatePoint returns the interpolated measure value of a linear measured LineString at the point closest to the specified point.
   
   ## How was this patch tested?
   
   - Passes new and existing tests
   
   
   ## Did this PR include necessary documentation updates?
   
   - Yes, I am adding a new API. I am using the [current SNAPSHOT version number](https://github.com/apache/sedona/blob/99239524f17389fc4ae9548ea88756f8ea538bb9/pom.xml#L29) in `vX.Y.Z` format.
   


-- 
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: dev-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu merged PR #1684:
URL: https://github.com/apache/sedona/pull/1684


-- 
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: dev-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on PR #1684:
URL: https://github.com/apache/sedona/pull/1684#issuecomment-2486473623

   @jiayuasu, does he need to create a PR in the snowflake repo? This PR does not port to Snowflake as it deals with M coordinates, @prantogg correct me if I am wrong.


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "prantogg (via GitHub)" <gi...@apache.org>.
prantogg commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1848874559


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -2377,4 +2377,57 @@ public static Geometry rotate(Geometry geometry, double angle, Geometry pointOri
     AffineTransformation rotation = AffineTransformation.rotationInstance(angle, originX, originY);
     return rotation.transform(geometry);
   }
+
+  /**
+   * This function returns the m coordinate of the closest point in a LineString to a Point. If the
+   * LineString does not have M values, it will interpolate the M value.

Review Comment:
   Thanks, fixed.



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "prantogg (via GitHub)" <gi...@apache.org>.
prantogg commented on PR #1684:
URL: https://github.com/apache/sedona/pull/1684#issuecomment-2486479262

   > Please create a separate PR against the [sedona-snowflake-tester](https://issues.apache.org/jira/browse/SEDONA-snowflake-tester) repo. It will trigger the snowflake test
   
   @jiayuasu This PR does not contribute to SedonaSnow as Snowflake currently doesn't support M ordinates


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1847451053


##########
common/src/test/java/org/apache/sedona/common/FunctionsTest.java:
##########
@@ -4086,4 +4086,29 @@ public void rotate() throws ParseException {
         "LINESTRING (0 0, -0.8390715290764524 -0.5440211108893698, -0.2950504181870827 -1.383092639965822, 0 0)",
         result);
   }
+
+  @Test
+  public void interpolatePoint() throws ParseException {
+    Geometry line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, 2 0 2, 4 0 4)");
+    Geometry point = Constructors.geomFromEWKT("POINT(1 1)");
+
+    double actual = Functions.interpolatePoint(line, point);
+    double expected = 1.0;
+    assertEquals(expected, actual, 1e-6);
+
+    line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, -2 2 2, -4 4 4)");
+    point = Constructors.geomFromEWKT("POINT(-1 1)");
+    actual = Functions.interpolatePoint(line, point);
+    assertEquals(expected, actual, 1e-6);
+
+    line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, 2 2 2, 4 0 4)");
+    point = Constructors.geomFromEWKT("POINT(2 0)");
+    actual = Functions.interpolatePoint(line, point);
+    assertEquals(expected, actual, 1e-6);
+
+    point = Constructors.geomFromEWKT("POINT(2.5 1)");
+    actual = Functions.interpolatePoint(line, point);
+    expected = 2.75;
+    assertEquals(expected, actual, 1e-6);

Review Comment:
   can you add a test for Linestring without the M ordinate?



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1847453388


##########
docs/api/flink/Function.md:
##########
@@ -2017,6 +2017,32 @@ Output:
 LINEARRING (1 1, 2 1, 2 2, 1 2, 1 1)
 ```
 
+## ST_InterpolatePoint
+
+Introduction: Returns the interpolated measure value of a linear measured LineString at the point closest to the specified point.
+
+!!!Note
+    Make sure that both geometries have the same SRID, otherwise the function will throw an IllegalArgumentException.
+
+Format: `ST_InterpolatePoint(linestringM: Geometry, point: Geometry)`
+
+Since: `v1.6.1`

Review Comment:
   same here



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #1684:
URL: https://github.com/apache/sedona/pull/1684#issuecomment-2486476047

   Yes, you are right @furqaankhan . Please don't create the PR


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1847451053


##########
common/src/test/java/org/apache/sedona/common/FunctionsTest.java:
##########
@@ -4086,4 +4086,29 @@ public void rotate() throws ParseException {
         "LINESTRING (0 0, -0.8390715290764524 -0.5440211108893698, -0.2950504181870827 -1.383092639965822, 0 0)",
         result);
   }
+
+  @Test
+  public void interpolatePoint() throws ParseException {
+    Geometry line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, 2 0 2, 4 0 4)");
+    Geometry point = Constructors.geomFromEWKT("POINT(1 1)");
+
+    double actual = Functions.interpolatePoint(line, point);
+    double expected = 1.0;
+    assertEquals(expected, actual, 1e-6);
+
+    line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, -2 2 2, -4 4 4)");
+    point = Constructors.geomFromEWKT("POINT(-1 1)");
+    actual = Functions.interpolatePoint(line, point);
+    assertEquals(expected, actual, 1e-6);
+
+    line = Constructors.geomFromEWKT("LINESTRING M (0 0 0, 2 2 2, 4 0 4)");
+    point = Constructors.geomFromEWKT("POINT(2 0)");
+    actual = Functions.interpolatePoint(line, point);
+    assertEquals(expected, actual, 1e-6);
+
+    point = Constructors.geomFromEWKT("POINT(2.5 1)");
+    actual = Functions.interpolatePoint(line, point);
+    expected = 2.75;
+    assertEquals(expected, actual, 1e-6);

Review Comment:
   can you add a test for Linestring without the M ordinate?



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1847457786


##########
common/src/main/java/org/apache/sedona/common/Functions.java:
##########
@@ -2377,4 +2377,57 @@ public static Geometry rotate(Geometry geometry, double angle, Geometry pointOri
     AffineTransformation rotation = AffineTransformation.rotationInstance(angle, originX, originY);
     return rotation.transform(geometry);
   }
+
+  /**
+   * This function returns the m coordinate of the closest point in a LineString to a Point. If the
+   * LineString does not have M values, it will interpolate the M value.

Review Comment:
   nit: i think this is misleading saying `If the LineString does not have M values, it will interpolate the M value.`. Did you mean `If the Point doesn't have M value, it will interpolate the M value`?



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "furqaankhan (via GitHub)" <gi...@apache.org>.
furqaankhan commented on code in PR #1684:
URL: https://github.com/apache/sedona/pull/1684#discussion_r1847452990


##########
docs/api/sql/Function.md:
##########
@@ -2023,6 +2023,32 @@ Output:
 LINESTRING (1 1, 2 1, 2 2, 1 2, 1 1)
 ```
 
+## ST_InterpolatePoint
+
+Introduction: Returns the interpolated measure value of a linear measured LineString at the point closest to the specified point.
+
+!!!Note
+    Make sure that both geometries have the same SRID, otherwise the function will throw an IllegalArgumentException.
+
+Format: `ST_InterpolatePoint(linestringM: Geometry, point: Geometry)`
+
+Since: `v1.6.1`

Review Comment:
   I think this is supposed to be `v1.7.0`



-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [SEDONA-675] Add ST_InterpolatePoint [sedona]

Posted by "jiayuasu (via GitHub)" <gi...@apache.org>.
jiayuasu commented on PR #1684:
URL: https://github.com/apache/sedona/pull/1684#issuecomment-2486467469

   Please create a PR against the sedona-snowflake-tester repo.


-- 
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: issues-unsubscribe@sedona.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org