AW: [MAPSERVER-USERS] Hiding overviews
Daniel Morissette
dmorissette at mapgears.com
Tue Mar 25 08:38:38 PDT 2008
Daniel Morissette wrote:
> I had a quick look at this thread and it seems to me at first that using
> GROUP in all layers corresponding to the same set of overviews should
> allow you to turn all of them on/off at once.
>
I built a small test case and it seems that the root problem is that the
function msOWSMakeAllLayersUnique() produces an exception if any layer
is missing a NAME. In order to allow what you want and make the layer
name really optional we would need to get rid of that exception.
If we modify msOWSMakeAllLayersUnique() to 'continue' the loop instead
of returning an exception when it encounters a NULL layer name as follows...
--- mapows.c (revision 7477)
+++ mapows.c (working copy)
@@ -141,10 +169,7 @@
{
if (GET_LAYER(map, i)->name == NULL || GET_LAYER(map,
j)->name == NULL)
{
- msSetError(MS_MISCERR,
- "At least one layer is missing a name in map
file.",
- "msOWSMakeAllLayersUnique()");
- return MS_FAILURE;
+ continue;
}
if (strcasecmp(GET_LAYER(map, i)->name, GET_LAYER(map,
j)->name) == 0 &&
msRenameLayer((GET_LAYER(map, j)), ++count) != MS_SUCCESS)
... then the following mapfile block...
LAYER
NAME layer1
METADATA
"wms_title" "Layer 1"
"wms_group_title" "Group 1"
END
GROUP group1
MINSCALE 0
MAXSCALE 10000
TYPE RASTER
STATUS ON
DATA layer1.tif
END
LAYER
# NAME intentionally omitted...
METADATA
"wms_title" "Layer 2"
END
GROUP group1
MINSCALE 10001
MAXSCALE 100000
TYPE RASTER
STATUS ON
DATA layer2.tif
END
... produces the following output in GetCapabilities ... this whole
group can be turned on/off at once using LAYERS=group1 in the GetMap
request. Notice that layer 2 has no name in GetCapabilities which is
what we wanted. Omitting the layer name for layer 1 as well would make
it non-selectable as well:
<Layer>
<Name>group1</Name>
<Title>Group 1</Title>
<Abstract>group1</Abstract>
<Layer queryable="0">
<Name>layer1</Name>
<Title>Layer 1</Title>
<ScaleHint min="0" max="4.98902848429637" />
</Layer>
<Layer queryable="0">
<!-- WARNING: Mandatory mapfile parameter 'LAYER.NAME' was missing in
this context. -->
<Title>Layer 2</Title>
<ScaleHint min="4.9895273871448" max="49.8902848429637" />
</Layer>
</Layer>
We would also need to update the WARNING text to say "optional" instead
of Mandatory.
If this is indeed what you were trying to achieve then please file a
ticket and I'll make the required changes in MapServer 5.2.
Daniel
--
Daniel Morissette
http://www.mapgears.com/
More information about the MapServer-users
mailing list