Skip to content
New issue

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

Errors that occur when judging between points and polygon for data with inner rings #2577

Open
yahabibib opened this issue Feb 4, 2024 · 1 comment

Comments

@yahabibib
Copy link

  • Version:7.0.0-alpha.1
  • Data:https://gist.github.com/yahabibib/3199e54fd8a5bdeac22a30715bfaa483
  • Description: This test data is "polygon" type data with holes (i.e. there is an inner ring). If you use the "booleanPointInPolygon" function to determine whether a point is within the data area, it will appear that when the point is in the inner ring, it will still return true, actually want to return false.
  • Code
  • var polygon = turf.polygon(([data.geometries[0].coordinates[0]])); // Load uploaded test data
    var point = turf.point([119, 10]);
    let bool = turf.booleanPointInPolygon(point, polygon);
@smallsaucepan
Copy link
Member

Hi @yahabibib. I think Turf's booleanPointWithinPolygon has some bugs. Found a comment on a similar issue, that includes a library that might give you a correct result. Not ideal, however should let you proceed until we can fix our implementation.

#1755 (comment)

Let us know if that helps! Btw, even if the other library fixes your problem, please leave this issue open until Turf's implementation is fixed. We can use your test data to validate any PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants