Permalink
Browse files

Support attribute name aliases for output in text/plain WMS GetFeatur…

…eInfo.
  • Loading branch information...
1 parent 1c26865 commit 846dd74a65a68d8649ceee5a1fa2503362a39c1f Martin Kofahl committed with tbonfort Nov 8, 2012
Showing with 25 additions and 4 deletions.
  1. +24 −3 mapwms.c
  2. +1 −1 msautotest
View
@@ -3740,6 +3740,10 @@ int msDumpResult(mapObj *map, int bFormatHtml, int nVersion, char *wms_exception
char **excitems=NULL;
int numexcitems=0;
const char *value;
+ size_t bufferSize=0;
+ size_t reqBuffSize;
+ char *tag=NULL;
+ const char *lineTemplate=" %s = '%s'\n";
layerObj *lp;
lp = (GET_LAYER(map, i));
@@ -3797,21 +3801,38 @@ int msDumpResult(mapObj *map, int bFormatHtml, int nVersion, char *wms_exception
msInitShape(&shape);
if (msLayerGetShape(lp, &shape, &(lp->resultcache->results[j])) != MS_SUCCESS) {
+ if (tag != NULL) msFree(tag);
msFree(itemvisible);
return msWMSException(map, nVersion, NULL, wms_exception_format);
}
msIO_printf(" Feature %ld: \n", lp->resultcache->results[j].shapeindex);
for(k=0; k<lp->numitems; k++) {
- if (itemvisible[k])
- msIO_printf(" %s = '%s'\n", lp->items[k], shape.values[k]);
- }
+ if (itemvisible[k]) {
+ reqBuffSize = strlen(lp->items[k]) + 7;
+ if (reqBuffSize > bufferSize) {
+ if (tag != NULL) msFree(tag);
+ /* allocate more buffer than we need to try and avoid need for
+ repeated reallocation */
+ bufferSize = reqBuffSize * 2;
+ tag = (char*)msSmallMalloc(bufferSize);
+ }
+ snprintf(tag, reqBuffSize, "%s_alias", lp->items[k]);
+
+ if((value = msOWSLookupMetadata(&(lp->metadata), "MO", tag)) != NULL)
+ msIO_printf(lineTemplate, value, shape.values[k]);
+ else
+ msIO_printf(lineTemplate, lp->items[k], shape.values[k]);
+ }
+ }
+
msFreeShape(&shape);
numresults++;
}
+ if (tag != NULL) msFree(tag);
msFree(itemvisible);
/* msLayerClose(lp); */

0 comments on commit 846dd74

Please sign in to comment.