fix(boolean-touches): check all LineString vertices against a MultiLineString#3088
Open
spokodev wants to merge 1 commit into
Open
fix(boolean-touches): check all LineString vertices against a MultiLineString#3088spokodev wants to merge 1 commit into
spokodev wants to merge 1 commit into
Conversation
…String In the LineString vs MultiLineString branch, the interior-intersection guard looped `ii < geom1.coordinates[i].length` where `i` indexes the MultiLineString's members, so the bound was always 2 (the length of a coordinate pair) and only the first two vertices of the LineString were ever tested against each member's interior. A LineString whose interior vertex (index >= 2) lies on the interior of a MultiLineString member — while an endpoint touches a member endpoint — was therefore reported as touching, even though the interiors intersect (DE-9IM touches requires disjoint interiors). Iterate over all of `geom1.coordinates`, matching the LineString vs LineString branch. Added a false fixture that fails before and passes after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
booleanTouches(LineString, MultiLineString)returnstruefor some pairs whose interiors actually intersect, violating the DE-9IM rule thattouchesrequires disjoint interiors.In
packages/turf-boolean-touches/index.ts, the interior-intersection guard loopsii < geom1.coordinates[i].length, whereiindexes the MultiLineString's members. Butgeom1is the LineString, sogeom1.coordinates[i]is a single[lon, lat]pair whose.lengthis always2. Only the first two LineString vertices are ever checked against each member's interior, so a LineString whose interior vertex (index >= 2) passes through a member's interior, while an endpoint touches a member endpoint, is wrongly reported as touching.Fix
Loop over the LineString's own vertices, matching the LineString to LineString branch:
Two-vertex lines are unaffected, so existing fixtures stay green.
Test
Added a
falsefixture where a LineString interior vertex crosses a MultiLineString member. It fails before the change (not ok ... LineStringInteriorVertexCrossesMultiLineString) and passes after; the package suite stays green (91/91).