Usage of SLD |
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.
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:
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:
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). |
The Service Layer Style Description (SLD) rule of WMS 1.0.0 service published by iServer supports three types of Filters, including comparison operator, spatial operator and logical operator, which are used to set the style used by specified features in point, line and polygon layers, so as to render the layers in the service as single-value thematic maps, segmented thematic maps or filter out maps according to spatial query conditions. The currently supported Filter types are as follows:
Note:
1. The <DWithin> operator is only supported in services published from a workspace that includes PostGIS data sources.
2. Logical operators are currently only supported in conjunction with comparison operators to express attribute value ranges for segmenting thematic maps.
Take single-value thematic maps, segmented thematic maps, and multi-rule single-spacical queries as examples to illustrate the use of operators:
1. Single-value thematic map
Render the specified style of polygon features in designated provinces such as Anhui, Jiangsu, and Hubei in the water polygon layer. The SLD is as follows:
Among them, the <ogc:PropertyIsEqualTo>operation symbol is used to specify the provincial polygon elements that match the name.
2. Segmented thematic map
Render the specified style of the province polygon features of different area sizes in the water polygon layer. The SLD file is as follows:
Among them, <ogc:And>, <ogc:PropertyIsGreaterThan>and <ogc:PropertyIsLessThan>specify the province polygon features that fit the interval of area.
Please note: When defining attribute intervals for a range thematic map, you must define at least two rules to desrcibe the interval, and the lower limit must be defined. The upper and lower values of each adjacent interval must be the same.
3. Multi-rule single-spacial query
Query province polygon features that intersect, overlap, or are adjacent to specified line and polygon features in the water polygon layer, and apply a specified styling in SLD as follows:
Among them, through <Intersects>, <Touches> and <Overlaps> specify the polygon features that conform to the spatial relationship.