Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#2705 closed defect (fixed)

No label background when labelcache is off

Reported by: aboudreault Owned by: sdlime
Priority: normal Milestone: 5.4 release
Component: MapServer C Library Version: unspecified
Severity: normal Keywords:
Cc: dmorissette

Description

There is a problem with a label background is used and the labelcache is set to off: there is no background draw at all is we add "LABELCACHE OFF" is the LAYER definition in the mapfile. Currently, only the function "msDrawLabelCache" seem to draw the background of a label and this function is only called when labelcache is on. Otherwise, it's the function "msDrawText" that is called and this one doesn't care about background. There is also a problem when we have a layer of type "annotation" and load text from OGR with "STYLEITEM AUTO". After changing these two lines to "label.backgroundcolor":

we can see that for this style, it's the function "msDrawLabel" that is called and this function doesn't care neither of drawing background.

Change History (7)

comment:1 by dmorissette, 16 years ago

Steve, any idea on this one? Is there a reason why label background (filled box behind the label) should be drawn only when the labelcache is on (and not drawn if we bypass labelcache)?

comment:2 by sdlime, 16 years ago

Status: newassigned

It's probably just the result of where the billboard is drawn. It may be that the info necessary to draw it is only (easily) available in the cache processing or (more likely) that the billboard is taken into account when placing labels so it is only done in the cache. I'll have to investigate to be sure.

Steve

comment:3 by sdlime, 16 years ago

The block of code that draws the background looks like it can safely be moved out to the msxxxDrawText functions. Will try that with GD and AGG.

Steve

comment:4 by dmorissette, 16 years ago

Um... I was checking this and it seems that if we move the code that renders the background to msDrawText() then we'll need to call msGetLabelSize() twice: once in the msDrawLabelCache() as we already do, and once more in msDrawText(), unless we carry the label box around. Did you know of a way to avoid this Steve?

comment:5 by sdlime, 16 years ago

Check out a change I made tonight (r7846). Instead of drawing the background stuff in the msxxxDrawText() function I do it in msDrawLabel(). This mimics the behavior in msDrawLabelCache()- which remains "as is", and is more general I think. I did have to update the parameters for msDrawLabel() to pass a mapObj so we'd have access to a symbolset but that allowed removing the fontset parameter so it's a wash.

In my simple tests the backround (and optionally background shadow) are rendered if the cache is on or off. We might be able to condense the code in msDrawLabel() a bit more but I didn't bother yet.

Steve

comment:6 by dmorissette, 16 years ago

Resolution: fixed
Status: assignedclosed

Thanks a lot Steve. Alan confirmed that this solved the problem with his test case as well, so we're ready to call this fixed from our point of view... unless you want to keep this open to move all the code in msDrawLabel()?

I'll mark fixed for now. You can reopen if you plan on doing more code refactoring.

comment:7 by sdlime, 16 years ago

msDrawLabel and msDrawLabelCache are basically mutally exlusive, you'd never use both with the same feature so it's probably good enough as is. We just have to remember that if we want to play with background label rendering it has to be changed in 2 places for the moment.

Steve

Note: See TracTickets for help on using tickets.