[mapserver-dev] Another labeling sample...
Steve Lime
Steve.Lime at dnr.state.mn.us
Sat Sep 13 18:44:37 EDT 2008
I've been tweaking the label placement code a bit and have arrived at what seems to be a pretty nice combo:
1) find the center of gravity for the largest outer ring
2) use that y value
3) compute x from the midpoint of longest segment from a horizontal line (from y above) that that intersects the shape
I believe this guarantees the label point is in the polygon. The current method does as well but it's not as optimized. The center of gravity is fairly quick to compute since the components it needs are the same as for area so they can be done in one pass over the points. Might even be able to sample the points.
Anyway, here's the states sample with this approach. Compare this the maps I posted yesterday. This really improves the placement of labels for Florida and Louisiana. New York moves a bit for the worse, but is quite tolerable. Limiting the computation to the largest outer ring fixes placement issues with Michigan.
I can supply a patch if anyone would like to try it out.
Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: states.png
Type: image/png
Size: 18986 bytes
Desc: Portable Network Graphics Format
Url : http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20080913/c3cdec0d/states-0001.png
More information about the mapserver-dev
mailing list