From c93152a3f05553aba856045ca1d1863a12dc7340 Mon Sep 17 00:00:00 2001 From: Kristin Cowalcijk Date: Thu, 22 Jan 2026 08:57:54 +0800 Subject: [PATCH 1/2] Fix polygon split by line by replicating the logic from PostGIS --- .../sedona/common/utils/GeometrySplitter.java | 19 ++++++--- .../apache/sedona/common/FunctionsTest.java | 41 +++++++++++++++++++ 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/apache/sedona/common/utils/GeometrySplitter.java b/common/src/main/java/org/apache/sedona/common/utils/GeometrySplitter.java index 7045316fed3..89473c5d3c7 100644 --- a/common/src/main/java/org/apache/sedona/common/utils/GeometrySplitter.java +++ b/common/src/main/java/org/apache/sedona/common/utils/GeometrySplitter.java @@ -262,13 +262,9 @@ private void splitOnCoord(LinearGeometryBuilder lineBuilder, Coordinate coord) { } private Geometry generateCandidatePolygons(Geometry polygons, Geometry blade) { - // restrict the blade to only be within the original polygon to - // avoid candidate polygons that are impossible - Geometry bladeWithinPolygons = blade.intersection(polygons); - // a union will node all the lines at intersections // these nodes are required for Polygonizer to work correctly - Geometry totalLineWork = polygons.getBoundary().union(bladeWithinPolygons); + Geometry totalLineWork = polygons.getBoundary().union(blade); Polygonizer polygonizer = new Polygonizer(); polygonizer.add(totalLineWork); @@ -281,7 +277,18 @@ private void addValidPolygonsToList(Geometry polygons, Geometry original, List

Date: Thu, 22 Jan 2026 09:02:05 +0800 Subject: [PATCH 2/2] Remove unnecessary function --- .../org/apache/sedona/common/FunctionsTest.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) 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 0ff5b2503e5..c4e63251437 100644 --- a/common/src/test/java/org/apache/sedona/common/FunctionsTest.java +++ b/common/src/test/java/org/apache/sedona/common/FunctionsTest.java @@ -24,8 +24,6 @@ import com.google.common.geometry.S2CellId; import com.google.common.math.DoubleMath; -import java.io.IOException; -import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; import org.apache.sedona.common.sphere.Haversine; @@ -64,15 +62,6 @@ protected int compareCoordinate( } }; - private static String readResourceString(String resourcePath) throws IOException { - try (InputStream inputStream = FunctionsTest.class.getResourceAsStream(resourcePath)) { - if (inputStream == null) { - throw new IllegalArgumentException("Resource not found: " + resourcePath); - } - return new String(inputStream.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8).trim(); - } - } - private final WKTReader wktReader = new WKTReader(); @Test @@ -543,7 +532,7 @@ public void splitHeterogeneousGeometryCollection() { } @Test - public void splitCircleInto2SemiCircles() throws ParseException, IOException { + public void splitCircleInto2SemiCircles() throws ParseException { String polygonWkt = "POLYGON ((-117.76405581088967 34.111876749328026, -117.76407506132291 34.11170068822483, " + "-117.76413523652074 34.111531133837936, -117.76423402376724 34.11137460199335, -117.76436762657538 34.11123710803779, "