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

Not getting the rectangle center when passing a rectangle as polygon #45

Closed SBRK closed 6 years ago

SBRK commented 6 years ago

I'm using this to add labels to random shape polygons, mainly because I can sometimes get "L" shaped polygons and using the barycenter would give me points outside of the polygon. It works pretty good on those cases, but on very simple cases, I'm getting bad results.

On rectangular shapes, I most of the time get a point close to one of the 4 sides. I would expect a point in the dead center in those cases.

mourner commented 6 years ago

Let's close this as a duplicate of #33