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

Special case for rectangular polygons comment is misleading #72

Closed hollasch closed 4 years ago

hollasch commented 4 years ago

After computing the polygon centroid to see an initial guess, polylabel computes an additional special case, with the comment “special case for rectangular polygons”. The comment puzzled me, because for rectangular polygons, this would simply compute the centroid through a different method, yielding a redundant candidate point.

I then realized that this computes the bounding-box center point as a legitimate candidate for any polygon. There are indeed cases where this would yield a better solution than a centroid. I'd suggest replacing this comment with something more accurate, like “test the bounding-box center as a possible better candidate”.