Opened 16 years ago

Closed 16 years ago

#2562 closed defect (fixed)

Accept layers with no name in WMS GetCapabilities

Reported by: dmorissette Owned by: dmorissette
Priority: normal Milestone: 5.2 release
Component: WMS Server Version: svn-trunk (development)
Severity: normal Keywords:
Cc:

Description

This ticket came out of the thread "Hiding overviews" on mapserver-users: http://lists.osgeo.org/pipermail/mapserver-users/2008-March/054677.html

A user created a set of overviews for different scales of a given raster image and created individual layers for each scale (with continuous minscale/maxscale settings). We want to group all these layers under the same group in WMS GetCapabilities and have the ability to select the group by its name, but prevent users from selecting any of the individual scale-specific layers.

The grouping works, and the whole group can be selected at once using the LAYERS=group_name GetMap parameter, but it is not currently possible to set no name on the individual layers. The function msOWSMakeAllLayersUnique() produces an exception if any layer is missing a NAME. In order to allow what we want and make the layer name really optional we would need to get rid of that exception.

Change History (4)

comment:1 by dmorissette, 16 years ago

Owner: changed from mapserverbugs to dmorissette

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.

comment:2 by ctweedie, 16 years ago

Daniel, this raises an interesting question regarding subgroups in general.

If Mapserver now does not advertise Named Layers under Named Groups, this should allow users to configure GROUP's to reside under a wms_group Title. As i understand the current limitation of 1 but not both, is for compliance reasons.

If i understand the requirement correctly, given this patch we should now be able to ..

LAYER

NAME layer1 METADATA

"wms_title" "Layer 1" "wms_group_title" "Group 1" "wms_layer_group" "/parent" "wms_group_title" "Parent"

END GROUP group1 MINSCALE 0 MAXSCALE 10000 TYPE RASTER STATUS ON DATA layer1.tif

END

LAYER

# NAME intentionally omitted... METADATA

"wms_title" "Layer 2" "wms_layer_group" "/parent" "wms_group_title" "Parent"

END GROUP group1 MINSCALE 10001 MAXSCALE 100000 TYPE RASTER STATUS ON DATA layer2.tif

END

Would result in ...

<Layer>

<Title>Parent</Title>

<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>

</Layer>

This opens up a few new opportunities for structuring of data. Although i recognise this may require a fair bit of reworking the current mapwms.c code.

Thoughts? Shall i raise a new task dependant on this?

comment:3 by dmorissette, 16 years ago

Chris, I read your comment multiple times but still don't understand what you mean. Anyway, this ticket is not directly related to nesting of groups using wms_layer_group metadata, so I suspect what you want is out of scope for this ticket and we should move this discussion elsewhere.

I'd suggest you raise your question on the users list, and if needed a ticket can be created later on.

comment:4 by dmorissette, 16 years ago

Resolution: fixed
Status: newclosed

Fixed. Committed a change to trunk (5.1-dev) in r7610 to accept layers with no name instead of producing an exception, and got rid of the Warning in the XML output about LAYER.NAME being mandatory (since it is not any more).

Note: See TracTickets for help on using tickets.