-
Notifications
You must be signed in to change notification settings - Fork 1
GSIP 161
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.
Torben Barsballe, David Vick
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 type of LayerGroup entry that uses a style to define the layers included:
-
Add support for StyleGroupInfo 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 StyleGroupInfo is and how it works.

-
-
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.
-
Add support for StyleGroupInfo to the
layergroupsREST API endpoint, e.g.PUT
<layerGroup> <name>nyc</name> <layers> <styleGroup></styleGroup> <layer>parks</layer> </layers> <styles> <style>roads_style</style> <style>polygon</style> </styles> </layerGroup> -
Create a new class extending PublishedInfo, called "StyleGroupInfo", which to be used as a member of a LayerGroupInfo.
- This class will act as a marker, indicating that the contained layers will be defined by the associated style.
- Instances of StyleGroupInfo will not be stored as catalog objects (similar to how LegendInfo is handled). This also means that standalone instances of this class will not exist; they will only exist as members of a layer group.
- In a LayerGroup, if no style is associated with an instance of StyleGroupInfo, then will not contribute any layers to the LayerGroup (it will be in effect empty).
- Because all configuration is defined by the associated style, only a single instance of StyleGroupInfo is required (as a placeholder or marker instance it can be shared among all layer groups).
- Any number of StyleGroupInfo can be included in a layer group.
The StyleGroupInfo implementation of the PublishedInfo interface will be more similar to a nested LayerGroupInfo than LayerInfo, except that it will not have contents (layers or styles). Namely, getType() will return
PublishedType.GROUP. Methods such as setMetadataLinks will necessarily have no effect, since StyleGroupInfo will not be stored in the catalog. -
Make the necessary changes to GeoServer WMS to support this new collection of layers.
- Add logic to GetMapKvpRequestReader.java and GetMapXmlReader.java 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); getMap.setStyles(parseStyles); }
- After getting the list of styles add a method to process the styles, adding MapLayerInfo and Style to the WMS request for each NamedLayer.
This change is additive-only, so there should be no backwards compatibility concerns.
Project Steering Committee:
- Alessio Fabiani:
- Andrea Aime:
- Ben Caradoc-Davies:
- Brad Hards:
- Christian Mueller:
- Ian Turton:
- Jody Garnett:
- Jukka Rahkonen:
- Kevin Smith:
- Simone Giannecchini:
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.
http://localhost:8080/geoserver/topp/wms?
service=WMS&
version=1.1.0&
request=GetMap&
SLD=http://localhost:8080/geoserver/styles/multilayer_style.sld&
bbox=145.19754,-43.423512,148.27298000000002,-40.852802&
width=768&
height=641&
srs=EPSG:4326&
format=application/openlayers
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="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>topp:tasmania_water_bodies</Name>
<UserStyle>
<Title>Blue lake</Title>
<Abstract>A blue fill, solid black outline style</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>name</Name>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">
<ogc:Literal>#f0f0C0</ogc:Literal>
</CssParameter>
<CssParameter name="fill-opacity">
<ogc:Literal>1.0</ogc:Literal>
</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">
<ogc:Literal>#000000</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-linecap">
<ogc:Literal>butt</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-linejoin">
<ogc:Literal>miter</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-opacity">
<ogc:Literal>1</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-width">
<ogc:Literal>1</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-dashoffset">
<ogc:Literal>0</ogc:Literal>
</CssParameter>
</Stroke>
</PolygonSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
<NamedLayer>
<Name>topp:tasmania_roads</Name>
<UserStyle>
<Title>Default Styler for simple road segments</Title>
<Abstract>Light red line, 2px wide</Abstract>
<FeatureTypeStyle>
<Rule>
<Title>Roads</Title>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">
<ogc:Literal>#AA3333</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-width">
<ogc:Literal>2</ogc:Literal>
</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>©2020 Open Source Geospatial Foundation