Permalink
Browse files

Fix issues with wms_layer_group printing (#4533)

  • Loading branch information...
1 parent 8a60a5a commit 1e38acb6cbb2cc18b7e1ce8d271431e52a066ad3 @szekerest szekerest committed Mar 4, 2013
Showing with 7 additions and 1 deletion.
  1. +7 −1 mapwms.c
View
@@ -2378,6 +2378,8 @@ int msDumpLayer(mapObj *map, layerObj *lp, int nVersion, const char *script_url_
group_layers[0] = lp->index;
if (isUsedInNestedGroup[lp->index]) {
for (j=0; j < map->numlayers; j++) {
+ if (j == lp->index)
+ continue;
for(k = 0; k < numNestedGroups[j]; k++) {
if (strcasecmp(lp->name, nestedGroups[j][k]) == 0) {
group_layers[num_layers++] = j;
@@ -2603,6 +2605,7 @@ void msWMSPrintNestedGroups(mapObj* map, int nVersion, char* pabLayerProcessed,
int index, int level, char*** nestedGroups, int* numNestedGroups, int* isUsedInNestedGroup, const char *script_url_encoded, const char *validated_language)
{
int i, j;
+ int groupAdded = 0;
char *indent = NULL;
indent = msStrdup("");
@@ -2628,10 +2631,12 @@ void msWMSPrintNestedGroups(mapObj* map, int nVersion, char* pabLayerProcessed,
if (!pabLayerProcessed[j]) {
msDumpLayer(map, GET_LAYER(map, j), nVersion, script_url_encoded, indent, validated_language, MS_TRUE);
pabLayerProcessed[j] = 1; /* done */
+ groupAdded = 1;
}
} else {
msIO_printf("%s <Layer>\n", indent);
msIO_printf("%s <Title>%s</Title>\n", indent, nestedGroups[index][level]);
+ groupAdded = 1;
}
/* Look for one group deeper in the current layer */
@@ -2658,7 +2663,8 @@ void msWMSPrintNestedGroups(mapObj* map, int nVersion, char* pabLayerProcessed,
}
}
/* Close group layer block */
- msIO_printf("%s </Layer>\n", indent);
+ if (groupAdded)
+ msIO_printf("%s </Layer>\n", indent);
}
msFree(indent);

0 comments on commit 1e38acb

Please sign in to comment.