[Gdal-dev] WMS and LAYERS= vs. STATUS Behaviour
Frank Warmerdam
warmerdam at pobox.com
Wed Apr 28 13:33:44 EDT 2004
Daniel and others,
I have been experimenting a bit with the Gaia WMS viewer
(http://www.nukegold.com/downloads.htm) a bit against MapServer, and
found something that surprised me.
It seems that a layer with STATUS DEFAULT will be returned in a GetMap
request against MapServer regardless of whether the layer is in the
layers list or not. Is this the expected behaviour?
I have a WMS server (from CVS) servering 3 layers, all of which have
STATUS DEFAULT. Even if I ask for just one of them, it would appear I
get all 3.
I would have hoped MapServer would have:
o returned only the requested layers if there is a LAYERS= parameter
in the WMS GetMap request.
o Returned only STATUS DEFAULT layers if there was no LAYERS= parameter
in the WMS GetMap request.
If things are behaving as intended, then I think the WMS Server HOWTO
should mention this gotcha.
If things are not working as intended, it would appear the following code
in mapwms.c needs some alterations:
// getMap parameters
if (strcasecmp(names[i], "LAYERS") == 0)
{
int j, k, iLayer;
layers = split(values[i], ',', &numlayers);
if (layers==NULL || numlayers < 1) {
msSetError(MS_WMSERR, "At least one layer name required in LAYERS.",
"msWMSLoadGetMapParams()");
return msWMSException(map, wmtver, NULL);
}
for (iLayer=0; iLayer < map->numlayers; iLayer++)
map->layerorder[iLayer] = iLayer;
for(j=0; j<map->numlayers; j++)
{
// Keep only layers with status=DEFAULT by default
// Layer with status DEFAULT is drawn first.
if (map->layers[j].status != MS_DEFAULT)
map->layers[j].status = MS_OFF;
else
map->layerorder[nLayerOrder++] = j;
}
for (k=0; k<numlayers; k++)
{
layerfound = 0;
for (j=0; j<map->numlayers; j++)
{
// Turn on selected layers only.
if ((map->layers[j].name &&
strcasecmp(map->layers[j].name, layers[k]) == 0) ||
(map->name && strcasecmp(map->name, layers[k]) == 0) ||
(map->layers[j].group && strcasecmp(map->layers[j].group, layers[k]) == 0))
{
map->layers[j].status = MS_ON;
map->layerorder[nLayerOrder++] = j;
validlayers++;
layerfound = 1;
}
}
if (layerfound == 0)
invalidlayers++;
}
// set all layers with status off at end of array
for (j=0; j<map->numlayers; j++)
{
if (map->layers[j].status == MS_OFF)
map->layerorder[nLayerOrder++] = j;
}
msFreeCharArray(layers, numlayers);
}
I can provide a demonstration of the problem if required.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list