|
2 | 2 |
|
3 | 3 | ## Overview |
4 | 4 |
|
5 | | -We've been using WMS for the example so far. In this exercise we'll look in more detail at how to configure WMS services in MapServer. |
| 5 | +We've been using WMS for interacting with MapServer for Mapfile examples. In this exercise we'll look in more detail at how to configure WMS services in MapServer. |
6 | 6 |
|
| 7 | +Full MapServer WMS documentation is available [here](https://www.mapserver.org/ogc/wms_server.html). |
7 | 8 |
|
8 | 9 | ## METADATA Blocks |
9 | 10 |
|
10 | 11 | Web services are configured using `METADATA` blocks. These are key-value pairs, for example: |
11 | 12 |
|
12 | | - |
13 | 13 | !!! tip |
14 | 14 |
|
15 | 15 | It is good practice to put the key names in quotes. This is not required, but it makes the Mapfile |
16 | 16 | clearer that they are strings and not keywords. Keys can also contain strings such as field names, which |
17 | 17 | could contain spaces. Without quotes these will cause syntax errors in the Mapfile. |
18 | 18 |
|
| 19 | +Prefixes are used to configure different types of web service. For example: |
| 20 | + |
| 21 | +- `wms_` is used for WMS services, for example `"wms_title"` can be set in the `WEB` `METADATA` block to set the title of the WMS service. This will be seen when read with client applications such as QGIS. |
| 22 | +- `wfs_` is used for Web Feature Services. |
| 23 | +- `oga_` is used for the new [OGC Features API](ogcfeatures.md). |
| 24 | + |
| 25 | +!!! tip |
| 26 | + |
| 27 | + If settings are to be used for multiple services, then rather than duplicating values for `wms_`, `wfs_` etc. you can use the `ows_` prefix and these settings will apply to all open web services. You can still override this top-level setting for individual service types if needed. |
| 28 | + |
| 29 | + ```scala |
| 30 | + METADATA |
| 31 | + "ows_title" "My Services" # this will apply to WFS GetCapabilities requests |
| 32 | + "wms_title" "My WMS Services" # this will apply to WMS GetCapabilities requests |
| 33 | + END |
| 34 | + ``` |
| 35 | + |
| 36 | +## WMS Request Types |
| 37 | + |
| 38 | +There are several different types of WMS request. |
| 39 | + |
| 40 | +- `GetMap` - for returning map images |
| 41 | +- `GetLegendGraphic` for returning legend images |
| 42 | +- `GetCapabilities` for returning XML metadata of the WMS |
| 43 | +- `GetFeatureInfo` - for returning feature attributes at a query location |
| 44 | +- `DescribeLayer` - returns an XML description of the WMS layer(s) |
| 45 | + |
| 46 | +More details are in [the documentation](https://www.mapserver.org/ogc/wms_server.html#how-does-a-wms-work). |
| 47 | + |
| 48 | +## GetLegendGraphic |
| 49 | + |
| 50 | +A sample request for the legend for the `polygons.map` is as follows: |
| 51 | + |
| 52 | +- <http://localhost:5000/?map=/etc/mapserver/polygons.map&service=wms&version=1.3.0&request=GetLegendGraphic&layer=buildings&format=image/png&SLD_VERSION=1.1.0> |
| 53 | + |
| 54 | +!!! tip |
| 55 | + |
| 56 | + The names applied to the legends are based on the `CLASS` `NAME` in the Mapfile. If this is not set then no legend image is created for that layer. |
| 57 | + |
| 58 | +<!-- |
19 | 59 | ## Output Image Formats |
20 | 60 |
|
21 | 61 | + webp |
22 | | - |
| 62 | +--> |
23 | 63 |
|
24 | 64 | ## Exercises |
25 | 65 |
|
26 | | -1. If you've read this far you deserve to discover one of MapServer's Easter eggs. Try changing the output format to `&format=image` |
27 | | - |
28 | | -<https://demo.mapserver.org/cgi-bin/wms?version=1.3.0&request=GetMap&service=WMS&layers=cities&format=image/txt&crs=EPSG%3A4326&exceptions=XML&bbox=-90%2C-180%2C90%2C180&styles=&width=500&height=500&transparent=true> |
| 66 | +1. If you've read this far you deserve to discover one of MapServer's Easter eggs. Try changing the output format to `&format=image/txt`. We'll use the `polygons.map` for the request: <http://localhost:5000/?map=/etc/mapserver/polygons.map&service=wms&version=1.3.0&request=GetMap&layers=buildings&format=image/txt> |
| 67 | +2. Change the legend title for the `polygon map`. |
| 68 | +3. Run a [GetCapabilities](http://localhost:5000/?map=/etc/mapserver/polygons.map&service=wms&version=1.3.0&request=GetCapabilities) request for the `polygon.map`. Add various `METADATA` pairs to get rid of the warnings in the `GetCapabilities` response. |
0 commit comments