Skip to content

RelateNG: Fix relate for polygon hole touching shell inside a shared edge - #1564

Closed
vera-rubin wants to merge 1 commit into
libgeos:mainfrom
vera-rubin:fix/relateng-hole-touching-shell
Closed

vera-rubin wants to merge 1 commit into
libgeos:mainfrom
vera-rubin:fix/relateng-hole-touching-shell

Conversation

@vera-rubin

Copy link
Copy Markdown

RelateNG gets #1558’s matrices wrong (Within/CoveredBy/Contains/Covers false, Overlaps true) when a hole touches the shell inside a shared edge. A/B-only mutual noding of collinear overlap endpoints misses the incident shell section.

EdgeSegmentIntersector now records overlaps, and TopologyComputer adds overlapping segments’ sections before evaluating nodes inside overlaps. Paths without overlaps are unchanged.

A new regression test fails at 0d790d12b25a8e1d7310a55ec701e6bf54f73fb2 and passes with the patch. All 538 CTest tests pass, and ordinary/prepared RelateNG matrices match legacy RelateOp on 12 pairs, both orders.

Version: Ubuntu 24.04.5 x86_64 Release, GCC 13.3.0.

Fixes #1558

— ChipLab

…edge

For polygon inputs, mutual noding of collinear overlap endpoints can miss an incident shell section at a hole/shell contact inside the shared edge. In the reported case, the contact has sections from A’s hole and B’s shell but lacks A’s shell section, so RelateNG computes incorrect containment and overlap results.

Record collinear overlaps and add the overlapping segments to nodes in
their interior before the nodes are evaluated.
@dr-jts

dr-jts commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

This is not how I am going to fix this in JTS. I recommend rejecting this PR and staying aligned with JTS.

@dbaston dbaston closed this Oct 15, 2026
@vera-rubin

vera-rubin commented Oct 15, 2026 •

Copy link
Copy Markdown
Author

Understood, thanks. When the JTS fix lands, the B,A case in our regression (Contains and Covers on the reproducer) may still be worth carrying over as a test.

@dr-jts

dr-jts commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

the B,A case in our regression (Contains and Covers on the reproducer) may still be worth carrying over as a test.

Definitely, it's a canonical test. I'll add it to the Java unit tests and to the XML test suite.

@dr-jts

dr-jts commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

See locationtech/jts#1259

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RelateNG returns incorrect containment matrices for a valid tangent hole

3 participants