-
Notifications
You must be signed in to change notification settings - Fork 1
GSIP 161
Extend the LayerGroup model to enable defining a LayerGroup by referencing a style which uses one or more NamedLayers. This functionality "exists" currently when making WMS requests and referencing external styles using the SLD parameter. This GSIP proposes to promote this capability to "1st class citizenship" by adding a new type of LayerGroup entry that delegates to the Style to get the details on the layers included.
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. While this is currently supported in GeoServer by using an external style in your WMS request, tying this functionality into the GeoServer WMS layer handling makes it more accessible, and allows us to reference additional layers in the WMS request alongside those referenced by such an SLD.
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 provided by the associated style.
- Instances of StyleGroupInfo will not be stored as catalog objects (similar to LegendInfo). This also means that standalone instances of this class will not exist; they will only exist as members of a layer group.
- If no style is associated with an instance of StyleGroupInfo, then it will behave as an empty layer group.
- Given that all configuration is stored in the style, only a single instance of StyleGroupInfo among all layer groups will be necessary.
- Any number of Style Groups are permissible in a layer group.
The StyleGroupInfo implementation of the PublishedInfo interface will be more similar to 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