From bf71d665ee7ea2f019d97f5653b26f5787474325 Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Mon, 29 Jul 2024 15:52:29 -0700 Subject: [PATCH] Fix RelateNG handling of empty point elements --- .../operation/relateng/RelateGeometry.java | 2 ++ .../operation/relateng/RelateNGGCTest.java | 6 ++++++ .../resources/testxml/misc/TestRelateGC.xml | 21 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelateGeometry.java b/modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelateGeometry.java index 9f5ac3cd03..7bc7bf8503 100644 --- a/modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelateGeometry.java +++ b/modules/core/src/main/java/org/locationtech/jts/operation/relateng/RelateGeometry.java @@ -295,6 +295,8 @@ public List getEffectivePoints() { //-- only return Points not covered by another element List ptList = new ArrayList(); for (Point p : ptListAll) { + if (p.isEmpty()) + continue; int locDim = locateWithDim(p.getCoordinate()); if (DimensionLocation.dimension(locDim) == Dimension.P) { ptList.add(p); diff --git a/modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGGCTest.java b/modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGGCTest.java index 140708bf91..b63193f174 100644 --- a/modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGGCTest.java +++ b/modules/core/src/test/java/org/locationtech/jts/operation/relateng/RelateNGGCTest.java @@ -208,5 +208,11 @@ public void testAdjPolygonsContainingLineAndPoint() { checkCoversCoveredBy(a, b, true); } + public void testEmptyMultiPointElements() { + String a = "POLYGON ((3 7, 7 7, 7 3, 3 3, 3 7))"; + String b = "GEOMETRYCOLLECTION (MULTIPOINT (EMPTY, (5 5)), LINESTRING (1 9, 4 9))"; + checkIntersectsDisjoint(a, b, true); + } + } diff --git a/modules/tests/src/test/resources/testxml/misc/TestRelateGC.xml b/modules/tests/src/test/resources/testxml/misc/TestRelateGC.xml index 8eec76e4bc..3b23304a93 100644 --- a/modules/tests/src/test/resources/testxml/misc/TestRelateGC.xml +++ b/modules/tests/src/test/resources/testxml/misc/TestRelateGC.xml @@ -42,6 +42,27 @@ false + + A/GC:mP with empty MultiPoint elements + + POLYGON ((3 7, 7 7, 7 3, 3 3, 3 7)) + + + GEOMETRYCOLLECTION (MULTIPOINT (EMPTY, (5 5)), LINESTRING (1 9, 4 9)) + + true + false + false + false + true + false + false + true + false + false + false + + mA/GC:PL