deseasion.backend.services.wfs module

class deseasion.backend.services.wfs.WFSCapabilities(url: str, version: str, feature_types: dict[str, WFSFeatureType])

Bases: object

This dataclass holds information parsed from a WFS GetCapabilities query XML response.

feature_types: dict[str, WFSFeatureType]
url: str
version: str
class deseasion.backend.services.wfs.WFSFeatureType(name: str, title: str, description: str, keywords: list[str], srs: list[str])

Bases: object

This dataclass is meant for holding information parsed from a <FeatureType> XML tag in a WFS GetCapabilities query response.

Todo

Add other srs options from server, and use them to make the projection server-side if possible. Must be able to compare srs on multiple formats for that…

property default_srs: str

Default SRS projection (first one from srs list)

description: str
keywords: list[str]
name: str
srs: list[str]
title: str
deseasion.backend.services.wfs.convert_raw_crs(raw_crs: str) str

Convert a crs/srs XML tag content into a usable srs string.

Formats converted:

Any other formats than the first 2 are passed as is, so all WFS standard srs formats are handled.

Parameters:

raw_crs – crs/srs XML tag content

Returns:

srs/csr usable for projections

deseasion.backend.services.wfs.get_capabilities(url: str, version: str = None) WFSCapabilities

Perform WFS GetCapabilities request and parse informations.

Parameters:
  • url – WFS server URL

  • version – WFS version number, negotiated with server if not set

Raises:
Returns:

WFS server capabilities

deseasion.backend.services.wfs.get_feature(url: str, feature_type: str, version: str = None, srs: str = None, **kwargs) GeoDataFrame

Perform WFS GetFeature request and return geographic data.

Parameters:
  • url – WFS server URL

  • feature_type – feature type to retrieve

  • version – preferred WFS version number (actual is negotiated with server)

  • srs – coordinate system to use, use feature type default if not set

Raises:
Returns:

geographic data

deseasion.backend.services.wfs.parse_capabilities(capabilities: Tag) tuple[str, dict[str, WFSFeatureType]]

Parse a <WFS_Capabilities> XML tag for information.

Parameters:

capabilities – XML tag

Raises:

CapabilitiesXMLParsingError – if XML parsing of capabilities failed

Returns:

WFS server capabilities

deseasion.backend.services.wfs.parse_feature_type(feature_type: Tag, version: str) WFSFeatureType

Parse a XML <FeatureType> tag.

Parameters:
  • feature_type – XML <FeatureType> tag

  • version – WFS version

Returns:

information describing the feature type

Todo

Add other srs/crs options to srs

deseasion.backend.services.wfs.version2int(version: str) tuple[int, ...]

Convert version string to int tuple.

Parameters:

version

Returns:

version int tuple in same order