Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions packages/turf-boolean-within/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,21 @@ function isMultiPointOnLine(multiPoint: MultiPoint, lineString: LineString) {
}

function isMultiPointInPoly(multiPoint: MultiPoint, polygon: Polygon) {
var output = true;
var oneInside = false;
var isInside = false;
for (var i = 0; i < multiPoint.coordinates.length; i++) {
isInside = booleanPointInPolygon(multiPoint.coordinates[i], polygon);
if (!isInside) {
output = false;
break;
// All points must be inside polygon (boundary OK)
if (!booleanPointInPolygon(multiPoint.coordinates[i], polygon)) {
return false;
}
// Track if at least one point is strictly in the interior
if (!oneInside) {
isInside = booleanPointInPolygon(multiPoint.coordinates[i], polygon, {
oneInside = booleanPointInPolygon(multiPoint.coordinates[i], polygon, {
ignoreBoundary: true,
});
}
}
return output && isInside;
// At least one point must be in the interior (not just on boundary)
return oneInside;
}

function isLineOnLine(lineString1: LineString, lineString2: LineString) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPoint",
"coordinates": [
[0.5, 0.5],
[1, 1]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[0, 0],
[1, 0],
[1, 1],
[0, 1],
[0, 0]
]
]
}
}
]
}
Loading