4

I'm using ODC OWS to serve rasters from our datacube via WMS. I configured the layers hierarchically but not with a single root and this displays perfectly fine in QGIS:

QGIS screenshot

Then I wanted to use the same WMS in a web app with OpenLayers, so I used its WMSCapabilities class to read the GetCapabilities request. Unexpectedly, only the last group of layers was displayed there, as the top-most Layer property is an object, not an array:

JS console screenshot

(Further down in the hierarchy, there are Layers that are arrays, so in principle this concept is known there.)

Is this a bug in OpenLayers?

In other words: Is this layout a valid GetCapabilities response?

<WMS_Capabilities version="1.3.0">
<Service>...</Service>
<Capability>
  <Request>...</Request>
  <Exception>...</Exception>
  <Layer>...</Layer>
  <Layer>...</Layer>
</Capability>
</WMS_Capabilities>
1
  • I did some digging and believe to have found the answer myself, however as by then I had already pretty much finished writing the question, I decided to post it anyway and answer it myself. If anyone's got any more comments on the matter, I'm happy to hear them! Commented Jun 7 at 19:27

1 Answer 1

4

In its section "7.2.4.5 Layers and styles" (page 24), the WMS 1.3.0 spec says:

Each available map is advertised by a element in the service metadata. Conceptually, each Layer is a distinct entity. However, as a means of classifying and organizing layers, and as a means of reducing the size of the service metadata, a single parent Layer may enclose any number of additional layers, which may be hierarchically nested as desired. Some properties defined in a parent layer are inherited by the children it encloses. These inherited properties may be either redefined or added to by the child. Subclause 7.2.4.8 summarizes whether or how each property is inherited.

A server shall include at least one element for each map layer offered. If desired, layers may be repeated in different categories (i.e. enclosed in more than one parent ) when relevant.

(emphases mine)

In my opinion, this wording is somewhat ambiguous, or at least doesn't explicitly disallow more than one top-most <Layer>.

However, on page 63, the Annex E -- which is explicitly declared as normative -- gives the XML schema as:

<sequence>
  <element ref="wms:Request"/>
  <element ref="wms:Exception"/>
  <element ref="wms:_ExtendedCapabilities" minOccurs="0" maxOccurs="unbounded"/>
  <element ref="wms:Layer" minOccurs="0"/>
</sequence>

As per this answer, the default value for maxOccurs is 1, so the answer can be given as a clear NO.

No, the element is not allowed multiple times there; no, the sample XML is not valid; and no, this is not a bug in OpenLayers.

QGIS probably works around it anyway so that servers can be used even when they are not 100% compliantly implemented. ODC OWS should probably give a warning when configured like this, or wrap the whole thing in an additional <Layer>...</Layer> if it encounters more than one top-most layer in the user-supplied config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.