gws.base.ows.server.layer_caps

Utilities for LayerCaps objects.

Source code: gws.base.ows.server.layer_caps

Module Contents

gws.base.ows.server.layer_caps.feature_name_matches(lc: gws.base.ows.server.core.LayerCaps, name: str, custom_namespace_prefixes: dict) → bool

Check if the feature name in the caps matches the given name, which may be a QName.

A name without a prefix matches any namespace.

Parameters:
  • lc – Layer caps.

  • name – Feature name, optionally with a prefix.

  • custom_namespace_prefixes – Custom prefixes by namespace uri.

Returns:

True if the names match.

gws.base.ows.server.layer_caps.feature_prefix(lc: gws.base.ows.server.core.LayerCaps, custom_namespace_prefixes: dict) → str

Return the namespace prefix of the feature type.

Parameters:
  • lc – Layer caps.

  • custom_namespace_prefixes – Custom prefixes by namespace uri, as requested with the WFS NAMESPACES parameter.

Returns:

The custom prefix for the layer namespace if there is one, otherwise the namespace prefix, or an empty string if the layer has no namespace.

gws.base.ows.server.layer_caps.for_layer(layer: gws.Layer, user: gws.User, service: gws.OwsService | None = None) → gws.base.ows.server.core.LayerCaps

Create LayerCaps for a layer.

isGroup is not set and children and leaves are empty; the caller fills them in when building the layer tree.

Parameters:
  • layer – Layer object.

  • user – User, used to find a readable model for the layer.

  • service – Service; if given, bounds are computed for its supported bounds.

Returns:

The layer caps.

gws.base.ows.server.layer_caps.layer_name_matches(lc: gws.base.ows.server.core.LayerCaps, name: str) → bool

Check if the layer name in the caps matches the given name, ignoring a prefix.

Parameters:
  • lc – Layer caps.

  • name – Layer name, possibly with a namespace prefix.

Returns:

True if the names match.

gws.base.ows.server.layer_caps.qualified_feature_name(lc: gws.base.ows.server.core.LayerCaps, custom_namespace_prefixes: dict) → str

Return the feature type name as a QName (prefix:name), for use in text content.

Parameters:
  • lc – Layer caps.

  • custom_namespace_prefixes – Custom prefixes by namespace uri.

Returns:

The qualified name, or the plain feature name if the layer has no namespace.

gws.base.ows.server.layer_caps.xml_schema(lcs: list[gws.base.ows.server.core.LayerCaps], user: gws.User) → tuple[gws.XmlElement, gws.XmlOptions]

Create an ad-hoc XML Schema for a list of LayerCaps.

All layers must have a model and share the same XML namespace. The schema contains a complex type and an element for each feature type, with elements for the model fields the user can read.

Parameters:
  • lcs – Layer caps.

  • user – User.

Returns:

The schema element and XML options to serialize it.

Raises:

gws.NotFoundError – If a layer has no namespace or model, or the namespaces differ.