Usage of SLD

Feedback


SLD (Styled-Layer Descriptor) defines various style schemes that can symbolize WMS services, including WMS service predefined style schemes and client-customized style schemes. The predefined styles (STYLES) are SLDs built into the WMS service and are represented as Capabilities <Style> node in an XML document. In addition to the WMS service's predefined styles, the client can apply a custom SLD to the WMS service to render the layer. The user can pass the GetMap operation adds the appropriate parameters to use SLD, SuperMap iServer currently supports SLD functionality in WMS 1.1.1, which allows you to configure SLD information for point, line, surface, and text layers. The usage of the two styles is described as follows:

The SLD file is in XML format and follows the OGC SLD standard , making it understandable to both servers and clients. Multiple SLD styles can be defined in one SLD file. The SLD style defines the symbolization rules for the specified WMS layer. A style can have multiple rules, each rule can include a filter to describe which features to render, and multiple symbolizers to describe how to render these features.

Use predefined STYLES

The predefined STYLES are built into the WMS service and are represented as <Styles> node in the Capabilities XML document. For publishing the STYLES that SLD predefines for the SuperMap iServer service, see Add WMS Service Interfaces. Predefined STYLES via STYLES=style_list parameter pair request, and the request method is as follows:

<ServiceRoot>?VERSION=version&REQUEST=GetMap&LAYERS=&STYLES=&SRS=&BBOX=&WIDTH=&HEIGHT=&FORMAT=

ServiceRoot is the URI root directory of the service. Please refer to URI Settings .

By default, SuperMap iServer includes an SLD file for rendering face layers: %SuperMap iServer_HOME%\webapps\iserver\WEB-INF\config\region.sld, with the name World Style, starting the iServer service publishes it as a predefined STYLE. After the native SuperMap iServer WMS 1.1.1 service is started successfully, use this style of the URI of the GetMap request is: http://localhost:8090/iserver/services/maps/wms111/WorldMap_Day?VERSION=1.1.1&REQUEST=GetMap&layers=0.11&STYLES=World&SRS=EPSG:4326&BBOX=-180.0,-90.0,180.0,90.0&WIDTH=800&HEIGHT=400&FORMAT=image/png, the response result of the request is as follows:

Use custom STYLES

The client can apply a custom SLD to the WMS service to render the layer. There are two ways to render a layer using a custom SLD:

The requested map is rendered by introducing the URI of the SLD document, i.e. add SLD=sld_xml_uri in the GetMap request. Where the sld_xml_uri must be accessible by the WMS server. The request is made as follows:

<ServiceRoot>?VERSION=version&REQUEST=GetMap&LAYERS=&STYLES=&SRS=&BBOX=&WIDTH=&HEIGHT=&FORMAT=&SLD=

ServiceRoot is the URI root directory of the service. Please refer to URI Settings .

The requested map is rendered by bringing in the actual content of the SLD document, i.e. adding SLD_BODY=sld_xml_body in the GetMap request, where the SLD_BODY=sld_xml_body must be URI-encoded. The request is made as follows:

<ServiceRoot>?VERSION=version&REQUEST=GetMap&LAYERS=&STYLES=&SRS=&BBOX=&WIDTH=&HEIGHT=&FORMAT=&SLD_BODY=

ServiceRoot is the URI root directory of the service. Please refer to URI settings .

The following is the content of an SLD document:

 <?xml version="1.0" encoding="UTF-8"?>

<sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"

        xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"

        xmlns:gml="http://www.opengis.net/gml" version="1.0.0">

        <sld:UserLayer>

                <sld:UserStyle>

                        <sld:Name>lineStyle</sld:Name>

                        <sld:FeatureTypeStyle>

                                <sld:FeatureTypeName>Feature</sld:FeatureTypeName>

                                <sld:Rule>

                                        <sld:LineSymbolizer>

                                                <sld:Stroke>

                                                        <sld:CssParameter name="stroke">#0000FF

                                                        </sld:CssParameter>

                                                        <sld:CssParameter name="stroke-width">0.1</sld:CssParameter>

                                                </sld:Stroke>

                                        </sld:LineSymbolizer>

                                </sld:Rule>

                        </sld:FeatureTypeStyle>

                </sld:UserStyle>

        </sld:UserLayer>

</sld:StyledLayerDescriptor>

An example of a GetMap request using the above SLD_BODY is:

The response to this request is as follows, and you can see that the line layer OceanBoundary@World is rendered in blue:

Matching rules for STYLES and SLD/SLD_BODY.

In the GetMap request, the user can specify either the STYLES parameter or the SLD (SLD_BODY) parameter. The matching rules for the two parameters are shown in the following table.

Table 1 The matching relationship between STYLES and SLD/SLD_BODY in GetMap request;

Does the request include the STYLES=style_list parameter pair Does the request include the SLD=sld_xml_uri(SLD_BODY=sld_xml_body) parameter pair Does the style name in STYLES match the style name in SLD (SLD_BODY) How to render the WMS map

Yes

No

  Use the style in STYLES to render the corresponding layer in LAYERS=layer_list.

Yes

Yes

Yes

Use the style in SLD(SLD_BODY) to render the corresponding layer in LAYERS=layer_list.

Yes

Yes

No

Use the style in STYLES=style_list to render the corresponding layer in LAYERS=layer_list.

No

Yes

  The named layer must be included in the SLD(SLD_BODY), and the style rendering in the SLD(SLD_BODY) is used The layer identified by named layer in the SLD(SLD_BODY).