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

return best distance #2

Closed Fil closed 4 years ago

Fil commented 8 years ago

it would be super useful in many cases to know what the best distance was, for example to decide whether or not to display a label, or to use in other computations.

Non-breaking change 1: var r = [bestCell.x, bestCell.y]; r.distance = bestCell.d; return r;

Not-too-much-breaking change 2: return [bestCell.x, bestCell.y, bestCell.d];

1 is probably nicer but some developers might find the array/object mix awkward to work with.

curran commented 7 years ago

Another useful application of this would be variable size labels. That would be super cool.

Thirdhuman commented 5 years ago

Where would I make this edit in the polylabel code?

curran commented 4 years ago

This would be nice to have.

At the moment, I'm looking at the MultiPolygon label placement problem.

Approach for now: show labels only for the polygon with the largest area, within a given MultiPolygon.

FWIW I'd vote for Non-breaking change 1.