Turfjs / turf

A modular geospatial engine written in JavaScript and TypeScript

Home Page:https://turfjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

yahabibib opened this issue · comments

  • 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);

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.