Skip to content

wms

WMS 1.3

Web Map Service support: capabilities documents, map images, and attribute queries. Parsing and response generation live in qgis_render::server::wms; the server module drives it.

use qgis_render::server::{Server, WmsRequest};
let response = server.handle_wms(WmsRequest::parse(query_string)?)?;

Requests

REQUESTPurposeResponse
GetCapabilitiesDescribe the service, layers, CRS, and bounding boxes.XML
GetMapRender a map image for a bounding box.image/png, image/jpeg, image/svg+xml
GetFeatureInfoReturn attributes at a clicked pixel.JSON, XML, or HTML

GetMap parameters

ParameterExampleDescription
LAYERSbuildings,roadsComma-separated layer names.
STYLES,One entry per layer; empty means default styling.
CRSEPSG:3857Output CRS.
BBOX14,50,15,51Extent in the requested CRS.
WIDTH / HEIGHT1024 / 768Image size in pixels.
FORMATimage/pngOutput encoding.
TRANSPARENTTRUEPreserve alpha.
BGCOLOR0xFFFFFFBackground colour when not transparent.
DPI96Label and symbol scaling.
Terminal window
curl -o map.png 'http://localhost:8080/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap' \
--data-urlencode 'LAYERS=buildings,roads' \
--data-urlencode 'STYLES=,' \
--data-urlencode 'CRS=EPSG:3857' \
--data-urlencode 'BBOX=6300000,6400000,1600000,1700000' \
--data-urlencode 'WIDTH=1024' --data-urlencode 'HEIGHT=768' \
--data-urlencode 'FORMAT=image/png' \
-G

GetFeatureInfo

Terminal window
curl -G 'http://localhost:8080/wms' \
--data-urlencode 'SERVICE=WMS' --data-urlencode 'VERSION=1.3.0' \
--data-urlencode 'REQUEST=GetFeatureInfo' \
--data-urlencode 'LAYERS=buildings' --data-urlencode 'QUERY_LAYERS=buildings' \
--data-urlencode 'CRS=EPSG:3857' \
--data-urlencode 'BBOX=6300000,6400000,1600000,1700000' \
--data-urlencode 'WIDTH=1024' --data-urlencode 'HEIGHT=768' \
--data-urlencode 'I=512' --data-urlencode 'J=384' \
--data-urlencode 'INFO_FORMAT=application/json'

I and J are the pixel to query. The response lists every feature whose rendered geometry covers that pixel, with the fields the layer exposes.

Axis order

Errors

Service exceptions come back as 200 with an XML ServiceExceptionReport, which is what the specification requires:

<ServiceExceptionReport version="1.3.0">
<ServiceException code="LayerNotDefined">Unknown layer: roads</ServiceException>
</ServiceExceptionReport>

WmsRequest::parse returns Err(QgisError::...) only for malformed query strings.

See also