point-in-polygon-hao icon indicating copy to clipboard operation
point-in-polygon-hao copied to clipboard

incorrect response for inside function

Open Madanian opened this issue 4 months ago • 1 comments

      const coordinate = [
                  [51.65906944711844, 32.644344469605144],
                  [51.643474062027934, 32.64597280574026],
                  [51.6602114368668, 32.658994206590506],
                  [51.64382208072604, 32.65965256535195],
                  [51.65906944711844, 32.644344469605144],
                ];

      const point = [51.6476999685446, 32.65383784687809]

      const hao = inside(point, coordinate)
      console.log(`hao gives: ${hao}`) 

for this code, the function should returns true but it returns false! it means the response is incorrect. samely I have this bug when I use turf.booleanPointInPolygon do you have any suggestion for me? it is very important for me

Madanian avatar Feb 18 '24 10:02 Madanian

Hi @Madanian

So it looks like the polygon you've provided contains self-intersections. geojson io | powered by Mapbox 2024-02-19 19-46-55

In theory this algorithm is supposed to work with those sorts of polygons but it doesn't appear to be working in this case - not sure why sorry.

Regards, Rowan

rowanwins avatar Feb 19 '24 08:02 rowanwins