Opened 19 years ago

Last modified 15 years ago

#1377 new enhancement

expand variable substition to LABELITEM

Reported by: bugzilla@… Owned by: sdlime
Priority: low Milestone: 6.0 release
Component: MapServer CGI Version: 4.6
Severity: minor Keywords:
Cc:

Description (last modified by sdlime)

Hi, we need to label a map using different fields of a DBF. We have patched
mapserver to allow variable substitution on LABELITEM tag, and i think it may be
usefull for others. I suggest to add this feature to next version of mapserver.

Regards.

281a282
>       if(map->layers[j].labelitem && (strstr(map->layers[j].labelitem, tmpstr)
!= NULL)) map->layers[j].labelitem = gsub(map->layers[j].labelitem, tmpstr,
msObj->request->ParamValues[i]);

Change History (4)

comment:1 by sdlime, 19 years ago

I don't think this is needed. Why not just use the runtime configuration. So, 
if you have a layer called 'lakes' you could change the labelitem with 
something like:

  map_lakes_labelitem=foo

Steve

comment:2 by bugzilla@…, 19 years ago

We are already passing arguments "user" "variable" "horizon" to other layers.  
Since "DATA" tag supports variable substitution, we are using variables to  
build a data source name.  
  
for example:  
  
DATA "forecasts/%date%/%variable%.png" or  
DATA "obs/%date%/lightings.shp"  
EXPRESSION ([%horizon%] > 3)  
  
The same variable passed to the cgi is substituted in several layers  
simultaneously.  
The problem comes when we need to label a map, because we can't choose the  
field of dbffile to use.  
  
Yes, we can use (we were using)  ugly solutions like map_layer_labelitem 
trick, but we don't want users to know which layers we have.  
 
Compare: 
 
mapserv?mode=map&map=forecats.map&user=fred&date=20050608&variable=temperature 
 
with 
 
mapserv?mode=map&map=forecats.map&user=fred&date=20050608&variable=temperature&map_TEMPMAX-LABELS_labelitem=20050608&map_TEMPMIN-LABELS_labelitem=20050608 
 
We try to maintain an 'object oriented' query string. 
 
Of course, we can use a wrapper in order to avoid calling mapserv cgi 
directly, hidding all "raw" parameters,  but it has an unneeded performance 
hit. 
 
LABELITEM is in some way like "DATA", "CONNECTION", or "FILTER". It is needed 
to choose which content to show. Please, consider %variable% substitution in 
this tag. 
 
Why don't enable variable substitution in all mapfile? It is only related to  
performance? May be it could be a configuration option. 

comment:3 by sdlime, 16 years ago

Description: modified (diff)
Milestone: 5.4 release

comment:4 by sdlime, 15 years ago

Milestone: 5.4 release6.0 release
Note: See TracTickets for help on using tickets.