Right, the problem has two parts:
1) determine potential candidate label points
2) see if the label fits given the constraints placed on how to draw it
This is NP hard problem because it not just a problem of labeling a
single polygon you also have to deal with all the other labels on the
map that you might collide with.
If you search "automatic label placement" in google you can read up on
the problem and the solutions that are available. Mapserver uses a
different scheme for doing label placement that is much faster because
it does not try to optimize label placement, but rather gives you
controls for how labels should be placed, like POSITION, ANGLE
AUTO|FOLLOW, PROCESSING "LABEL_NO_CLIP=ON", PRIORITY, WRAP,
MINFEATURESIZE, MAXLENGTH, PARTIALS, etc.
By the way, PROCESSING "LABEL_NO_CLIP=ON" will fix the label point at
the polygon center.
-SteveW
On 3/6/2012 6:13 AM, Patricio Gigoux wrote:
You could generate a center point, there is a function that do it in
irregular shaped, and fit the label in it
Patricio Gigoux
El 05-03-2012 18:50, Stephen Woodbridge escribió:
On 3/5/2012 4:44 PM, Mark Volz wrote:
Hello,
Is there a way to force labels to fit inside of a polygon, even if a
polygon is irregularly shaped? I noticed that with POSITION AUTO labels
are falling outside of my soils boundary.
The short answer is no. It is an interesting problem, but it does not
have a guaranteed result as the label might be too big to fit
regardless. I am not even sure of the algorithm should be for
something like this. There are a lot of parameters like:
font
font size
wrapping the text
changing the angle
finding the longest line, arc or smooth polyline that fits withing the
polygon and then have the text follow that line
These are all computationally expensive to do on the fly while
rendering. Ideally these should be worked out in advance then you can
supply the attributes to the label via binding columns in the data.
-SteveW
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users