Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix InteriorPoint for MultiLineString with EMPTY #1023

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public Coordinate getInteriorPoint()
*/
private void addInterior(Geometry geom)
{
if (geom.isEmpty())
return;

if (geom instanceof LineString) {
addInterior(geom.getCoordinates());
}
Expand All @@ -93,6 +96,9 @@ private void addInterior(Coordinate[] pts)
*/
private void addEndpoints(Geometry geom)
{
if (geom.isEmpty())
return;

if (geom instanceof LineString) {
addEndpoints(geom.getCoordinates());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void testPolygonZeroArea() {
checkInteriorPoint(read("POLYGON ((10 10, 10 10, 10 10, 10 10))"), new Coordinate(10, 10));
}

public void testMultiLineWithEmpty() {
checkInteriorPoint(read("MULTILINESTRING ((0 0, 1 1), EMPTY)"), new Coordinate(0, 0));
}

public void testAll() throws Exception
{
checkInteriorPointFile(TestFiles.getResourceFilePath("world.wkt"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<run>
<precisionModel scale="1.0" offsetx="0.0" offsety="0.0"/>

<case>
<desc>P - empty</desc>
Expand Down Expand Up @@ -38,7 +37,7 @@
<desc>L - linestring with single segment</desc>
<a> LINESTRING (0 0, 7 14)
</a>
<test><op name="getInteriorPoint" arg1="A" > POINT (7 14) </op></test>
<test><op name="getInteriorPoint" arg1="A" > POINT (0 0) </op></test>
</case>

<case>
Expand Down Expand Up @@ -68,6 +67,13 @@
<test><op name="getInteriorPoint" arg1="A" > POINT (180 200) </op></test>
</case>

<case>
<desc>mL - multilinestring with empty</desc>
<a> MULTILINESTRING ((0 0, 1 1), EMPTY)
</a>
<test><op name="getInteriorPoint" arg1="A" > POINT (0 0) </op></test>
</case>

<case>
<desc>A - box</desc>
<a> POLYGON ((0 0, 0 10, 10 10, 10 0, 0 0))
Expand All @@ -93,7 +99,7 @@
<desc>A - polygon with horizontal segment at centre (narrower L shape)</desc>
<a> POLYGON ((0 2, 0 4, 3 4, 3 0, 2 0, 2 2, 0 2))
</a>
<test><op name="getInteriorPoint" arg1="A" > POINT (2 3) </op></test>
<test><op name="getInteriorPoint" arg1="A" > POINT (1.5 3) </op></test>
</case>

<case>
Expand All @@ -103,6 +109,14 @@
<test><op name="getInteriorPoint" arg1="A" > POINT (115 200) </op></test>
</case>


<case>
<desc>mA - multipolygon with empty</desc>
<a> MULTIPOLYGON (((0 2, 0 4, 3 4, 3 0, 2 0, 2 2, 0 2)), EMPTY)
</a>
<test><op name="getInteriorPoint" arg1="A" > POINT (1.5 3) </op></test>
</case>

<case>
<desc>GC - collection of polygons, lines, points</desc>
<a> GEOMETRYCOLLECTION (POLYGON ((0 40, 40 40, 40 0, 0 0, 0 40)),
Expand Down
Loading