Skip to content

Intersection of mixed-dimension polygons creates inconsistent CoordinateArraySequence #375

Description

@jodygarnett

Follow on to #374 we have found GeoTools test cases producing inconsistent coordinate sequence through a sequence of JTS calls ending in an intersection call.

This is an interesting case using intersection() between mixed dimensions:

  • g1 Polygon using CoordinateXY (footprint polygon from WKB)
  • g2 Polygon using Coordinate (taken from mosaic bounds).

We suspect one of the internal JTS methods in the overlay process path is calling new Coordinate() rather than relying on CoordinateSequence.createCoordinate().

The net effect is closing a LinearRing with a Coordinate when all the other coordinates are CoordinateXY. This produces a CoordinateArraySequence with inconsistent Coordinates, which will start failing when the CoordinateArraySequence constructor is tightened up to check this as in #374.

    private boolean polygonOverlap(Geometry g1, Geometry g2) {
        // TODO: try to use relate instead
        Geometry intersection = g1.intersection(g2);
        return intersection != null && intersection.getDimension() == 2;
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions