Skip to content

Commit

Permalink
boolean-within check if line ends outside of poly (#2599)
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlav authored Apr 23, 2024
1 parent e0bdd0a commit c76e6e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/turf-boolean-within/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
}
var foundInsidePoint = false;

for (var i = 0; i < linestring.coordinates.length - 1; i++) {
for (var i = 0; i < linestring.coordinates.length; i++) {
if (!booleanPointInPolygon(linestring.coordinates[i], polygon)) {
return false;
}
Expand All @@ -184,7 +184,7 @@ function isLineInPoly(linestring: LineString, polygon: Polygon) {
{ ignoreBoundary: true }
);
}
if (!foundInsidePoint) {
if (!foundInsidePoint && i < linestring.coordinates.length - 1) {
var midpoint = getMidpoint(
linestring.coordinates[i],
linestring.coordinates[i + 1]
Expand Down

0 comments on commit c76e6e9

Please sign in to comment.