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

Counterintuitive Pole Placement #32

Closed stonetip closed 6 years ago

stonetip commented 7 years ago

I may misunderstand the way this algorithm works. And from reading the description, it is an impressive bit of work. However, this is just one of several examples where the output is unexpected:

image

weyer1.json.txt

talaj commented 7 years ago

If I'm counting correctly there are 10 interior rings in the json, but the image shows more than 10 holes, so the polygon cannot be valid. The algorithm cannot work with invalid polygons. Please correct me if I'm wrong.

stonetip commented 7 years ago

I checked a simplified version of the feature for validity in both QGIS and ArcGIS and it seems fine. I also tested it as geoJSON in geoJSONLint. The label point still ended up in the same place. I even temporarily removed all the actual rings and that resulted in an even less likely point. Even with a simpler, definitely single polygonic shape, the results aren't as expected (which I've indicated by manually placing the encircled red point): image

The attached is the verified and tested file for the original polygon: weyer1_S2.json.txt

talaj commented 7 years ago

So I've got that position with precision set to 0.01: interior-point-3-512-512-1 0-agg

I'm sorry for the noise with polygon validity.

stonetip commented 7 years ago

You know, I've got to go back and look at my code. I'm thinking I either set the precision too coarse or left it out altogether (if that's possible). Because, judging by the image from @talaj above that placement is perfect.

mourner commented 6 years ago

I assume this was just a badly picked precision, right?

stonetip commented 6 years ago

That was the case. Thanks.