Friday, August 26, 2011

Cascaded Layers and Themes

Today I want to talk about an experimental way to configure cascaded layers.

I already talked about a new layers and themes concept. In order to test out how this can work, I've now implemented an experimental way to cascade a WMS. This is a different approach than the one I already talked about, it focuses on cascading a complete service rather than a single layer.

So we have a couple of different resources here. The first and most basic resource is a remote OWS (OGC Web Service). There are now two different remote OWS resource types, with the old one still being used by the traditional cascading layers concept. The new one is currently a lot simpler to configure:

<?xml version="1.0"?>
<RemoteWMS xmlns="http://www.deegree.org/remoteows/wms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.deegree.org/remoteows/wms remotewms.xsd"
configVersion="3.1.0">
  <CapabilitiesDocumentLocation
    location="http://deegree3-demo.deegree.org/deegree-utah-demo/services?request=GetCapabilities&amp;service=WMS&amp;version=1.1.1" />
</RemoteWMS>

Please note that the namespace differs from the traditional remote WMS store. The only thing to configure here is the location of the WMS capabilities document.

The next resource we have is a LayerStore. A remote WMS layer store can be used to provide a 'copy' of all the layers a remote WMS has. The configuration simply consists of telling the store which remote WMS to use:

<?xml version="1.0"?>
<RemoteWMSLayers
xmlns="http://www.deegree.org/layers/remotewms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.deegree.org/layers/remotewms remotewms.xsd"
configVersion="3.1.0">
<RemoteWMSStoreId>d3</RemoteWMSStoreId>
</RemoteWMSLayers>
 
Next is the configuration of a Theme. The configuration of a theme is also pretty straightforward. It also needs a remote WMS, and it needs to have layer stores:

<?xml version="1.0"?>
<RemoteWMSThemes
xmlns="http://www.deegree.org/themes/remotewms"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.deegree.org/themes/remotewms remotewms.xsd"
configVersion="3.1.0">
<RemoteWMSId>d3</RemoteWMSId>
<LayerStoreId>d3</LayerStoreId>
</RemoteWMSThemes> 
 
The interesting thing here is what happens here. As you might remember, a theme combines sub-themes and layers to what is traditionally known as layer trees. You can now use theme references to configure your WMS layer structure (as we will see below).

The remote WMS theme creates a theme structure which is identical to the layer structure of the remote WMS. It then tries to find matching layers from the available layer stores, and inserts them at the appropriate places. If the layer store coincides with the remote WMS layer store (as in our case) you'll get the same structure as the cascaded WMS.

The WMS configuration is then as simple as this:

<wms:deegreeWMS
xmlns:wms="http://www.deegree.org/services/wms"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
configVersion="3.1.0"
xsi:schemaLocation="http://www.deegree.org/services/wms http://scemas.deegree.org/services/wms/3.1.0/wms_configuration.xsd">
<wms:ServiceConfiguration>                                                                                                                         
    <wms:ThemeId>d3</wms:ThemeId>                                                                                                                                                     
  </wms:ServiceConfiguration>
</wms:deegreeWMS>

And that's it. True, you had to edit four files, but all are very simple to understand. Cascading a WMS with 524 layers used to be harder...

If you do a quick GetCapabilities, you'll see that bounding boxes, metadata etc. are just copied from the remote service. In the future it will of course be possible to manually create a custom theme, which can then be used to only select a couple of layers from the remote WMS, mix them with other layers and add/edit metadata.

I think this proves that the layers/themes concept can work. To further test it, a couple of prototypic other layer stores will be implemented soon.