[mapserver-dev] Another labeling sample...

Steve Lime Steve.Lime at dnr.state.mn.us
Sat Sep 13 19:30:55 EDT 2008


I had thought about that too, haven't figured out the switch though...

Steve

>>> "Paul Ramsey" <pramsey at cleverelephant.ca> 09/13/08 6:07 PM >>>
I wonder if FL and NY are sort of inverse cases... the vertically
oriented main area with horizontal scruft and vice versa. Perhaps
there is a switch that can be thrown so that NY uses the center of
gravity in x and computes y using longest mid-point.

P.

On Sat, Sep 13, 2008 at 3:44 PM, Steve Lime <Steve.Lime at dnr.state.mn.us> wrote:
> 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
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>
_______________________________________________
mapserver-dev mailing list
mapserver-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-dev



More information about the mapserver-dev mailing list