Skip to content

Commit c76e6e9

Browse files
authored
boolean-within check if line ends outside of poly (#2599)
1 parent e0bdd0a commit c76e6e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/turf-boolean-within/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
173173
}
174174
var foundInsidePoint = false;
175175

176-
for (var i = 0; i < linestring.coordinates.length - 1; i++) {
176+
for (var i = 0; i < linestring.coordinates.length; i++) {
177177
if (!booleanPointInPolygon(linestring.coordinates[i], polygon)) {
178178
return false;
179179
}
@@ -184,7 +184,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
184184
{ ignoreBoundary: true }
185185
);
186186
}
187-
if (!foundInsidePoint) {
187+
if (!foundInsidePoint && i < linestring.coordinates.length - 1) {
188188
var midpoint = getMidpoint(
189189
linestring.coordinates[i],
190190
linestring.coordinates[i + 1]

0 commit comments

Comments
 (0)