Skip to content

SpatialRuleLookup issue with Polygons with holes #1680

Closed

Description

@boldtrn

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

  1. karussell commented on Jun 16, 2020

    @karussell
    Member

    Was fixed with #1680.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions