We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0bdd0a commit c76e6e9Copy full SHA for c76e6e9
packages/turf-boolean-within/index.ts
@@ -173,7 +173,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
173
}
174
var foundInsidePoint = false;
175
176
- for (var i = 0; i < linestring.coordinates.length - 1; i++) {
+ for (var i = 0; i < linestring.coordinates.length; i++) {
177
if (!booleanPointInPolygon(linestring.coordinates[i], polygon)) {
178
return false;
179
@@ -184,7 +184,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
184
{ ignoreBoundary: true }
185
);
186
187
- if (!foundInsidePoint) {
+ if (!foundInsidePoint && i < linestring.coordinates.length - 1) {
188
var midpoint = getMidpoint(
189
linestring.coordinates[i],
190
linestring.coordinates[i + 1]
0 commit comments