fix(boolean-within): require an interior point in MultiPoint-in-Polygon check#3085
Open
greymoth-jp wants to merge 2 commits into
Open
fix(boolean-within): require an interior point in MultiPoint-in-Polygon check#3085greymoth-jp wants to merge 2 commits into
greymoth-jp wants to merge 2 commits into
Conversation
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.
booleanWithin(multiPoint, polygon)gives the wrong answer when a MultiPoint has an interior point followed by a boundary point.isMultiPointInPolyshould return true when every point is inside the polygon (boundary allowed) and at least one point is strictly interior. ButoneInsidewas declared and never assigned, so theif (!oneInside)branch ran on every iteration and overwroteisInsidewith the strict-interior result of the current point. The finalreturn output && isInsidethen depended only on whether the last point was interior, not whether any point was.Reversing the points to
[[1, 1], [0.5, 0.5]]returns true on master, so the result is also order-dependent.This is the mirror of
booleanContains, whose equivalent helper was fixed for this case in #3024 (booleanContains(a, b)is documented as equivalent tobooleanWithin(b, a)). The fix here latchesoneInsideonce a strictly-interior point is found, matching that change.Added a
truefixture covering the interior-then-boundary case (test/true/MultiPoint/Polygon/MultiPointOneOnBoundaryOneInterior.geojson). It fails before the change and passes after; the existing fixtures are unchanged. Not a breaking change.The open draft #3011 de-duplicates the contains/within helpers and would cover this too. Happy to close in favour of that if you'd rather fold it in, but since the bug is in a released version this seemed worth fixing on its own.