Skip to content

Commit ade6696

Browse files
committed
Update WMS exercise
1 parent 1b01dca commit ade6696

File tree

3 files changed

+49
-7
lines changed

3 files changed

+49
-7
lines changed

workshop/content/docs/outputs/wms.md

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,67 @@
22

33
## Overview
44

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.
66

7+
Full MapServer WMS documentation is available [here](https://www.mapserver.org/ogc/wms_server.html).
78

89
## METADATA Blocks
910

1011
Web services are configured using `METADATA` blocks. These are key-value pairs, for example:
1112

12-
1313
!!! tip
1414

1515
It is good practice to put the key names in quotes. This is not required, but it makes the Mapfile
1616
clearer that they are strings and not keywords. Keys can also contain strings such as field names, which
1717
could contain spaces. Without quotes these will cause syntax errors in the Mapfile.
1818

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+
<!--
1959
## Output Image Formats
2060
2161
+ webp
22-
62+
-->
2363

2464
## Exercises
2565

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.

workshop/exercises/app/js/stars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ const map = new Map({
2626
view: new View({
2727
projection: 'EPSG:4326',
2828
center: [0, 0],
29-
zoom: 4,
29+
zoom: 4
3030
}),
3131
});

workshop/exercises/mapfiles/polygons.map

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ MAP
2323
CONNECTION "data/osm/buildings_a.fgb"
2424
CLASSGROUP "offices" # we can switch the default set of CLASSes here
2525
CLASS
26+
NAME "Offices" # this value is used for Legend titles for the CLASS
2627
GROUP "offices"
2728
EXPRESSION ( "[type]" = "office" )
2829
STYLE
@@ -31,6 +32,7 @@ MAP
3132
END
3233
END
3334
CLASS
35+
NAME "Other"
3436
GROUP "other"
3537
STYLE
3638
COLOR 246 241 223

0 commit comments

Comments
 (0)