diff --git a/mapwms.c b/mapwms.c index 5063f39454..9fafe3f267 100644 --- a/mapwms.c +++ b/mapwms.c @@ -363,9 +363,15 @@ int msWMSApplyTime(mapObj *map, int version, char *time, char *wms_exception_for */ void msWMSPrepareNestedGroups(mapObj* map, int nVersion, char*** nestedGroups, int* numNestedGroups, int* isUsedInNestedGroup) { - int i, j, k; + int i, k; const char* groups; char* errorMsg; + //Create array to hold unique groups + int maxgroups = 2000; + int maxgroupiter = 1; + char** uniqgroups = malloc(maxgroups * sizeof(char*)); + int uniqgroupcount = 0; + for (i = 0; i < map->numlayers; i++) { nestedGroups[i] = NULL; /* default */ @@ -388,24 +394,42 @@ void msWMSPrepareNestedGroups(mapObj* map, int nVersion, char*** nestedGroups, i } else { /* split into subgroups. Start at address + 1 because the first '/' would cause an extra empty group */ nestedGroups[i] = msStringSplit(groups + 1, '/', &numNestedGroups[i]); - /* */ - for (j = 0; j < map->numlayers; j++) { - if (isUsedInNestedGroup[j]) - continue; - - for (k=0; kname && strcasecmp(GET_LAYER(map, j)->name, nestedGroups[i][k]) == 0 ) { - isUsedInNestedGroup[j] = 1; + /* Iterate through the groups and add them to the unique groups array */ + for (k=0; knumlayers; i++) { + for (k=0; kname ,uniqgroups[k]) == 0 ){ + isUsedInNestedGroup[i] = 1; + break; } - } - } + } } } + /* ** Validate that a given dimension is inside the extents defined */