Opened 21 years ago

Closed 21 years ago

#396 closed defect (fixed)

Double labeling in querymap

Reported by: dmorissette Owned by: sdlime
Priority: high Milestone:
Component: MapServer C Library Version: 4.1
Severity: normal Keywords:
Cc:

Description

This was reported on mapserver-users, but I noticed the same myself in 3.6 and
4.0, but never took time to investigate (duh!).  I'm filing this here so that we
don't forget.

----------
> From: 	Fawcett, David[SMTP:David.Fawcett@state.mn.us]
> Sent: 	Monday, August 04, 2003 4:27 PM
> To: 	'mapserver-users@lists.gis.umn.edu'
> Subject: 	[Mapserver-users] Double labeling in querymap?
> 
> I am not sure if this is a bug or PIBCAK*
> 
> Version 4.0 beta2 (7/11/03)
> 
> When I query a point feature, the querymap puts two identical labels on the
selected point feature, but correctly places only one label on the other point
features on the map.  
> 
> The point layer only exists once in the MAP file, so I am not querying two
overlaying instances of the same point.
> 
> Am I getting a cached label showing up?  I really only need to label each
facility once.
> 
> Thanks, 
> 
> David.

Fawcett, David wrote:
> This occurs when the STYLE property of the QUERYMAP object is set to HILITE,
but does not occurr when I change it to SELECTED.
> 
> David.
>

Change History (3)

comment:1 by dmorissette, 21 years ago

Steve Lime wrote:
> That's cause with HILITE the layer is processed twice, once as normal
> and once with only the selected features. With SELECTED the layer is
> only processed once. The label is just getting set in the cache twice.
> One workaround would be to set a value for MINDISTANCE. In most cases
> that wouldn't affect labeling at all and should remove the second label.
> 


OK, I think you had sent the same exlanation last time the issue was raised,
that's why nothing was done about this.

But is there really no way we could automagically fix this for the user.  It
seems a bit clunky to require from the user that he sets a MINDISTANCE just to
make hilite work properly.

Perhaps QUERYMAP HILITE could check the labelcache setting for the layer, and if
labelcache is turned on then it knows that the feature may already have a label
in the cache and won't label it again, it would only draw the shape but not the
label.  OTOH, if labelcache is disabled for this layer or if this layer is
postlabelcache then it would draw the label on the hilited feature.

Would that work?

comment:2 by sdlime, 21 years ago

Status: newassigned
The best solution would be to remove dups somehow from within the cache. This 
would only have to be done once (for each label in the result set) in the 
function that draws a query map, and then only when style equals hilite and the 
cache is on. I'd propose adding a function called something like 
msLabelIsDuplicate() that takes the cache and a label and returns success if 
it's a duplicate and failure if not. If not a duplicate then msAddLabel() is 
called and all is well. Shouldn't add much overhead since HILITE result sets 
tend to be very small.

In cases when the cache is off, or it's post label cache there is no 
autoplacement so the labels would just write over one another.

comment:3 by sdlime, 21 years ago

op_sys: Windows XPAll
rep_platform: PCAll
Resolution: fixed
Status: assignedclosed
I don't think there is a perfect solution, especially if layers are drawn
outside of the labelcache. However, I don't believe that will be much of a
problem. Layers labeled without the cache cannot take advantage of AUTO
placement so in that case the label would simply be drawn twice but exactly on
top of each other. My solution was to mimic the workaround I mentioned. In cases
where style is HILITE we cache the old MINDISTANCE value and set a temporary
value. This way we use the normal mechanism in the cache processor. I expect
querymaps to change at some point (to query specific styles for example) and
this would have to change then too, but for now it should work fine.
Note: See TracTickets for help on using tickets.