Skip to content

Commit

Permalink
Allow access to layer [metadata_*] tags in legacy headers & footers
Browse files Browse the repository at this point in the history
Due to these parts being processed in BROWSE mode, no layer metadata
could be accessed - this commit allows access to layer metadata tags
so long as there is a current (non-null) resultlayer, regardless of the
mode in which processLine() is being run
  • Loading branch information
ejn committed Jul 20, 2015
1 parent a504deb commit e945d25
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions maptemplate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3923,18 +3923,8 @@ static char *processLine(mapservObj *mapserv, char *instr, FILE *stream, int mod
outstr = msReplaceSubstring(outstr, "[lrn]", repstr);
outstr = msReplaceSubstring(outstr, "[cl]", mapserv->resultlayer->name); /* current layer name */
/* if(resultlayer->description) outstr = msReplaceSubstring(outstr, "[cd]", resultlayer->description); */ /* current layer description */
}

if(mode != QUERY) {
if(processResultSetTag(mapserv, &outstr, stream) != MS_SUCCESS) {
msFree(outstr);
return(NULL);
}
}

if(mode == QUERY) { /* return shape and/or values */

/* allow layer metadata access in a query template, within the context of a query no layer name is necessary */
/* allow layer metadata access when there is a current result layer (implicitly a query template) */
if(&(mapserv->resultlayer->metadata) && strstr(outstr, "[metadata_")) {
for(i=0; i<MS_HASHSIZE; i++) {
if(mapserv->resultlayer->metadata.items[i] != NULL) {
Expand All @@ -3950,6 +3940,14 @@ static char *processLine(mapservObj *mapserv, char *instr, FILE *stream, int mod
}
}
}
}

if(mode != QUERY) {
if(processResultSetTag(mapserv, &outstr, stream) != MS_SUCCESS) {
msFree(outstr);
return(NULL);
}
} else { /* return shape and/or values */

snprintf(repstr, sizeof(repstr), "%f %f", (mapserv->resultshape.bounds.maxx + mapserv->resultshape.bounds.minx)/2, (mapserv->resultshape.bounds.maxy + mapserv->resultshape.bounds.miny)/2);
outstr = msReplaceSubstring(outstr, "[shpmid]", repstr);
Expand Down

0 comments on commit e945d25

Please sign in to comment.