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 bug in DistanceOp for geometries with empty components #524

Merged
merged 2 commits into from Mar 23, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -41,7 +41,10 @@
* <p>
* {@link Polygonal} and {@link LinearRing} geometries
* are supported.
*
* <p>
* The index is lazy-loaded, which allows
* creating instances even if they are not used.
* <p>
* Thread-safe and immutable.
*
* @author Martin Davis
Expand All @@ -66,8 +69,6 @@ public IndexedPointInAreaLocator(Geometry g)
if (! (g instanceof Polygonal || g instanceof LinearRing))
throw new IllegalArgumentException("Argument must be Polygonal or LinearRing");
geom = g;
// index = new IntervalIndexedGeometry(geom);

}

/**
Expand Down
Expand Up @@ -27,6 +27,7 @@
* (e.g. a polygon, linestring or point)
* and returns them in a list. The elements of the list are
* {@link org.locationtech.jts.operation.distance.GeometryLocation}s.
* Empty geometries do not provide a location item.
*
* @version 1.7
*/
Expand Down Expand Up @@ -56,6 +57,8 @@ public static List getLocations(Geometry geom)

public void filter(Geometry geom)
{
// empty geometries do not provide a location
if (geom.isEmpty()) return;
if (geom instanceof Point
|| geom instanceof LineString
|| geom instanceof Polygon )
Expand Down
Expand Up @@ -38,6 +38,8 @@
* the coordinate computed is a close
* approximation to the exact point.
* <p>
* Empty geometry collection components are ignored.
* <p>
* The algorithms used are straightforward O(n^2)
* comparisons. This worst-case performance could be improved on
* by using Voronoi techniques or spatial indexes.
Expand Down
Expand Up @@ -57,4 +57,11 @@
<test><op name="distance" arg1="A" arg2="B" > 0.0 </op></test>
</case>

<case>
<desc>mAmA - multipolygon with empty component</desc>
<a> MULTIPOLYGON (EMPTY, ((98 200, 200 200, 200 99, 98 99, 98 200))) </a>
<b> POLYGON ((300 200, 400 200, 400 100, 300 100, 300 200)) </b>
<test><op name="distance" arg1="A" arg2="B" > 100.0 </op></test>
</case>

</run>