[mapserver-users] Labels at the layer level

Howard Butler hobu.inc at gmail.com
Sun Apr 6 14:11:27 EDT 2008


On Apr 6, 2008, at 10:46 AM, Richard Greenwood wrote:
> I have many layers that have multiple classes. I frequently want to
> label all the classes in the same way. Being lazy, and not wanting to
> paste a lengthy label definition into each class, I usually create a
> second layer with a single class for the labels. However this forces
> MapServer to open and read the layer twice, which I think is a bit of
> a performance hit over reading only once to render and label it. Is
> this generally correct?
>
> In my mind it would be ideal to have labels available at both the
> layer level and the class level. Any thoughts? Does anybody have a
> more elegant solution?

I don't have an elegant solution, but one thing I've been wishing for  
is a way to serialize the label cache entirely - out to a shapefile or  
some other data source - and provide a way for MapServer to use the  
serialized label cache.  There would be some obvious downsides to that  
approach like it getting out of sync and being highly sensitive to  
certain layers being on and off, but even if the serialized cache were  
used for pre-computed label positions and you let MapServer then go  
handle the collisions, I think it could be faster and certainly more  
repeatable.  On more than a few occasions, I've generated centroids of  
things and used them for labeling county polygons, for example.  For  
line work, it's difficult to do something like that without a lot of  
hand editing of data.  I think serialized label cache would be a more  
repeatable way to do it and allow us to take advantage of MapServer's  
label positioning engine.

So, it doesn't really help, but maybe throws another idea out there :)

Howard


More information about the mapserver-users mailing list