gws.base.ows.server

OWS services.

Base for the OWS services (WMS, WMTS, WFS, CSW) implemented in gws.plugin.ows_server.

Submodules

  • service: base class for services (gws.base.ows.server.service.Object) and its configuration. Configures supported CRSs and bounds, image formats, templates and metadata, parses incoming requests, dispatches them to the operation handlers and provides helpers to create template, XML, image and legend responses.

  • request: the service request (gws.base.ows.server.request.Object), which reads and validates OWS parameters, resolves the project and collects the layer caps, and TemplateArgs, the arguments passed to service templates.

  • core: data structures: LayerCaps, FeatureCollection, FeatureCollectionMember, MetadataCollection.

  • layer_caps: creates LayerCaps for layers, matches layer and feature names and creates XML schemas.

  • error: OWS exception classes and their XML and image responses. Each class corresponds to an OWS exception code, as defined in OGC standards; the class name is the code.

  • templatelib: helper functions used by service templates to generate common XML fragments.

  • action: the ows action that serves the configured services over HTTP.

Configuration

A service (owsService) can be global or project-bound. A global service can be used with any project.

When invoked, the service locates the project (the bound project or projectUid for global services) and collects all suitable layers from the project.

Layers can control their presence in OWS services using withOws and ows configs.

The ows action is required to serve OWS services over http.

Example:

actions+ { type "ows" }

owsServices+ {
    type "wms"
    uid "my_wms"
    supportedCrs [ 3857 25832 ]
}

The service is then available at /_/owsService/serviceUid/my_wms.

XML Namespaces

A WFS service requires each involved layer to have a configured XML namespace (with ows.featureName <ns>:name or ows.xmlns <ns>). Additionally, custom namespaces must be configured globally using Application.xml config.

For some layers, we can autogenerate schemas for custom namespaces on the fly from the layer data. To use an autogenerated schema, the schemaLocation attribute for a namespace must be https://<server>/_/owsXml/namespace/<ns>.xsd and the ows action must be enabled globally.

Workflow

  • the ows action receives a request and locates the Service object

  • the service initializes the Request (gws.base.ows.server.request.Object), which determines the operation and version

  • the request locates the Project and creates a list of LayerCaps (gws.base.ows.server.core.LayerCaps) for the layers the user can read; groups have children and leaves. The list is cached per service, project and user roles

  • the service dispatches the request to the handler method of the operation (OwsOperation.handlerName)

  • the handler filters the caps according to parameters like LAYERS or TYPENAMES and creates a list of suitable leaf layers

  • for image requests, like GetMap, the leaves are rendered, the result is converted to the requested image format and returned

  • for search requests, the service searches the leaves and creates FeatureCollection objects

  • for search and capabilities requests, a suitable template is located and rendered

  • errors are converted to OWS exception documents (gws.base.ows.server.error.Error)

Example of a service template, using templatelib:

import gws.base.ows.server as server
import gws.base.ows.server.templatelib as tpl
from gws.lib.xmlx import tag

def main(ta: server.TemplateArgs):
    return tpl.to_xml_response(
        ta,
        tag('Capabilities', tpl.ows_service_identification(ta), tpl.ows_service_provider(ta)),
    )

Formats

Standard service templates are python templates which use gws.lib.xmlx.tag() to generate nested XML responses.

Standard image formats are image/png and image/jpeg.

Users can configure their own templates and image formats. The “supported formats” lists in OWS capabilities documents are created automatically, based on configured templates and image formats.

References

OGC Standards:

Other implementations:

Source code: gws.base.ows.server

Submodules