From 7d8455ce42677411c3d4ee950928506eb65745e1 Mon Sep 17 00:00:00 2001 From: Martin Davis Date: Sun, 29 Oct 2023 08:26:44 -0700 Subject: [PATCH] Fix InteriorPointPoint to handle empty elements (#977) --- src/algorithm/InteriorPointPoint.cpp | 3 +++ tests/xmltester/tests/general/TestInteriorPoint.xml | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/algorithm/InteriorPointPoint.cpp b/src/algorithm/InteriorPointPoint.cpp index 6fb48f3978..9070aa670b 100644 --- a/src/algorithm/InteriorPointPoint.cpp +++ b/src/algorithm/InteriorPointPoint.cpp @@ -47,6 +47,9 @@ InteriorPointPoint::InteriorPointPoint(const Geometry* g) void InteriorPointPoint::add(const Geometry* geom) { + if (geom->isEmpty()) + return; + const Point* po = dynamic_cast(geom); if (po) { add(po->getCoordinate()); diff --git a/tests/xmltester/tests/general/TestInteriorPoint.xml b/tests/xmltester/tests/general/TestInteriorPoint.xml index 0d765cacab..23b4a87050 100644 --- a/tests/xmltester/tests/general/TestInteriorPoint.xml +++ b/tests/xmltester/tests/general/TestInteriorPoint.xml @@ -14,12 +14,19 @@ - P - single point + P - multipoint MULTIPOINT ((60 300), (200 200), (240 240), (200 300), (40 140), (80 240), (140 240), (100 160), (140 200), (60 200)) POINT (140 240) + + P - multipoint with EMPTY + MULTIPOINT((0 0), EMPTY) + + POINT (0 0) + + L - linestring with single segment LINESTRING (0 0, 7 14)