Skip to content

@turf/boolean-contains: allow boundary points in MultiPoint containment checks#3024

Merged
mfedderly merged 2 commits into
Turfjs:masterfrom
rexxars:fix/multipoint-polygon-boundary
Jun 22, 2026
Merged

@turf/boolean-contains: allow boundary points in MultiPoint containment checks#3024
mfedderly merged 2 commits into
Turfjs:masterfrom
rexxars:fix/multipoint-polygon-boundary

Conversation

@rexxars

@rexxars rexxars commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

(Lifted from #3010)

Fixes behavior of booleanContains to return true if every point in a MultiPoint is inside/on boundary of some polygon, and at least one is strictly interior. This previously returned false, but differs from booleanWithin and doesn't match DE-9IM semantics. In my eyes this is a bugfix, not a breaking change - but will leave it to the maintainers to decide how to classify it.

An example:

Given the following square polygon:

{
  "type": "Polygon",
  "coordinates": [
    [
      [0, 0],
      [1, 0],
      [1, 1],
      [0, 1],
      [0, 0]
    ]
  ]
}

And the following MultiPoint:

{
  "type": "MultiPoint",
  "coordinates": [
    [0.5, 0.5],
    [1, 1]
  ]
}
Image

In this case, one point is strictly on the interior of the polygon, while one point is on the boundary. This previously returned false, but the way I (and DE-9IM) see it should return true.

Resolves #3025

@mfedderly

Copy link
Copy Markdown
Collaborator

This seems like a pretty reasonable change, and I'm kind of torn on whether correcting behavior to match the spec is a breaking fix or not (I went back and forth on #3070 with the same debate). I think semantically they're bug fixes so 7.x is appropriate, but adding them to the v8 milestone and explicitly documenting the behavior change is probably a safer rollout strategy. Its always hard to tell on these calls until we hear back from users after a release that we broke things for them.

Thoughts?

@mfedderly mfedderly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mfedderly mfedderly added this to the v7.4 milestone Jun 21, 2026
@mfedderly
mfedderly merged commit 4382b3b into Turfjs:master Jun 22, 2026
5 checks passed
@mfedderly

Copy link
Copy Markdown
Collaborator

I have convinced myself that this is a bug that doesn't need a major version bump to correct. The docs and de-9im all suggest that this is a correction of buggy behavior and people should not have been depending on the broken state.

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.

booleanContains does not align with DE9-IM behaviour for Polygons containing MultiPoints

2 participants