[mapserver-users] Avoid labels over particular lines

Stephen Woodbridge woodbri at swoodbridge.com
Fri Mar 23 14:37:36 EDT 2012


This was my thinking when I responsed to Matt below. Based on some of 
the new work that Thomas has done I think label leaders are put into the 
processed label cache, and that these are avoided also. So based on 
Matt's request we could include the road lines also and then the bbox of 
the labels would avoid intersecting the lines. Likewise as you have 
suggested, the same could be done for polygons. We would just need an 
API call that could be used to preload the processed cache with geometry 
and a mechanism to trigger loading the data at the layer or class level.

Once an object has been added to the processed label cache, you loose 
information about priority so I don't think it is feasible to put 
priorities on the features to be avoided because this makes the problem 
significantly more complex and probably a multiple pass problem.

-SteveW

On 3/23/2012 2:22 PM, Brent Fraser wrote:
> Steve L.,
>
> I was thinking more of a way to avoid certain locations for label
> placement. Currently the label cache mechanism "reserves" locations that
> already have labels (if I remember correctly), and mapserver iterates
> thru the 9 locations to hopefully find one without any existing labels.
> My thought was to use that method to create polygons not of label boxes,
> but of outlines of feature graphics. and put those in the label cache
> (at a much lower priority than the label boxes perhaps?). In a perfect
> world, the label would be placed in an "empty" area., or more likely in
> an area of a minimal amount of graphics.
>
> Best Regards,
> Brent Fraser
>
>
> On 3/23/2012 10:24 AM, Lime, Steve D (DNR) wrote:
>>
>> Might the layer masking support described here
>> http://mapserver.org/development/rfc/ms-rfc-79.html be relevant? One
>> could create a mask around features you don’t want covered and
>> reference that in the layers with labels. Problem is you might omit
>> features to when you really just want to omit labels.
>>
>> Steve
>>
>> *From:*mapserver-users-bounces at lists.osgeo.org
>> <mailto:mapserver-users-bounces at lists.osgeo.org>
>> [mailto:mapserver-users-bounces at lists.osgeo.org] *On Behalf Of *Matt
>> McClelland
>> *Sent:* Thursday, March 22, 2012 10:03 PM
>> *To:* Brent Fraser
>> *Cc:* mapserver-users at lists.osgeo.org
>> <mailto:mapserver-users at lists.osgeo.org>
>> *Subject:* Re: [mapserver-users] Avoid labels over particular lines
>>
>> I love this idea
>> Maybe the ability to give a feature priority level of 'label avoidance'
>> So features like Contours (that may cover a map) can be given a low
>> priority,
>> but features like main roads and points of interest might be given a
>> high priority so they are always visible.
>>
>> (I did play with rendering some of these items after the label cache,
>> but that just meant the labels where now covered by the feature)
>>
>> This sounds like a lot of work, but I don't know??
>>
>> Matt :)
>>
>> On Fri, Mar 23, 2012 at 1:16 PM, Brent Fraser <bfraser at geoanalytic.com
>> <mailto:bfraser at geoanalytic.com>> wrote:
>>
>> Steve,
>>
>> I wonder if it would be possible/economical to extend the label cache
>> to have some kind of feature density "map"/weighted mask to help in
>> determining a preferred label location...
>>
>> Best Regards,
>> Brent Fraser
>>
>>
>>
>>
>> On 3/22/2012 6:19 PM, Stephen Woodbridge wrote:
>>
>> On 3/22/2012 8:09 PM, Matt McClelland wrote:
>>
>> Hi All
>>
>> Is there a way in mapserver (6.0) to prevent labels appearing over a map
>> feature?
>>
>> I have a highway and I want to prevent labels (town and other names from
>> other layers) sitting over the highway.
>> I guess something like Buffer in labels.
>>
>>
>> No, when you go to process a label it knows nothing about what
>> features have been rendered. I guess in theory you could add all the
>> features to the label cache. I guessing that to do this you would need
>> some keyword at the LAYER level to indicate that these features need
>> to be added to the label cache, but nothing exists today that would do
>> this.
>>
>> You might want to open a ticket for an enhancement and paste the
>> cotent of your message and my response above into it.
>>
>> -Steve W
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org <mailto:mapserver-users at lists.osgeo.org>
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list