Skip to content

OverlayEdge: Don't skip first point when adding coordinates#1187

Merged
dr-jts merged 1 commit into
locationtech:masterfrom
dbaston:overlayedge-addcoords-fix
Jul 1, 2026
Merged

OverlayEdge: Don't skip first point when adding coordinates#1187
dr-jts merged 1 commit into
locationtech:masterfrom
dbaston:overlayedge-addcoords-fix

Conversation

@dbaston

@dbaston dbaston commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

The isFirstEdge logic in OverlayEdge::addCoordinates appears to be backwards. It works out OK because it is only used to construct rings, and the dropped point ends up being added later on, with the ring being "rotated" by one vertex.

However, problems arise when extending this function to handle coordinates from CircularString because dropping the first point of the first arc causes a control point to be interpreted as an endpoint.

Fixes #865

@dr-jts

dr-jts commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Nice. This fixes #865.

It would be good to add a unit test in OverlayNGTest:

  /**
   * Tests that overlay produces stable (non-rotated) results.
   * See https://github.com/locationtech/jts/issues/865
   */
  public void testRingsNonRotated() {
    Geometry a = read("POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9))");
    Geometry actual = intersection(a, a);
    checkEqualExact(a, actual);
  }

Signed-off-by: Dan Baston <dbaston@gmail.com>
@dbaston dbaston force-pushed the overlayedge-addcoords-fix branch from c13c193 to 26d124a Compare July 1, 2026 20:25
@dr-jts dr-jts merged commit 52c5d98 into locationtech:master Jul 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OverlayNG intersection of same Polygon rotates vertices

2 participants