mapbox / polylabel

A fast algorithm for finding the pole of inaccessibility of a polygon (in JavaScript and C++)
Other
1.44k stars 151 forks source link

Algorithm returns external point #44

Closed fminuti closed 6 years ago

fminuti commented 6 years ago

The point returned for the polygon var polygon = [[[12.8569046,43.7153127],[12.85684,43.7153125],[12.8568395,43.7152068],[12.8568758,43.7152072],[12.8568766,43.7151763],[12.8570085,43.7151777],[12.8570083,43.7152309],[12.8569055,43.7152302],[12.8569046,43.7153127]]]; is not a Point inside the polygon itself. var point = polylabel(polygon,1,true); debug output: found best 0 after 2 probes num probes: 2 best distance: -0.0000023558598186856006 sample image with the returned point outside the given polygon: polylabel

talaj commented 6 years ago

Try smaller value of precision parameter. I would try 1e-5 in your case, those coordinate values begin to differ on fourth decimal place.

fminuti commented 6 years ago

ThankYou, with precision of 1e-5 works perfectly.