gws.base.ows.client.parseutil¶
Parse utilities for OWS capabilities documents.
Source code: gws.base.ows.client.parseutil
Module Contents¶
- gws.base.ows.client.parseutil.default_style(styles: list[gws.SourceStyle]) gws.SourceStyle | None¶
Find the default style in a list of styles.
- Parameters:
styles – Source styles.
- Returns:
The first style marked as default, otherwise the first style, or
Noneif the list is empty.
- gws.base.ows.client.parseutil.element_metadata(el: gws.XmlElement) gws.Metadata¶
Read the metadata of an element, such as a
LayerorFeatureType.- Parameters:
el – XML element.
- Returns:
Normalized metadata.
- gws.base.ows.client.parseutil.parse_style(el: gws.XmlElement) gws.SourceStyle¶
Read a
Styleelement.The style is marked as default if it has
IsDefault="true"or its name isdefaultor ends with:default.- Parameters:
el –
Styleelement.- Returns:
The source style, with a lower-cased name.
- gws.base.ows.client.parseutil.service_metadata(caps_el: gws.XmlElement) gws.Metadata¶
Read the service metadata from a capabilities document.
Reads the WMS
Serviceelement or the OWSServiceIdentificationandServiceProviderelements, including contact information.- Parameters:
caps_el – Root element of the capabilities document.
- Returns:
Normalized metadata.
- gws.base.ows.client.parseutil.service_operations(caps_el: gws.XmlElement) list[gws.OwsOperation]¶
Read the operations from a capabilities document.
Supports both the OWS Common format (
OperationsMetadata/Operation) and the WMS format (Capability/Request).- Parameters:
caps_el – Root element of the capabilities document.
- Returns:
A list of operations, empty if none are found.
- gws.base.ows.client.parseutil.supported_crs(layer_el: gws.XmlElement, extra_crs_ids: list[str] = None) list[gws.Crs]¶
Enumerate the supported CRSs of a
LayerorFeatureTypeelement.For WMS, enumerates
CRS/SRSandBoundingBoxtags, for OWS,DefaultCRSandOtherCRS. Unknown CRS ids are skipped.- Parameters:
layer_el –
LayerorFeatureTypeelement.extra_crs_ids – Additional CRS ids.
- Returns:
A list of
Crsobjects.
- gws.base.ows.client.parseutil.to_float(s, default=0.0)¶
Convert a string to a float.
- Parameters:
s – String value.
default – Value used when
sis empty.
- Returns:
The float value.
- Raises:
ValueError – If the string is not a number.
- gws.base.ows.client.parseutil.to_float_pair(s)¶
Convert a whitespace-separated string to a pair of floats.
- Parameters:
s – String like
"1.5 2.5".- Returns:
The first two numbers as a tuple.
- Raises:
ValueError – If a value is not a number.
IndexError – If there are fewer than two values.
- gws.base.ows.client.parseutil.to_int(s, default=0)¶
Convert a string to an int, accepting float strings.
- Parameters:
s – String value.
default – Value used when
sis empty.
- Returns:
The value, truncated to an int.
- Raises:
ValueError – If the string is not a number.
- gws.base.ows.client.parseutil.wgs_extent(layer_el: gws.XmlElement) gws.Extent | None¶
Read the WGS84 bounding box from a
LayerorFeatureTypeelement.Extracts coordinates from
EX_GeographicBoundingBox(WMS),WGS84BoundingBox(OWS) orLatLonBoundingBox. For the latter, assume x=longitude, y=latitude, as per OGC 01-068r3, 6.5.6.- Parameters:
layer_el –
LayerorFeatureTypeelement.- Returns:
The extent, or
Noneif the element has no WGS84 bounding box.