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…
- 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:
http://www.opengis.net/def/crs/epsg/0/<EPSG code>
http://www.opengis.net/gml/srs/epsg.xml#<EPSG code>
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:
CapabilitiesXMLParsingError – if XML parsing of capabilities failed
ExternalRequestError – if GetCapabilities request to WFS server failed
- 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:
CapabilitiesXMLParsingError – if XML parsing of GetCapabilities response failed
ExternalRequestError – if GetCapabilities or GetFeature request to WFS server failed
UploadError – if the GetFeature response could not be loaded into geodata
- 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