diff --git a/modules/core/src/main/java/org/locationtech/jts/operation/distance/DistanceOp.java b/modules/core/src/main/java/org/locationtech/jts/operation/distance/DistanceOp.java
index 34542df972..cca020c846 100644
--- a/modules/core/src/main/java/org/locationtech/jts/operation/distance/DistanceOp.java
+++ b/modules/core/src/main/java/org/locationtech/jts/operation/distance/DistanceOp.java
@@ -348,8 +348,12 @@ private void computeMinDistancePoints(List points0, List points1, GeometryLocati
{
for (int i = 0; i < points0.size(); i++) {
Point pt0 = (Point) points0.get(i);
+ if (pt0.isEmpty())
+ continue;
for (int j = 0; j < points1.size(); j++) {
Point pt1 = (Point) points1.get(j);
+ if (pt1.isEmpty())
+ continue;
double dist = pt0.getCoordinate().distance(pt1.getCoordinate());
if (dist < minDistance) {
minDistance = dist;
@@ -368,6 +372,8 @@ private void computeMinDistanceLinesPoints(List lines, List points,
LineString line = (LineString) lines.get(i);
for (int j = 0; j < points.size(); j++) {
Point pt = (Point) points.get(j);
+ if (pt.isEmpty())
+ continue;
computeMinDistance(line, pt, locGeom);
if (minDistance <= terminateDistance) return;
}
diff --git a/modules/tests/src/test/resources/testxml/general/TestDistance.xml b/modules/tests/src/test/resources/testxml/general/TestDistance.xml
index 4ce6d0fede..3835c919da 100644
--- a/modules/tests/src/test/resources/testxml/general/TestDistance.xml
+++ b/modules/tests/src/test/resources/testxml/general/TestDistance.xml
@@ -6,6 +6,7 @@
POINT(10 10)
POINT EMPTY
0.0
+ 0.0
@@ -13,6 +14,31 @@
POINT(10 10)
POINT (10 0)
10.0
+ 10.0
+
+
+
+ PP - point to multipoint
+ POINT(10 10)
+ MULTIPOINT ((10 0), (30 30))
+ 10.0
+ 10.0
+
+
+
+ PP - point to multipoint with empty element
+ POINT(10 10)
+ MULTIPOINT ((10 0), EMPTY)
+ 10.0
+ 10.0
+
+
+
+ LL - line to empty line
+ LINESTRING (0 0, 0 10)
+ LINESTRING EMPTY
+ 0.0
+ 0.0
@@ -20,6 +46,31 @@
LINESTRING (0 0, 0 10)
LINESTRING (10 0, 10 10)
10.0
+ 10.0
+
+
+
+ LL - line to multiline
+ LINESTRING (0 0, 0 10)
+ MULTILINESTRING ((10 0, 10 10), (50 50, 60 60))
+ 10.0
+ 10.0
+
+
+
+ LL - line to multiline with empty element
+ LINESTRING (0 0, 0 10)
+ MULTILINESTRING ((10 0, 10 10), EMPTY)
+ 10.0
+ 10.0
+
+
+
+ PA - point to empty polygon
+ POINT (240 160)
+ POLYGON EMPTY
+ 0.0
+ 0.0
@@ -27,6 +78,7 @@
POINT (240 160)
POLYGON ((100 260, 340 180, 100 60, 180 160, 100 260))
0.0
+ 0.0
@@ -34,6 +86,7 @@
LINESTRING (40 300, 280 220, 60 160, 140 60)
LINESTRING (140 360, 260 280, 240 120, 120 160)
0.0
+ 0.0
@@ -41,6 +94,7 @@
POLYGON ((60 260, 260 180, 100 60, 60 160, 60 260))
POLYGON ((220 280, 120 160, 300 60, 360 220, 220 280))
0.0
+ 0.0
@@ -48,6 +102,7 @@
POLYGON ((100 320, 60 120, 240 180, 200 260, 100 320))
POLYGON ((420 320, 280 260, 400 100, 420 320))
71.55417527999327
+ 71.55417527999327
@@ -55,13 +110,23 @@
MULTIPOLYGON (((40 240, 160 320, 40 380, 40 240)), ((100 240, 240 60, 40 40, 100 240)))
MULTIPOLYGON (((220 280, 120 160, 300 60, 360 220, 220 280)), ((240 380, 280 300, 420 340, 240 380)))
0.0
+ 0.0
- mAmA - multipolygon with empty component
+ mAmA - multipolygon with empty element
MULTIPOLYGON (EMPTY, ((98 200, 200 200, 200 99, 98 99, 98 200)))
POLYGON ((300 200, 400 200, 400 100, 300 100, 300 200))
100.0
+ 100.0
+
+
+
+ GCGC - geometry collections with mixed dimensions
+ GEOMETRYCOLLECTION (LINESTRING (10 10, 50 10), POINT (90 10))
+ GEOMETRYCOLLECTION (POLYGON ((90 20, 60 20, 60 50, 90 50, 90 20)), LINESTRING (10 50, 30 70))
+ 10.0
+ 10.0