Skip to content

Align multilinestring boundary expectations with GEOS - #31

Merged
tidwall merged 20 commits into
tidwall:mainfrom
paleolimbot:multiline-boundary-mod2
Oct 2, 2026
Merged

tidwall merged 20 commits into
tidwall:mainfrom
paleolimbot:multiline-boundary-mod2

Conversation

@paleolimbot

Copy link
Copy Markdown
Contributor

Please do not open a pull request without first filing an issue and/or discussing the feature directly with me.

Please ensure you adhere to every item in this list

  • This PR was pre-approved by the project maintainer (nope, just separated from another change that was unrelated)
  • I have self-reviewed the code
  • I have added all necessary tests

Describe your changes

The boundary of a multilinestring doesn't include endpoints that appear an even number of times, which affects touches and contains predicates.

This change separates the pathway for a multilinestring touching a point, a line, or another multilinestring, as well as a multilinestring containing a point. As far as I can tell these are the affected pairs.

The initial approach here visits all endpoints and counts for an odd number of intersections if an intersection point is found. Codex did the implementation.

This approach is slow once you get to very large linestrings, and there are some adversarial examples (two huge linestrings that actually do intersect at all of their endpoints) where this scales badly. We could just compute the boundary (deduplicate the endpoints once) and check for an intersection. Happy to try that as well.

No opinions on whether this is a useful property of a boundary...I just work here.

Issue number and link

Closes #30.

@tidwall

tidwall commented Sep 25, 2026

Copy link
Copy Markdown
Owner

This will take me some time to review.
Are you generating the jsonc results using the tests/relate.sh tool?

@paleolimbot

Copy link
Copy Markdown
Contributor Author

This will take me some time to review.

No problem! I really am not quite sure of the approach here...computing a multilinestring boundary eagerly seems like it may scale better, but the index-aware search seems like it constrains that in most cases.

Are you generating the jsonc results using the tests/relate.sh tool?

Strictly speaking I told codex to use relate.c, but I can double check. I did plot them manually.

@tidwall
tidwall merged commit 78a0ce3 into tidwall:main Oct 2, 2026
2 checks passed
@tidwall

tidwall commented Oct 2, 2026

Copy link
Copy Markdown
Owner

This PR appears correct.
I notice a couple uncovered lines and minor cleanup, but I'll address these in main after #33.
Thanks!

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.

Mod 2 boundary rule for multilinestring boundaries is not considered

2 participants