We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using booleanContains cannot accurately determine the inclusion result of line segments and concave convex polygons.
version: 6.5.0
import { lineString, polygon, booleanContains } from '@turf/turf'; const turf_polygon = polygon([ [ [0, 0], [4, 0], [4, 1], [3, 1], [3, 2], [2, 2], [2, 1], [1, 1], [1, 3], [0, 3], [0, 0], ], ]); const turf_line = lineString([ [1, 2], [4, 0], ]); console.log(booleanContains(turf_polygon, turf_line));
The final result is true, and it is evident from the image that this line segment is not completely contained within the polygon.
I'm not sure if there's a problem with my usage. Is there any way to correctly determine the inclusion of line segments and polygons?
The text was updated successfully, but these errors were encountered:
I'm also having the same issue with a very similar case. Thanks in advance.
For the case geometry 1 is polygon, geometry 2 is line. Looking at the code, looks like the issue is in isLineInPoly method. To calculate if the line is contained in the polygon, it only checks if the mid point of that line is inside the polygon. https://github.com/Turfjs/turf/blob/88dfdbb2617b70c833e30923590400dc0189e601/packages/turf-boolean-contains/index.ts#L196C27-L196C27 In the above case, the mid point of the red line is inside the polygon.
Sorry, something went wrong.
Hey! added a PR to fix this. #2848
No branches or pull requests
Using booleanContains cannot accurately determine the inclusion result of line segments and concave convex polygons.
version: 6.5.0
The final result is true, and it is evident from the image that this line segment is not completely contained within the polygon.
I'm not sure if there's a problem with my usage. Is there any way to correctly determine the inclusion of line segments and polygons?
The text was updated successfully, but these errors were encountered: