Skip to content

Commit

Permalink
Fix InteriorPointPoint to handle empty elements (#977)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Oct 29, 2023
1 parent 0dc1901 commit 7d8455c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/algorithm/InteriorPointPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
9 changes: 8 additions & 1 deletion tests/xmltester/tests/general/TestInteriorPoint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7d8455c

Please sign in to comment.