gws.plugin.ows_server.wms

WMS service.

Implements WMS 1.1.x and 1.3.0 with the operations GetCapabilities, GetMap, GetFeatureInfo and GetLegendGraphic. SLD extensions are not supported, except GetLegendGraphic, for which only the LAYER/LAYERS parameter is evaluated.

The service publishes the project layers that are groups or can render a box. A requested group stands for its leaf layers. GetMap renders the requested layers that are visible at the requested resolution into one image. GetFeatureInfo runs a search at the clicked point in the queryable layers and returns the results in GML 2, using the GetFeature template of the WFS service. DPI or MAP_RESOLUTION parameters are taken into account when the request resolution is computed.

Templates:

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

  • ../wfs/templates/getFeature2.cx.py: ows.GetFeatureInfo.

Example:

projects+ {
    owsServices+ {
        type "wms"
        uid "my_wms"
        supportedCrs [3857 25832]
        layerLimit 20
        maxPixelSize 4096
    }
}

Source code: gws.plugin.ows_server.wms

Subpackages

Package Contents

class gws.plugin.ows_server.wms.Config

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

WMS service that renders the project layers.

layerLimit: int = 0

Max. number of layers in a map request.

maxPixelSize: int = 0

Max. width and height of a map image in pixels.

class gws.plugin.ows_server.wms.Object

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

WMS service that renders the project layers as map images and returns feature info and legends.

isOwsCommon = False
isRasterService = True
layerLimit: int = 0

Max. number of layers in a request, 0 for no limit.

maxPixelSize: int = 0

Max. width and height of a map image in pixels, 2048 by default.

protocol
supportedVersions = ['1.3.0', '1.1.1', '1.1.0']
configure()
configure_metadata()
configure_operations()
configure_templates()
get_features(sr: gws.base.ows.server.request.Object, lcs: list[gws.base.ows.server.LayerCaps])

Search for features at the point given by the I/J (or X/Y) parameters.

Only layers visible at the requested resolution are searched. The search uses the search tolerance of the service.

Parameters:
  • sr – Service request, with bounds and resolution already set.

  • lcs – Layer caps to search.

Returns:

The feature collection.

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_info(sr: gws.base.ows.server.request.Object)

Handle the GetFeatureInfo operation.

Parameters:

sr – Service request.

Returns:

The feature collection, rendered in the requested INFO_FORMAT.

Raises:

server.error.LayerNotQueryable – If none of the requested layers is searchable.

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

Handle the GetLegendGraphic operation.

Parameters:

sr – Service request.

Returns:

The legend image of the requested layers.

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

Handle the GetMap operation.

Layers that are not visible at the requested resolution are skipped; if none remain, an empty image is returned. The background is transparent unless TRANSPARENT=false is requested.

Parameters:

sr – Service request.

Returns:

The map image.

Raises:

server.error.LayerNotDefined – If no layers are requested.

init_request(req)
layer_is_compatible(layer: gws.Layer)
requested_layer_caps(sr: gws.base.ows.server.request.Object, param_name: str, bottom_first=False) → list[gws.base.ows.server.LayerCaps]

Find the layer caps for the layer names in a request parameter.

A requested group is replaced by its leaf layers. Duplicates are removed.

Parameters:
  • sr – Service request.

  • param_name – Request parameter with the layer names, e.g. LAYERS.

  • bottom_first – Return the layers bottom-first, as required for GetMap. Otherwise, the layers are returned top-first.

Returns:

The layer caps.

Raises:
set_size_and_resolution(sr: gws.base.ows.server.request.Object)

Set the bounds, the pixel size and the resolution of the request.

The values are taken from the BBOX, WIDTH and HEIGHT parameters. If DPI or MAP_RESOLUTION is given, the resolution is converted from that DPI.

Parameters:

sr – Service request.

Raises:
visible_layer_caps(sr, lcs: list[gws.base.ows.server.LayerCaps]) → list[gws.base.ows.server.LayerCaps]

Filter layer caps by the resolution of the request.

Parameters:
  • sr – Service request.

  • lcs – Layer caps.

Returns:

The layer caps whose layers are visible at the request resolution.