by Ian Miller, Information Technology Strategist
The Web Map Service (WMS) Open GIS standard provides a vendor-neutral means of publishing web-based mapping services, including the ability to request a map image for a chosen area and a set of map layers to be displayed. There are a number of software servers which implement the WMS standard including open source packages such as MapServer and GeoServer and vendor packages such as ESRI ArcIMS and MapInfo MapXtreme.
Most of these packages require that the symbology for each layer (i.e. the colors and styles used to present features) be defined in a package-specific format, typically in some form of "mapservice" file which specifies the map layers, their source, scale limits, names and symbology. The syntax for these files varies significantly between packages as does the nature and sophistication of the symbology which is supported.
The impact of the symbology being defined in a package-specific format is that even though we may be able to access WMS services in an "open" way, if we need to dynamically define symbology, we are forced to write code which is specific to the actual software providing the WMS service - somewhat defeating the purpose of the open standard in the first place!
The OGC Styled Layer Descriptor (SLD) specification, according to the Open Geospatial Consortium "extends the Web Map Service specification to allow user-defined symbolization of feature data. It allows users (or other systems) to determine which features or layers are rendered with which colors or symbols." SLD therefore provides an open-standards-based way to dynamically define symbology and allows us to avoid using package-specific formats. Applications are therefore able to (in theory at least) switch the underlying WMS server without needing to be re-coded.
In practice, a styled layer descriptor is an XML file which is specified in the WMS request, either directly or by providing a URL from which the XML file can be retrieved. The XML file specifies the layer(s) to which it applies and includes a series of rules which define a set of features and the symbology to be applied to them. A simple example is:
This example shows symbology being defined for a polygon layer. It has a single rule only, meaning that all polygons in the layer will be symbolised in the same way. The PolygonSymbolizer tag specifies the field which holds the polygons (GEOMETRY) and a simple fill with the color #ff0000, which gives the RGB values in hexadecimal - ie Red is ff (255) and both green and blue are zero.
When the WMS server applies this SLD, it will find a layer called "cma" and apply this symbology in place of that originally defined. The SLD can contain entries for many map layers, each in a separate NamedLayer tag. It is also possible to include multiple rules for a layer, each with a Filter tag to define the set of features they apply to. This allows you to set up thematic symbology based on the values of an attribute as shown in the sample below.
In this example, an attribute of the layer, FEATURECODE, is being used to select out each subset, with a different style being applied to each. You can also add an "ELSE" rule which can provide a default symbology for all features not specifically addressed preceding rules. You can, of course, include one or more rules but no ELSE section, as a way of displaying only a subset of features.
The samples shown here have included only very simple symbology but SLD is capable of quite sophisticated symbology including multi-layer symbols and text labelling with "halo"ing and various placement options. Note that you need to check what your particular WMS server supports - most packages do not support all SLD capabilities.
Support for the SLD standard is not currently widespread. ArcIMS at version 9.2 supports SLD for simple point, line, polygon and text symbology but does not support Filters or LegendGraphics. MapServer supports simple symbology, Filters and LegendGraphics.
GeoServer, the Java-based open source WMS/WFS server uses SLDs as its native symbology definition format and supports the same aspects of SLDs as does MapServer.
At Spatial Vision we have recently been implementing SLDs in a web mapping application which uses MapServer as the WMS server and the Internet Mapping Framework for OpenGIS (IMF-OWS) application framework from Moxi Media to develop the web interface.
This application has an extensive set of map layers whose symbology is fixed and which have been defined in the MapServer map file. There is one polygon layer however against which users enter many different scores and from these scores, a set of result values are calculated. Users need to be able to view this polygon layer symbolised by any of the scores or results.
One way of achieving this would have been to statically define some 30 additional layers, each showing the same polygon layer symbolised by a different score or result and each with the details of symbology hard coded in the map file. Instead of this, we defined the polygon layer only once in map file and allowed the user to select from a dynamic list which of the values they would like to symbolise the layer by.
IMF-OWS allows an SLD url to be set on a WMS request and we set this to the url of a Java Server Pages (JSP) script which would be called by MapServer and would dynamically generate the required SLD. The SLD url included the "id" of the value to be used. The JSP script queries the underlying database for the passed score id and retrieves the values and descriptions required for the SLD, then generates and returns the SLD content to MapServer.
The above may sound complex but in practice the user selects the desired score from the list, clicks Refresh Map and the map is redrawn with the updated symbology. A similar change to the script which generates the map legend ensures that the legend always reflects the dynamically selected symbology.
SLDs could be used to implement a number of other capabilities such as:
• Security/Privacy - generate an SLD with a FILTER clause based on the current user which hides features other than those the user is authorised to see
• User-defined symbology - build an interface to allow users to select the desired symbology from color pickers, lists etc and generate an SLD which implements the selected symbology
Some web resources to help you explore SLDs further:
• The SLD Specification from the Open Geospatial Consortium
• MapServertutorial on SLDs including some great examples of SLD requests and the results they produce:
• Details of ArcIMS 9.2 support for SLDs:
Note that, to date, there are no graphical SLD editors available and users must edit SLDs in an XML editor and deploy them to a working service in order to view the results - a somewhat time-consuming process. There is a software converter which can export symbology defined in ESRI ArcMap to SLD, developed by Albrecht Weiser as part of a thesis at the Institute for Spatial Information and Surveying Technology. Further details can be accessed at http://arcmap2sld.geoinform.fh-mainz.de/ArcMap2SLDConverter_Eng.htm - note that Spatial Vision has not used the software provided there.
There are some excellent web resources providing examples of SLD requests and the results - MapServer provides one at mapserver.gis.umn.edu



Technical Tips


I am working on a GIS application using Java and I want to consume WMS layers from a Geoserver. I can add the layers using GetCapability but I can not show them. As I try to show these layers both server and client applications reports errors.
Would you kindly recommand me what to do to overcome the problem.
Sincerely
Pooia Lalbakhsh