Skip to content

Commit

Permalink
Fix predicates for MultiPoint with EMPTY
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Nov 8, 2023
1 parent 89309b2 commit af4eae4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ else if (geom instanceof Polygon) {

private void computeLocation(Coordinate p, Geometry geom)
{
if (geom.isEmpty())
return;

if (geom instanceof Point) {
updateLocationInfo(locateOnPoint(p, (Point) geom));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ private void addCollection(GeometryCollection gc)
{
for (int i = 0; i < gc.getNumGeometries(); i++) {
Geometry g = gc.getGeometryN(i);
add(g);
if (! g.isEmpty()) {
add(g);
}
}
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public void testIntersectsSnappedEndpoint2()
runRelateTest(a, b, "FF10F0102" );
}

public void testMultiPointWithEmpty()
{
String a = "MULTIPOINT(EMPTY,(0 0))";
String b = "POLYGON ((1 0,0 1,-1 0,0 -1, 1 0))";
runRelateTest(a, b, "0FFFFF212" );
}

void runRelateTest(String wkt1, String wkt2, String expectedIM)
{
Expand Down
25 changes: 25 additions & 0 deletions modules/tests/src/test/resources/testxml/general/TestRelatePA.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,29 @@
</test>
</case>

<case>
<desc>mPA - empty Point element</desc>
<a>
MULTIPOINT(EMPTY,(0 0))
</a>
<b>
POLYGON ((1 0,0 1,-1 0,0 -1, 1 0))
</b>
<test>
<op name="relate" arg3="0FFFFF212" arg1="A" arg2="B">
true
</op>
</test>
<test><op name="contains" arg1="A" arg2="B"> false </op></test>
<test><op name="coveredBy" arg1="A" arg2="B"> true </op></test>
<test><op name="covers" arg1="A" arg2="B"> false </op></test>
<test><op name="crosses" arg1="A" arg2="B"> false </op></test>
<test><op name="disjoint" arg1="A" arg2="B"> false </op></test>
<test><op name="equalsTopo" arg1="A" arg2="B"> false </op></test>
<test><op name="intersects" arg1="A" arg2="B"> true </op></test>
<test><op name="overlaps" arg1="A" arg2="B"> false </op></test>
<test><op name="touches" arg1="A" arg2="B"> false </op></test>
<test><op name="within" arg1="A" arg2="B"> true </op></test>
</case>

</run>

0 comments on commit af4eae4

Please sign in to comment.