[FrontPage] [TitleIndex] [WordIndex

WMS GetMap request with SLD

1. Introduction

The present description on GetMap requests with SLD will only highlight some small selection of possibilities. This should give an opportunity to grasp the idea of using style descriptions to influence the display of the resulting map when requesting it from the WMS server. It is not intended to replace a thorough study of the relevant OGC specifications (as given below). For further options not mentioned here, please work with the OGC documents directly or look at HowToSLD and HowToSE.

2. Relevant OGC Standards

There are several OGC specifications working together when requesting a map from a WMS with a (user)specific style.

The relevant versions when using deegree2 are: WMS 1.1.1/1.3.0, SLD 1.0.0, Filter Encoding 1.0.0.

3. HTTP Get Requests (KVP)

In a simplified explanation, a HTTP Get requests are what you type in the browsers address field, using a number of key-value pairs (KVP). An easy example is the WMS GetCapabilities request:

This request contains the service address:

and 3 key value pairs:

There are two different options for defining a WMS GetMap request with SLD. One makes use of the key SLD, the other uses the key SLD_BODY. Both ways are described below.

3.1. HTTP Get with SLD

A WMS GetMap request with the key "SLD" will expect a URL as value. This URL needs to contain a full SLD document. An example:

This mode is very easy to read, as you only need to specify an URL, where your SLD document may be found. It is up to you whether you prefer to provide a web URL or a file URL. You just have to make sure that you can access the SLD under the specified address.

Next thing you need is the SLD document itself, which you will place at the above URL. One possible SLD example is given below:

3.2. HTTP Get with SLD_BODY

If you want to send a GetMap request using the key SLD_BODY then you need an SLD document as the example above. Then you need to URL-encode this SLD (by using on of the many URL Decoder/Encoder in the internet). Then you can add this URL encoded SLD to the GetMap request and get something looking like this:

This is very hard to read, but it is exactly the same SLD as in the first example. The resulting map, of course, is also the same.

3.3. Comparison of SLD and SLD_BODY

One problem with SLD_BODY is that the request is getting very long. Some browsers have difficulties to send HTTP-Get requests that are longer than about 1000 characters. Since the URL encoding transforms each "<" to a "%3C" this is an increase in characters from 1 to 3. Just imagine to add a second or even third layer to the request. You would soon run into the browser-specific constraints on request lengths.

Another problem with SLD_BODY is the reduced readability and the extra step of URL-encoding the SLD. If you want to add or change something in the SLD, you need to first URL-decode the already encoded fragment, then apply your changes, and then again URL-encode the SLD.

Therefore it is recommendable to use the key SLD instead of SLD_BODY.

4. HTTP Post Requests

It is also an option to send HTTP Post requests to a WMS. This can for example be accomplished with the generic client of that is part of every deegree web sercvice installation. Point your browser to:

and you will be able to send WMS GetMap requests as HTTP Post requests.

5. Examples for HTTP Get with SLD 1.1.0

Here you can find some examples for SLDs in WMS GetMap request based on the utah demo.


CategoryDeegree2 CategoryDeegree3 CategoryHowTo


2018-04-20 12:04