DM Solutions Group Inc.
|
Revision History |
||
|
Revision 1.00 |
2004-03-10 |
YA |
|
initial draft |
||
|
Revision 1.01 |
2004-03-12 |
DR |
|
edit and DocBook translation |
||
Abstract
This document describes the procedures for taking advantage of the Styled Layer Descriptor (SLD) support in WFS GetMap requests that has been added to MapServer 4.1.
Last Updated: 2004-03-12
Table of Contents
Links to SLD-related Information
Specific SLD Elements Supported
Issues Found During Implementation
Copyright/Licensing Information
|
|
"However, while a WMS currently can provide the user with a choice of style options, the WMS can only tell the user the name of each style. It cannot tell the user what portrayal will look like on the map. More importantly, the user has no way of defining their own styling rules. The ability for a human or machine client to define these rules requires a styling language that the client and server can both understand. Defining this language, called the StyledLayerDescriptor (SLD)..." |
|
|
--Styled Layer Descriptor Implementation Specification, OGC |
|
|
SLD support has been developed for the server side support (ability to read an SLD and apply it with a GetMap request) and for the client side (includes sending SLD requests to server and generate SLD files on the fly from MapServer map file).
This document assumes that you are already familiar with the following aspects of MapServer:
· MapServer application development and setting up .map files.
· Familiarity with the WFS specification would be an asset. A link to the WFS specification document is included in the Links to SLD-Related Information section below.
· Styled Layer Descriptor Implementation Specification at http://www.opengis.org/docs/02-070.pdf.
· Open GIS Consortium (OGC) home page at http://www.opengis.org/.
· MapServer WFS Server HOWTO at http://mapserver.gis.umn.edu/doc40/wfs-server-howto.html.
This section describes how to use FE on both the server and client sides.
There are two ways a WMS request can pass an SLD document with a GetMap request to MapServer:
· SLD parameter pointing to remote SLD (SLD=http://URL_TO_SLD).
· SLD_BODY parameter to send the SLD definition in the URL.
These two methods are both available through MapServer. An example of a request would be:
http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1
&Request=GetMap&LAYERS=WorldGen_Outline
&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_simple.xml
When MapServer gets a valid SLD through a request, it parses this SLD to extract all the styles attached to the NamedLayers, and then it applies these styles to the map before it is returned to the client. When applying the SLD, MapServer compares the names used in the map files with the names of the NamedLayers in the SLD document.
Note : All the examples given in this document use valid SLDs and a MapServer with SLD support installed on DM Solutions site.
Additional WMS features related to SLDs have also been developed:
Table 1. Additional WMS Features
|
Features |
Supported |
Notes |
|
Method GET : SLD URL |
Yes |
|
|
Method GET : SLD_BODY |
Yes |
. |
|
Describer Layer |
Yes |
|
|
GetLegendGraphic |
Yes |
|
|
GetStyles |
Yes |
|
The following tables give a lot of additional details about SLD support in MapServer.
·
Table 2. Named Layers and User Layers
|
Features |
Supported |
Notes |
|
Named Layers |
Yes |
|
|
User Layers |
No |
|
·
Table 3. Named Styles and User Styles
|
Features |
Supported |
Notes |
|
Named Styles |
No |
|
|
User Styles |
Yes |
|
·
Table 4. User Styles
|
Features |
Supported |
Notes |
|
Name |
No |
This was removed at implementation time, since it does not fit with MapServer. |
|
Title |
No |
No use in the MapServer environment. |
|
Abstract |
No |
No use in the MapServer environment. |
|
IsDefault |
No |
Only one style is available per layer. |
|
FeatureTypeStyle |
Yes |
MapServer has a concept of one feature type style per layer (either point, line, polygon, or raster). |
·
Table 5. FeatureTypeStyle
|
Features |
Supported |
Notes |
|
Name |
No |
No use in the MapServer environment. |
|
Title |
No |
No use in the MapServer environment. |
|
Abstract |
No |
No use in the MapServer environment. |
|
FeatureTypeName |
No |
No use in the MapServer environment. |
|
SemanticTypeIdentifier |
No |
Still an experimental element in the SLD specifications. |
|
Rule |
Yes |
|
·
Table 6. Rule
|
Features |
Supported |
Notes |
|
Name |
Yes |
|
|
Title |
Yes |
|
|
Abstract |
No |
No use in the MapServer environment. |
|
LegendGraphic |
Yes |
|
|
Filter |
Yes |
|
|
ElseFilter |
Yes |
|
|
MinScaleDenominator |
Yes |
|
|
MaxScaleDenominator |
Yes |
|
|
LineSymbolizer |
Yes |
|
|
PolygonSymbolizer |
Yes |
|
|
PointSymbolizer |
Yes |
|
|
TextSymbolizer |
Yes |
|
|
RasterSymbolizer |
Yes |
Applies for 8-bit rasters. |
· Filter and ElseFilter
For each rule containing a filter, there is a
class created with the class expression set to reflect that filter. Please check
the OGC Filter Encoding support in Mapserver for Filters supported (JEFF :
Need a link here to the Filter Encoding document)
The ElseFilter parameters are converted into a class in MapServer and placed at the end of the class list with no expression set. They are used to render elements that did not fit into any other classes.
· MinScaleDenomibator and MaxScaleDenominator are translated in minscale and maxscale in MapServer.
The following are examples of valid requests using the Filters:
· line with one filter: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline
&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_one_filter.xml
· line with multiple filters: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline
&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_multi_filter.xml
· line with one filter and an else filter: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline
&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_one_filter_and_else.xml
·
Table 7. LineSymbolizer
|
Features |
Supported |
Notes |
|
Geometry |
No |
MapServer uses the data geometry to do the rendering. |
|
Stroke: GraphicFill |
No |
Solid color is used. |
|
Stroke: GraphicStroke |
No |
Solid color is used. |
|
Stroke (CssParameter): stroke |
Yes |
RGB colors are supported. |
|
Stroke (CssParameter): width |
Yes |
|
|
Stroke (CssParameter): opacity |
No |
Not supported in MapServer. |
|
Stroke (CssParameter): linejoin and linecap |
No |
Not supported in MapServer. |
|
Stroke (CssParameter): dasharray |
Yes |
|
|
Stroke (CssParameter): dashoffset |
No |
|
· The following are examples of valid requests using the LineSymbolizer:
· Simple line: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline&SLD=htp://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_simple.xml · Line with width: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_width.xml
· Dash line: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen_Outline&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_line_dash.xml ·
Table 8. PolygonSymbolizer
|
Features |
Supported |
Notes |
|
Geometry |
No |
|
|
Stroke |
Yes |
Strokes are the same as for the LineSymbolizer. |
|
Fill |
Yes |
Was developed to support symbol fill polygons in addition to solid fill. |
A Fill can be a solid fill or be a Graphic Fill, which is either a well-known Mark symbol (e.g., square, circle, triangle, star, cross, x) or an ExternalGraphic element (e.g., gif, png) available through a URL.
When a Mark symbol is used in an SLD, MapServer creates a corresponding symbol in the map file and uses it to render the symbols.
When a ExternalGraphic is used, the file is saved locally and a pixmap symbol is created in the mapfile referring to the this file. Note that the Web object IMAGEPATH is used to save the file.
The following are examples of valid requests using the PolygonSymbolizer:
· Simple solid fill: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen&SLD=http://www.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_polygon_solid_fill.xml · Solid fill with outline: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen&SLD=http://www.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_polygon_solid_fill_outline.xml· Fill with mark symbol: http://www2.dmsolutions.ca/cgi-n/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_polygon_fill_symbol.xml · Fill with external symbol: http://www2.dmsolutions.ca/cgi-in/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldGen&SLD=http://www2.msolutions.ca/msapps/world_testdata/tests/sld_tests/sld_polygon_fill_symbol_external.xml
·
Table 9. PointSymbolizer
|
Features |
Supported |
Notes |
|
Geometry |
No |
|
|
Graphic: Mark symbol |
Yes |
Well-known names (square, circle, triangle, star, cross, X) are supported. |
|
Graphic: ExternalGraphic |
Yes |
Was developed to support symbol fill polygons in addition to solid fill. |
|
Opacity |
No |
Not supported in MapServer. |
|
Size |
Yes |
Not supported in MapServer. |
|
Rotation |
No |
Not supported in MapServer. |
Note: Refer to the PolygonSymbolizer notes for how the Mark and ExternalGraphic symbols are applied in MapServer.
The following are examples of valid requests using the PointSymbolizer:
· Filled mark symbol: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldPOI&BBOX=84.7978536015,41.440374,-75.737539764,45.97524&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_symbol.xml · Default settings (square, size 6, color 128/128/128):http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldPOI&BBOX=84.7978536015,41.440374,-75.737539764,45.97524&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_symbol_default_settings.xml
· External symbol: http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldPOI&BBOX=-84.7978536015,41.440374,-75.737539764,45.97524&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_symbol_external.xml ·
Table 10. TextSymbolizer
|
Features |
Supported |
Notes |
|
Geometry |
No |
|
|
Label |
Yes |
|
|
Font(font-family) |
Yes |
Font names used are those available in MapServer font file. If no fonts are available there, default bitmap fonts are used. |
|
Font-style (Italic, ...) |
Yes |
|
|
Font-weight |
Yes |
|
|
Font-size |
Yes |
If true-type fonts are not used, default bitmap sizes are given. |
|
LabelPlacement |
Yes |
Only PointPlacement is supported. |
|
Halo |
No |
Only solid color is available. |
|
Fill |
No |
Only solid color is available. |
· Notes on the TextSymbolizer:
· Font names: when converting Font parameters to MapServer, the following rule is applied to get the font name: FontFamily-FontStyle-FontWeight.
For example, if there is an SLD with a Font Family of arial, a Font Style of italic, and a Font weight equal to bold, the resulting MapServer font name is arial-italic-bold.
Font Style and Weight are not mandatory and, if not available, they are not used in building the font name.
When a Font Style or a Font Weight is set to normal in an SLD, it is also ignored in building the name. For example, if there is an SLD with a Font Family of arial, a Font Style of normal and a Font weight equals to bold, the resulting MapServer font name is arial-bold.
· A TextSymbolizer can be used in MapServer either on an Annotation layer or on a Point, Line, or Polygon layer - in addition to other symbolizers used for these layers.
· PointPacement: a point placement includes AnchorPoint (which is translated to Position in MapServer) Displacement (which is translated to Offset) and Angle (which is translated to Angle).
The following are examples of valid requests using the TextSymbolizer:
· Annotation layer : test for label, font, point placement, color, angle:http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldPlaces&BBOX=-81.366241839,42.39269586,-77.8780568047,44.13861927&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_text_annotation.xml
· Annotation layer with text and symbols using 2 symbolizers:http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldPlaces&BBOX=81.366241839,42.39269586,-77.8780568047,44.13861927&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_text_with_symbols.xml
· Line layer with text using 2 symbolizers:http://www2.dmsolutions.ca/cgi-bin/mswms_world?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=WorldRoads&BBOX=-81.366241839,42.39269586,-77.8780568047,44.13861927&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_text_line.xml
·
Table 11. RasterSymbolizer
|
Features |
Supported |
Notes |
|
Geometry |
No |
|
|
Opacity |
Yes |
|
|
ChannelSelection |
No |
|
|
OverlapBehaviour |
No |
|
|
ColorMap |
Yes |
|
|
ContrastEnhancement |
No |
|
|
ShadedRelief |
No |
|
|
ImageOutline |
No |
|
The current support in MapServer includes only ColorMap parameter support. It can be used to classify 8-bit or 16 bits rasters. Inside the ColorMap parameters, the color and quantity parameters are extracted and used to do the classification.
·
Table 12. ColorMap
|
Features |
Supported |
Notes |
|
Color |
Yes |
|
|
Opacity |
No |
|
|
Quantity |
Yes |
|
|
Label |
No |
|
The following is an example of ColorMap usage.
If we have following ColorMap in an SLD:
<ColorMap>
<ColorMapEntry color="#00ff00" quantity="22"/>
<ColorMapEntry color="#00bf3f" quantity="30"/>
<ColorMapEntry color="#007f7f" quantity="37"/>
<ColorMapEntry color="#003fbf" quantity="45"/>
<ColorMapEntry color="#0000ff" quantity="52"/>
<ColorMapEntry color="#000000" quantity="60"/>
</ColorMap>
there will be six classes that are created are:
· class 1 : [pixel] >= 22 AND [pixel] < 30 with color 00ff00
· class 2: [pixel] >= 30 AND [pixel] < 37 with color 00bf3f
· class 3 : [pixel] >= 37 AND [pixel] < 45 with color 007f7f
· class 4: [pixel] >= 45 AND [pixel] < 52 with color 003fbf
· class 5: [pixel] >= 52 AND [pixel] < 60 with color 0000ff
· class 6: [pixel] = 60 with color 000000
Note that the ColorMapEntry quantity parameters should be in increasing order.
Examples using 8 bits and 16 bits rasters can be seen at:
- http://www2.dmsolutions.ca/cgi-bin/mswms_landsat2?SERVICE=WMS&VeRsIoN=1.1.1&Request=GetMap&LAYERS=golden_CO&SLD=http://www2.dmsolutions.ca/msapps/world_testdata/tests/sld_tests/sld_raster_16bits.xml
Client side support of the SLD consists of two parts:
· The first part is using MapServer as a WMS client to send a GetMap request with an SLD. This is done using two metadata that can be placed at a layer level in a MapServer mapfile. These two metadata are:
· wms_sld_url, which takes a valid URL as a value and appends SLD=xxx to the GetMap request.
· wms_sld_body, which takes a valid SLD string and appends SLD_BODY=xxx to the GetMap request. If the value of wms_sld_body is set to AUTO, MapServer generates an SLD based on the classes found in the layer and send this SLD as the value of the SLD_BODY parameter in the GetMap request.
· The other major item is the generation of an SLD document from MapServer classes. These functions are currently available through MapServer/MapScript interface. Here are the functions available:
· On a map object: genratesld
· On a layer object: generatesld
Additional MapScript functions have been added or will be added to complement these functions:
· On a map object: applysld
· On a layer object: applysld
Note: When generating an SLD from MapServer classes, if there is a pixmap symbol you need to have this symbol available through a URL so it can be converted as an ExternalGraphic symbol in the SLD. To do this, you need to define the URL through a web object level metadata called WMS_SLD_SYMBOL_URL in your map file. The SLD generated uses this URL and concatenates the name of the pixmap symbol file to get the value that is generated as the ExternaGraphic URL.
· Support of filled polygons with Mark and ExternalGraphic symbols.
· MapScript functions to parse and apply SLD.
· SLD_BODY request support on client and server side.
· Limitation of the FilterEncoding to comparison and logical filters. The spatial filters were not made available since it required major changes in MapServer WMS support.
Copyright (c) 2004, Yewondwossen Assefa, DM Solutions Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Send any comments or suggestions to the author.