GSIP 161

Torben Barsballe edited this page Aug 23, 2017 · 43 revisions

GSIP 161 - Style Based Layer Groups


This proposal makes this multi-layer SLD functionality accessible to a wider range of users through a modification to the GeoServer layer and layer group data model. This proposal allows a LayerGroup to contain both Layers, LayerGroups and StyleGroups (where a style group is defined by the associated SLD file).

See example at the end of this page for an example of a multi-layer SLD as currently supported by GeoServer.

Proposed By

Torben Barsballe, David Vick

Assigned to Release

This proposal is for GeoServer 2.12-beta.


  • Under Discussion
  • In Progress
  • Completed
  • Rejected
  • Deferred


SLD provides the ability to reference multiple layers from a single GeoServer using NamedLayers. This is currently supported by GetMap in GeoServer (using an external style URL in your GetMap request).

This proposal makes this multi-layer SLD functionality accessible to a wider range of users through a modification to the GeoServer layer and layer group data model.


Add a new method of defining layers in layer groups, referred to as a "style group". For this case, the "layer" entry would be null, and the style would be relied upon to define the layers included:

  1. Add support for style groups to the Layer Groups page in the Web UI: Add an "Add Style Group..." button after the existing "Add Layer..." and "Add Layer Group..." buttons.

    • Rather than bringing up a dialog, this button will just add a style group to the layers list.

    • The text "Style Group" (italicized, to differentiate it from a proper layer name) will show up under the Layer column. A null or default style will be equivalent to no style, and will show the text "Choose Style..." in the Style column.

    • Also add an (i) informational popup describing what a Style Group is and how it works.


  2. Add support for this new functionality to the GeoServer style editor

    Add a "Style Group" option to the select preview layer dialog, which uses the WMS external SLD parameter to preview a style defining multiple named layers. This is technically entirely independent of the work necessary to add "Style Group" support, but will allow previewing styles as if they were being used as a StyleGroup or an external style.

  3. Add support for Style Groups to the layergroups REST API endpoint, e.g.



(The empty layer should be interpreted as null, and treated as a style group).

  1. Make the necessary changes to GeoServer WMS to support this new collection of layers.

    • Add logic to and to handle Layer Groups being defined by a Style parameter.
         // ok, parse the styles parameter in isolation
         if (styleNameList.size() > 0) {
             List<Style> parseStyles = parseStyles(styleNameList);
    • After getting the list of styles add a method to process the styles, adding MapLayerInfo and Style to the WMS request for each NamedLayer.
    • If a style group refers to an invalid layer, it should throw a ServiceException, to match with the current treatment of layer groups.
  2. Add new validation for handling style groups / styles with named layers. For both these cases, it does not matter if the style is used as a style group, only that it has named layers.

    • Add a validation step for when layers are renamed or deleted.
      • In the UI, this will present itself as a dialog allowing the user to either rewrite the style, updating the name of the layer (Keeping a copy of the old style in the data directory for reference) or leaving the style as-is, to be updated by hand layer.
      • In the Rest API, this will present itself as a failure if such a rename or deletion would invalidate such a style. A new parameter ("styleUpdateStrategy") will be added allowing users to define a resolution strategy ("rewrite" style or "ignore"). The failure message will provide basic usage information for this parameter.
    • Add a new validation step for saving styles with named layers, which verifies that the named layers exist.

Using Style Groups

  1. Create (or upload) a new SLD file containing multiple NamedLayers and associated styles (See "Use of Multi-Layered SLD Files in GeoServer" below for an example of such an SLD). For the purposes of this example, this will be named "multilayer_style"

  2. Add a new layer group (named "lg_stylegroup"), and create a Style Group within it.

    1. To do this using the UI, got to the Layer Groups page, and click add layer group, and fill in the standard details. To add the style group, click New Style Group. Set the style for this entry to "multilayer_style" Associate your style with this Style Group, and save the layer group.


    2. Using the REST API, POST the following to the /layergroups endpoint:

    3. Optionally, you may add regular layers and layergroups to the "lg_stylegroup" layergroup alongside the style group.

  3. You will now be able to refer to "lg_stylegroup" in the LAYERS list of a WMS request. This will render a layer using the layers and styles defined in the "multilayer_style". Unlike using the SLD parameter, you can use additional layers alongside this one. For instance, you might define a basemap using a style group, and render addition layers on top of it.

    Like other layer groups, you can also view this one using the layer preview.

Backwards Compatibility

This change is additive-only, so there should be no backwards compatibility concerns.



Project Steering Committee:

  • Alessio Fabiani:
  • Andrea Aime: +1
  • Ben Caradoc-Davies: +1
  • Brad Hards: +1
  • Christian Mueller:
  • Ian Turton: +1
  • Jody Garnett: +1
  • Jukka Rahkonen: +1
  • Kevin Smith: +1
  • Simone Giannecchini: +0


Use of Multi-Layered SLD Files in GeoServer

(This represents existing functionality, which this GSIP is based on)

The following StyleLayerDescriptor document defines styling for an entire map, we do not generally use SLD in this fashion in the GeoServer codebase - but the functionality is supported by the WMS GetMap operations.


Resulting in the following output:


Here is the reference multilayer_style.sld used for the above image:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0" xmlns="" xmlns:ogc=""
  xmlns:xlink="" xmlns:xsi=""
      <Title>Blue lake</Title>
      <Abstract>A blue fill, solid black outline style</Abstract>
              <CssParameter name="fill">
              <CssParameter name="fill-opacity">
              <CssParameter name="stroke">
              <CssParameter name="stroke-linecap">
              <CssParameter name="stroke-linejoin">
              <CssParameter name="stroke-opacity">
              <CssParameter name="stroke-width">
              <CssParameter name="stroke-dashoffset">

      <Title>Default Styler for simple road segments</Title>
      <Abstract>Light red line, 2px wide</Abstract>
              <CssParameter name="stroke">
              <CssParameter name="stroke-width">
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.