From b376f0f4d81503574803e55aa7856759af7c44d7 Mon Sep 17 00:00:00 2001
From: Martin Davis <mtnclimb@gmail.com>
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 6e52fb5b1a..2fc90e0c57 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<const Point*>(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 @@
 </case>
 
 <case>
-  <desc>P - single point</desc>
+  <desc>P - multipoint</desc>
   <a>    MULTIPOINT ((60 300), (200 200), (240 240), (200 300), (40 140), (80 240), (140 240), (100 160), (140 200), (60 200))
 	</a>
 <test><op name="getInteriorPoint" arg1="A" >    POINT (140 240)   </op></test>
 </case>
 
+<case>
+  <desc>P - multipoint with EMPTY</desc>
+  <a>    MULTIPOINT((0 0), EMPTY)
+	</a>
+<test><op name="getInteriorPoint" arg1="A" >    POINT (0 0)   </op></test>
+</case>
+
 <case>
   <desc>L - linestring with single segment</desc>
   <a>    LINESTRING (0 0, 7 14)