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

[enhancement] weight x, y differently? #28

Closed estaub closed 7 years ago

estaub commented 7 years ago

Labels are usually nowhere near square; they are often an elongated bit of text. So the desired weighting (in a loose sense) of x-distances should be different from y-distances.

I'd suggest being able to pass in an aspect ratio. The algorithm modifications may be as simple as just weighting distance measurements.

mourner commented 7 years ago

Thanks for the suggestion! I considered this, but you can already do it by simply modifying the input — stretching coordinates along an axis, and then stretching the output back. Weighting distance turned out to be a non-trivial change in my experiments. If you find a simpler way to do that, feel free to do a pull request.