This is an automated email from the ASF dual-hosted git repository. jiayu pushed a commit to branch SEDONA-589 in repository https://gitbox.apache.org/repos/asf/sedona.git
commit 5ef46b0bc45bba150bf2fe89e3b111ac5c25793e Author: Furqaan Khan <[email protected]> AuthorDate: Fri Apr 26 15:06:38 2024 -0400 fix: bug of ST_LongestLine (#173) * temp commit * Revert "temp commit" This reverts commit 8cd8ecc6b3ae533379b779ba08c23b12df47e2fc. * feat: Add ST_LongestLine * fix: bug that would cause null pointer exception --- common/src/main/java/org/apache/sedona/common/Functions.java | 2 +- common/src/test/java/org/apache/sedona/common/FunctionsTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/apache/sedona/common/Functions.java b/common/src/main/java/org/apache/sedona/common/Functions.java index 5025fd19f..7787013cd 100644 --- a/common/src/main/java/org/apache/sedona/common/Functions.java +++ b/common/src/main/java/org/apache/sedona/common/Functions.java @@ -1063,7 +1063,7 @@ public class Functions { } public static Geometry longestLine(Geometry geom1, Geometry geom2) { - double maxLength = 0; + double maxLength = - Double.MAX_VALUE; Coordinate longestStart = null; Coordinate longestEnd = null; diff --git a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java index ab0ebe0db..e50e34192 100644 --- a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java +++ b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java @@ -1042,6 +1042,11 @@ public class FunctionsTest extends TestBase { actual = Functions.asWKT(Functions.longestLine(geom1, geom2)); expected = "LINESTRING Z(10 20 5, 50 60 20)"; assertEquals(expected, actual); + + geom1 = Constructors.geomFromWKT("POINT (0 0)", 0); + actual = Functions.asWKT(Functions.longestLine(geom1, geom1)); + expected = "LINESTRING (0 0, 0 0)"; + assertEquals(expected, actual); } @Test
