[Mapserver-dev] Labeling Question

woodbri at swoodbridge.com woodbri at swoodbridge.com
Sat Aug 30 09:42:30 EDT 2003


Hi all,

I have been thinking about labelling and have a question about 
mapserver's strategy or lack there of :)

It seems to me that the when constructing a mapfile that the layers 
are put down like polygon areas, then minor line art, then major line 
art, then point objects BUT when labelling the map you want your 
labels to be generated in the reverse priority ie: label points 
first, then major line art, them minor line art, then polygons, etc.

So in the mapfile you can either label objects when you lay them down 
or you can take a second pass through all your layers to change the 
order of labelling. The label as you go is faster but your labels are 
prioritized backwards or you have to scan your files twice. An 
lastly, labels are added to the cache in the same basic order as they 
are found in the data sets which may or may not make sense.

Assuming that I got this right so far ... probably a big wrong 
assumption on my part :)

Wouldn't is make more sense to construct a list of potential labels 
and then load the list backwards into the label cache to deal with 
collisions. This would cost a little more in memory, but I think it 
would faster and and cutdown on the number of layers and give better 
results for probably 90+% of the cases. You could still have 
ANNOTATION layers for more control or set up other additional 
strategies for prioritizing important labels.

A related idea would be to be able to give labels attributes like 
LEVEL=n and FORCE=0|1 these would have the effect of allowing you to 
set the force labels on on a label by label or expression and level 
would allow you to class labels into layers the get added to the 
cache based on their LEVELs. 

For example, I would like to label polygons with a muted color in the 
background and force those labels on, but I don't want them to bump 
other labels out of the cache. So I might say
   LEVEL=0
   FORCE=1
   CACHE=0
which would cause these labels to be drawn first (LEVEL=0) and they 
would be forced to be drawn and they would not be added to the cache 
so other labels might be drawn later over them. I might make LEVEL=-1 
to mean that the label is drawn at the time the layer is drawn.

Thoughts, comments, and flames welcome.

-Steve W.



More information about the mapserver-dev mailing list