BooleanContains should return false when the Outer contains all the verticies of the Inner, but their borders intersect.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10.5k
- Forks
- 1k
- Avg merge
- 1h 11m
- Merged PRs (30d)
- 4
Description
Given two polygons, Outer and Inner, we are checking that booleanContains(outer, inner) should return the correct result.
Consider the case where Outer contains all of the verticies of Inner, but their boundaries intersect. booleanContains incorrectly returns false in such a scenario.
Here is a picture of an example case:

As well as a unit test showing the failing case.
import booleanContains from "@turf/boolean-contains"
describe('booleanContains', () => {
it('Contains should be false when borders intersect but all verticies are contained', () => {
// Outer: A 2 x 2 square with the top-right quadrant removed.
const outer = {
type: "Polygon",
coordinates: [[
[0, 0],
[0, 2],
[1, 2],
[1, 1],
[2, 1],
[2, 0],
[0, 0]
]]
};
// Inner: A triangle with all 3 verticies inside outer, but one segment intersecting the border of outer
const inner = {
type: "Polygon",
coordinates: [[
[.1, .1],
[.1, 1.9],
[1.9, .1],
[.1, .1]
]]
}
expect(booleanContains(outer, inner)).toBe(false) // Returns true
})
});
Result:
● booleanContains › Contains should be false when borders intersect but all verticies are contained
expect(received).toBe(expected) // Object.is equality
Expected: false
Received: true
89 | }
90 |
> 91 | expect(booleanContains(outer, inner)).toBe(false)
| ^
92 | })
93 | });
94 |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the booleanContains entry point and reproduce the supplied polygon case as a unit test. Compare the returned result with the expected false value, then run the booleanContains test suite and confirm the regression case passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100