Skip to content

wfs

WFS 1.1

Web Feature Service support: feature-level access to vector layers as GML or GeoJSON. Parsing and response generation live in qgis_render::server::wfs; the server module drives it.

use qgis_render::server::{Server, WfsRequest};
let response = server.handle_wfs(WfsRequest::parse(query_string)?)?;
// response.content_type == "application/json"

Requests

REQUESTPurposeResponse
GetCapabilitiesDescribe the service and the published feature types.XML
DescribeFeatureTypeField names and types for one feature type.XML schema
GetFeatureReturn features, optionally filtered.GML 3 or GeoJSON

GetFeature parameters

ParameterExampleDescription
TYPENAMEbuildingsFeature type, as advertised in capabilities.
OUTPUTFORMATapplication/jsonapplication/json or text/xml; subtype=gml/3.1.1.
MAXFEATURES100Cap on the number of features returned.
STARTINDEX200Skip the first N features (paging).
BBOX14,50,15,51Spatial filter in the type’s CRS.
FILTEROGC XML filterAttribute and spatial filter.
PROPERTYNAMEname,heightRestrict the returned fields.
RESULTTYPEhitsReturn only numberMatched instead of features.
Terminal window
curl 'http://localhost:8080/wfs?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=buildings&OUTPUTFORMAT=application/json&MAXFEATURES=2'

The GeoJSON response carries paging metadata:

{
"type": "FeatureCollection",
"features": [],
"numberMatched": 48392,
"numberReturned": 2,
"links": [
{ "href": "/wfs?...&STARTINDEX=0", "rel": "self" },
{ "href": "/wfs?...&STARTINDEX=2", "rel": "next" }
]
}

Filtering

Terminal window
# Bounding box
curl 'http://localhost:8080/wfs?SERVICE=WFS&REQUEST=GetFeature&TYPENAME=buildings&BBOX=14,50,15,51&OUTPUTFORMAT=application/json'
# Attribute filter (OGC XML)
curl 'http://localhost:8080/wfs?SERVICE=WFS&REQUEST=GetFeature&TYPENAME=buildings&OUTPUTFORMAT=application/json' \
--data-urlencode 'FILTER=<Filter><PropertyIsGreaterThan><PropertyName>height</PropertyName><Literal>50</Literal></PropertyIsGreaterThan></Filter>'

The XML filter is translated into a FeatureRequest and pushed down to the provider, so it filters in the database rather than in memory where the layer allows it.

Counting without transferring

Terminal window
curl 'http://localhost:8080/wfs?SERVICE=WFS&REQUEST=GetFeature&TYPENAME=buildings&RESULTTYPE=hits&FILTER=...'

Errors

Malformed requests return an OGC ExceptionReport:

<ExceptionReport version="1.1.0">
<Exception exceptionCode="InvalidParameterValue" locator="TYPENAME">
Unknown feature type: roads
</Exception>
</ExceptionReport>

See also

  • server — request dispatch and configuration
  • features — the request model filters are translated to
  • wms — map images rather than features
  • Server Overview — OGC API Features, the modern alternative