Code documentation

Code documentation build from docstrings.

Client

Abstract OgcClient base class

class ows_lib.client.mixins.OgcClient(capabilities, session: ~requests.sessions.Session = <requests.sessions.Session object>, *args, **kwargs)

Abstract OgcClient class which implements some basic functionality for all ogc client applications

Parameters:
  • capabilities (OGCServiceMixin | str) – The capabilities document to initialize the client

  • session (requests.Session, optional) – The session object that shall be used

capabilities: OGCServiceMixin
get_capabilitites_request() OGCRequest

Constructs a basic GetCapabilities request to use for requesting

Returns:

A valid GetCapabilitites request

Return type:

requests.Request

send_request(request: OGCRequest, timeout: int = 10) Response

Sends a given request with internal session object.

Parameters:
  • request (requests.Request) – A request object that shall be sended

  • timeout – The time value for maximium waiting time of the response.

Returns:

Returns the response of the given request

Return type:

requests.Response

class ows_lib.xml_mapper.capabilities.mixins.OGCServiceMixin

Abstract class for all OGCService xml mappers, which implements functionality for global usage.

camouflage_urls(new_domain: str, scheme: str | None = None) None
get_operation_url_by_name_and_method(name, method) OperationUrl
property operation_urls: List[OperationUrl]

Custom getter to merge all operation urls as plane OperationUrl object.

class ows_lib.client.wms.mixins.WebMapServiceMixin(capabilities, session: ~requests.sessions.Session = <requests.sessions.Session object>, *args, **kwargs)

Abstract WebMapService class which implements some basic functionality for all wms client applications

capabilities: OGCServiceMixin
property crs_qp
property get_feature_info_operation_name
get_feature_info_request(get_map_request: Request, query_layers: List[str], info_format: str, i: int, j: int, feature_count: int = 0, exceptions: str = 'xml') OGCRequest

Constructs a GetFeatureInfo request to use for requesting

Parameters:
  • get_map_request (requests.Request) – The GetMap request where this request shall based on

  • query_layers (List[str]) – The list of layers for that the feature info shall be requested

  • info_format (str) – The concrete format of the response

  • i (int) – the x value of the x/y point tuple

  • j (int) – the y value of the x/y point tuple

  • feature_count (int, optional) – The number of features that shall be returned, defaults to 0

  • exceptions (str, optional) – the exception format of the server to response with, defaults to “xml”

Returns:

the constructed get feature info request object

Return type:

requests.Request

property get_map_operation_name
get_map_request(layers: List[str], styles: List[str], crs: str, bbox: Tuple[float, float, float, float], width: int, height: int, format: str, transparent: bool | None = None, bgcolor: int = 16777215, exceptions: str = 'xml', time: List[str] | None = None, elevation: float | None = None) OGCRequest

Constructs a GetMap request to use for requesting

Parameters:
  • layers (List[str]) – The name of layers which shall be requested

  • styles (List[str]) – The styles of the layers which shall be requested

  • crs (str) – the reference system which shall be used

  • bbox (Tuple[float, float, float, float]) – the bounding box

  • width (int) – the pixel width

  • height (int) – the pixel height

  • format (str) – the response format

  • transparent (bool, optional) – shall the response be a transparent image?, defaults to None

  • bgcolor (int, optional) – the background color of the response, defaults to 0xFFFFFF

  • exceptions (str, optional) – the exception format which shall be used by the server, defaults to “xml”

  • time (List[str], optional) – the time value or range for map data, defaults to None

  • elevation (float, optional) – _description_, defaults to None

Returns:

the constructed get map request object

Return type:

Request

class ows_lib.client.wfs.mixins.WebFeatureServiceMixin(capabilities, session: ~requests.sessions.Session = <requests.sessions.Session object>, *args, **kwargs)
capabilities: OGCServiceMixin
describe_feature_type_request(type_names: List[str], output_format: List[str]) Request
get_feature_request(get_feature_request: GetFeatureRequest) OGCRequest
property output_format_qp
property type_name_qp
class ows_lib.client.csw.mixins.CatalogueServiceMixin(capabilities, session: ~requests.sessions.Session = <requests.sessions.Session object>, *args, **kwargs)
capabilities: OGCServiceMixin
get_constraint(record_types: List[str])
get_record_by_id_request(id: str, output_schema: str = 'http://www.isotc211.org/2005/gmd', element_set_name: str = 'full') OGCRequest
get_records_request(type_names: str = 'gmd:MD_Metadata', result_type: str = 'hits', output_schema: str = 'http://www.isotc211.org/2005/gmd', element_set_name: str = 'full', xml_constraint: str | None = None, max_records: int | None = None, start_position: int | None = None) OGCRequest
queryable_type_name()

Returns the first matching string of the constraints list which matches the name ‘type’

Utitily functions

ows_lib.client.utils.construct_polygon_from_bbox_query_param(get_dict) GEOSGeometry

Construct a polygon from the parsed bbox query parameter, based on the given service type and version.

Returns:

the bbox parsed from the get_dict or an empty polygon if something went wrong.

Return type:

django.contrib.gis.geos.geometry.GEOSGeometry

ows_lib.client.utils.filter_ogc_query_params(params: Dict) Dict

Parses the GET parameters into all member variables, which can be found in a ogc request.

Parameters:

params (Dict) – all query parameters

Returns:

the ogc specific query parameters

Return type:

Dict

ows_lib.client.utils.get_client(capabilities: ~ows_lib.xml_mapper.capabilities.mixins.OGCServiceMixin, session: ~requests.sessions.Session = <requests.sessions.Session object>)

Helper function to construct the correct client version for given capabilities document

Parameters:

capabilities (OGCServiceMixin) – The parsed capabilities document

Returns:

the concrete service client

Return type:

WebMapService | WebFeatureService | CatalogueService

ows_lib.client.utils.get_requested_feature_types(params: Dict) List[str]

Filters the given params by requested featuretypes

Parameters:

params (Dict) – all query parameters

Returns:

the requested featuretypes from the query params

Return type:

List[str]

ows_lib.client.utils.get_requested_layers(params: Dict) List[str]

Filters the given params by requested layers

Parameters:

params (Dict) – all query parameters

Returns:

the requested layers from the query params

Return type:

List[str]

ows_lib.client.utils.update_queryparams(url: str, params: Dict)

Helper function to update query paramase inside an existing url with trailing query params