Open
Description
Description:
The turf.booleanPointInPolygon
function consistently returns incorrect results when checking if a specific point is within a polygon. Even though the provided point clearly lies within the boundaries defined by the polygon coordinates, the function incorrectly returns false
.
Steps to reproduce:
- Create a point:
let ship = turf.point([48.085345, -24.812173333333334]);
- Define the polygon using provided coordinates (polygon definition attached below).
let polygon=turf.polygon([[[103.80597708106134,1.1706523988804578],[103.79735625227198,1.1849031566750978],[103.73431605555935,1.1467677290341145],[103.66230286904077,1.1933799006715895],[103.65957951738504,1.1945193520412456],[103.41183202819165,1.2494210784883315],[102.86073688589278,1.6508976301178329],[102.85967331136771,1.6515562042286291],[102.28790037095075,1.948678387240059],[101.92579991287272,2.238746619533638],[101.78497843376864,2.375964399369304],[101.78414958131034,2.3766724252216096],[101.45942735908812,2.6191724252216093],[101.45807024283582,2.6199969515610926],[101.00099089391539,2.8410571457662424],[100.72031259116558,3.11979782709667],[100.72011412681937,3.119988511701125],[99.37233634904159,4.372766289478903],[99.37119346379349,4.373656573994859],[97.62119346379349,5.506989907328193],[97.6184235598357,5.508140271683228],[95.30175689316904,6.008140271683228],[95.2983668023733,6.008165988133492],[94.7983668023733,5.908165988133493],[94.79545956817871,5.906981058341],[54.512126234845375,-20.293018941659],[54.51190494516234,-20.29316796479814],[45.71276842146294,-26.42589948131591],[32.49708781047488,-31.358864753513217],[32.496676222121856,-31.3590310136297],[25.995926325959392,-34.1887888079647],[24.834015219305527,-34.30559028263072],[21.87775260136567,-34.512248122313814],[21.876587381395996,-34.51241293014868],[20.266309603618218,-34.85769070792646],[20.26549308629953,-34.85790966953456],[19.90481445947216,-34.97455115206359],[18.37168785575706,-34.44292697306179],[-17.62513396525563,11.003060575966728],[-17.791672293431912,14.733519127115668],[-17.791672293431912,20.804849042862244],[-17.242309766691868,23.096356673340036],[-10.472243314762572,32.00980539108238],[-5.976391845438432,35.850462994307655],[-5.567343988265914,35.91343592572922],[-5.566502578736536,35.91361031588548],[-5.312480861191057,35.980093644359755],[-2.149313607754742,36.24170062879672],[-2.148230948255647,36.241862361975976],[2.8344392040968023,37.32505152553086],[8.645264514449426,37.62416058538125],[10.047323228243618,37.54751804131169],[10.047885146158213,37.5475063189395],[10.240858503573637,37.54999451409242],[11.156290818295487,37.35858593919603],[14.630959709222834,36.32535106515529],[14.631552378541489,36.32519829204803],[33.55238112532039,32.18297707393209],[33.81432125441398,32.12532252699932],[34.44712106721267,31.89218575386296],[34.44855961470708,31.891797805970832],[34.61939294804041,31.861797805970834],[34.62227371862625,31.878202194029168],[34.45217708118458,31.908072823043312],[33.819545599454,32.14114757947037],[33.818456793442394,32.141466361232645],[33.55595679344239,32.199244139010425],[33.555947621458515,32.19924615239642],[14.63541343168796,36.34140288494958],[11.160706957443832,37.374648934844714],[11.160037722513453,37.37481809318028],[10.243371055846787,37.566484759846944],[10.241559298286232,37.566660347727165],[10.047951566254165,37.564163972958845],[8.645732327311938,37.64081529202164],[8.644849680401903,37.640816695817506],[2.8329052359574574,37.34165002915084],[2.8315642815889808,37.34147097135736],[-2.1512330484493214,36.25825416047947],[-5.314575281134148,35.99663270453661],[-5.315997421263464,35.99638968411452],[-5.570303443317068,35.92983194660867],[-5.981267122845198,35.866564074270784],[-5.985409094924492,35.864665188415536],[-10.483742428257825,32.02188741063776],[-10.48496502727019,32.02059255190378],[-17.256631693936857,23.10503699634823],[-17.258098236499006,23.101941458804703],[-17.808098236499006,20.807774792138034],[-17.80832770656809,20.805833333333332],[-17.80832770656809,14.733333333333333],[-17.808319420455742,14.732961930634415],[-17.641652753789074,10.999628597301083],[-17.639861326079064,10.994829312676648],[18.360138673920936,-34.45517068732335],[18.36393834015604,-34.4578680957757],[19.901993895711595,-34.99120142910903],[19.90728469147825,-34.99125699713211],[20.270215330160887,-34.87388722636548],[21.879502512267454,-34.52882185335211],[24.835302954189885,-34.32219632213063],[24.835555169482138,-34.32217483455287],[25.998888502815472,-34.205230390108426],[26.001379333433697,-34.20458009748142],[32.50312020007196,-31.37439093653908],[45.71957885619179,-26.441135246486784],[45.72142838817099,-26.440165368535194],[54.52131893702589,-20.306908319333296],[94.80320052891958,5.892147478125083],[95.29993547898854,5.9914944681388755],[97.61341952207786,5.49218136531384],[99.36152956024033,4.36007200726577],[100.70867395418313,3.107882968378302],[100.99024296438996,2.8282577284588855],[100.99248531271974,2.8266697151055737],[101.45010060213612,2.6053503205878394],[101.77374610599823,2.36365440538542],[101.91446601067581,2.226535600630696],[101.915071256763,2.2260005511305367],[102.27812681231855,1.9351672177972035],[102.27949335529895,1.934277129104704],[102.8514367657066,1.637066361250952],[103.40342978077389,1.2349357032155004],[103.40653159372607,1.23353620351431],[103.65451175572565,1.1785829159442482],[103.72964157540368,1.129953432661744],[103.73847708106135,1.1298190655471245],[103.80597708106134,1.1706523988804578]]]);
- Test point-in-polygon:
console.log(turf.booleanPointInPolygon(ship, polygon));
Expected result:
true
if i use geojson.io to show the point and polygon, the point appear in polygon!
Actual result:
false
Environment:
- Turf.js version: 7.2.0
Additional context:
- Other Turf.js functions like
pointsWithinPolygon
andbooleanWithin
also fail to produce expected results with the provided coordinates. - Coordinates appear valid and correctly formatted.
Metadata
Metadata
Assignees
Labels
No labels