gws.plugin.ows_server.wfs

WFS service.

Implements the WFS 2.0 “Basic” profile. Only GET requests with KVP encoding are supported.

The service publishes the project layers that are not groups, are searchable and have an XML namespace. Supported operations are GetCapabilities, DescribeFeatureType, GetFeature, GetPropertyValue, ListStoredQueries and DescribeStoredQueries.

Supported ad hoc query parameters:

  • TYPENAMES

  • SRSNAME

  • BBOX

  • STARTINDEX

  • COUNT

  • OUTPUTFORMAT

  • RESULTTYPE

FILTER and SORTBY are not supported yet.

Supported stored queries:

  • urn:ogc:def:query:OGC-WFS::GetFeatureById

For GetPropertyValue only a simple VALUEREFERENCE (a field name) is supported.

GetFeature runs a search with the BBOX of the request (or the map extent) in the requested layers and applies STARTINDEX and COUNT to the results. DescribeFeatureType returns an XML schema generated from the layers, unless a template is configured. Features can be returned as GML 3, GML 2 or GeoJSON.

Each published layer needs an XML namespace, set with ows.featureName or ows.xmlns; custom namespaces must also be configured globally (see gws.base.ows.server).

Templates:

  • templates/getCapabilities.cx.py: ows.GetCapabilities.

  • templates/getFeature3.cx.py: ows.GetFeature, GML 3.

  • templates/getFeatureGeoJson.cx.py: ows.GetFeature, GeoJSON.

  • templates/getFeature2.cx.py: ows.GetFeature, GML 2.

  • templates/getPropertyValue.cx.py: ows.GetPropertyValue.

  • templates/listStoredQueries.cx.py: ows.ListStoredQueries.

  • templates/describeStoredQueries.cx.py: ows.DescribeStoredQueries.

References:

Example:

projects+ {
    owsServices+ {
        type "wfs"
        uid "my_wfs"
    }
    map.layers+ {
        type "postgres"
        tableName "public.districts"
        ows.featureName "my:districts"
    }
}

Source code: gws.plugin.ows_server.wfs

Subpackages

Package Contents

class gws.plugin.ows_server.wfs.Config

Bases: gws.base.ows.server.service.Config

WFS service that serves features of the project layers.

class gws.plugin.ows_server.wfs.Object

Bases: gws.base.ows.server.service.Object

WFS service that returns the features of the project layers.

isOwsCommon = True
isVectorService = True
protocol
SEARCH_MAX_TOTAL = 100000

Max. number of features a search can return, before paging.

supportedVersions = ['2.0.2', '2.0.1', '2.0.0']
configure_metadata()
configure_operations()
configure_templates()
get_features(sr: gws.base.ows.server.request.Object, value_ref: str = '') → gws.base.ows.server.FeatureCollection

Search for the features requested by GetFeature or GetPropertyValue.

With RESULTTYPE=hits, only the number of found features is returned. Otherwise, STARTINDEX and COUNT (or MAXFEATURES) are applied to the results.

Parameters:
  • sr – Service request.

  • value_ref – If given, only features that have this attribute are returned.

Returns:

The feature collection.

handle_describe_feature_type(sr: gws.base.ows.server.request.Object)

Handle the DescribeFeatureType operation.

If a template is configured, it is used. Otherwise, an XML schema is generated for the requested layers.

Parameters:

sr – Service request.

Returns:

The XML schema of the requested feature types.

handle_describe_stored_queries(sr: gws.base.ows.server.request.Object)

Handle the DescribeStoredQueries operation.

Parameters:

sr – Service request.

Returns:

The description of the stored queries.

Raises:

server.error.InvalidParameterValue – If STOREDQUERY_ID is not a supported query.

handle_get_capabilities(sr: gws.base.ows.server.request.Object)

Handle the GetCapabilities operation.

Parameters:

sr – Service request.

Returns:

The capabilities document.

handle_get_feature(sr: gws.base.ows.server.request.Object)

Handle the GetFeature operation.

Parameters:

sr – Service request.

Returns:

The feature collection in the requested OUTPUTFORMAT.

handle_get_property_value(sr: gws.base.ows.server.request.Object)

Handle the GetPropertyValue operation.

Parameters:

sr – Service request.

Returns:

The values of the VALUEREFERENCE attribute of the found features.

handle_list_stored_queries(sr: gws.base.ows.server.request.Object)

Handle the ListStoredQueries operation.

Parameters:

sr – Service request.

Returns:

The list of stored queries.

init_request(req)
layer_is_compatible(layer: gws.Layer)

Create the search query for a request.

For the GetFeatureById stored query, the search looks up the feature given by the id parameter. Otherwise, it searches within the bounds of the request.

Parameters:
  • sr – Service request.

  • lcs – Layer caps to search.

Returns:

The search query.

Raises:

server.error.InvalidParameterValue – If STOREDQUERY_ID is not a supported query.

requested_layer_caps(sr: gws.base.ows.server.request.Object)

Find the layer caps for the feature types in TYPENAME or TYPENAMES.

Parameters:

sr – Service request.

Returns:

The matching layer caps without duplicates, or all layer caps if no feature types are requested.

Raises:

server.error.LayerNotDefined – If none of the requested feature types is found.

gws.plugin.ows_server.wfs.STORED_QUERY_GET_FEATURE_BY_ID = 'urn:ogc:def:query:OGC-WFS::GetFeatureById'

Identifier of the only supported stored query.