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, andTemplateArgs, the arguments passed to service templates.core: data structures:LayerCaps,FeatureCollection,FeatureCollectionMember,MetadataCollection.layer_caps: createsLayerCapsfor 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: theowsaction 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
owsaction receives a request and locates the Service objectthe service initializes the
Request(gws.base.ows.server.request.Object), which determines the operation and versionthe request locates the Project and creates a list of
LayerCaps(gws.base.ows.server.core.LayerCaps) for the layers the user can read; groups havechildrenandleaves. The list is cached per service, project and user rolesthe service dispatches the request to the handler method of the operation (
OwsOperation.handlerName)the handler filters the caps according to parameters like
LAYERSorTYPENAMESand creates a list of suitable leaf layersfor image requests, like
GetMap, the leaves are rendered, the result is converted to the requested image format and returnedfor search requests, the service searches the leaves and creates
FeatureCollectionobjectsfor 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:
- OpenGIS Web Map Service (WMS) Implementation Specification 1.3.0 06-042
- Web Map Service 1.1.1 01-068r3
- OpenGIS Web Map Tile Service Implementation Standard 1.0.0 07-057r7
- OpenGIS Web Feature Service 2.0 Interface Standard (also ISO 19142) 2.0 09-025r1
- OpenGIS Web Feature Service (WFS) Implementation Specification 1.1.0 04-094
- OGC Web Coverage Service (WCS) Interface Standard - Core, version 2.1 17-089r1
- OGC Web Service Common Implementation Specification 2.0.0 06-121r9
Other implementations:
Source code: gws.base.ows.server