iD icon indicating copy to clipboard operation
iD copied to clipboard

Area label appears outside area for complex shapes

Open andyclegg opened this issue 11 years ago • 4 comments

For example, see http://www.openstreetmap.org/edit?editor=id&way=23543197#map=18/57.17726/-2.14126 The label for 'River Don' appears on top of the northernmost soccer field. I am presuming this is because it is the centroid of the nearby riverbank area, however because the area is not convex, it does not necessarily enclose its own centroid. The simplest solution would probably be to test the calculated label point, and if it is not enclosed by the area, do not display it. ]

andyclegg avatar Dec 02 '14 12:12 andyclegg

ideas here: http://gis.stackexchange.com/questions/2128/algorithm-for-finding-irrregular-polygon-centroid-label-point

bhousel avatar Dec 02 '14 20:12 bhousel

Another idea, taking advantage of iDs ability to draw labels along arbitrary paths. Break the area down into a polygon mesh of triangles. Find the centroid of each triangle. Draw the label along the imaginary path which connects these centroids.

andyclegg avatar Dec 03 '14 00:12 andyclegg

update: try @mourner's https://github.com/mapbox/polylabel

bhousel avatar Jul 22 '16 17:07 bhousel

https://github.com/mapbox/polylabel's PIA would work well.

pnorman avatar Jul 18 '22 03:07 pnorman