You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SpatialRuleLookup issue with Polygons with holes #1680
When creating Polygons from geojson in the SpatialRuleLookupBuilder, we call the method Polygon#create(org.locationtech.jts.geom.Polygon polygon).
The create method uses the method org.locationtech.jts.geom.Polygon#getNumPoints, which returns all points of the Polygon, including the points for the holes. Therefore, the holes and the connection to the whole become part of the Polygon, which can lead false positive contain results, even for points outside of the polygon.
A quick-fix could be to only use the shell:
Coordinate[] shell = polygon.getExteriorRing().getCoordinates();
double[] lats = new double[shell.length];
double[] lons = new double[shell.length];
for(int i = 0; i < shell.length; ++i) {
lats[i] = polygon.getCoordinates()[i].y;
lons[i] = polygon.getCoordinates()[i].x;
}
return new Polygon(lats, lons);
The proper solution would be to correctly read holes as holes and use them in the contains lookup.
Activity
karussell commentedon Jun 16, 2020
Was fixed with #1680.