Class: QgsServerApiUtils

class qgis.server.QgsServerApiUtils

Bases: sip.wrapper

The QgsServerApiUtils class contains helper functions to handle common API operations.

Methods

appendMapParameter

Appends MAP query string parameter from current requestUrl to the given path

crsToOgcUri

Returns a crs as OGC URI (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) Returns an empty string on failure.

parseBbox

Parses a comma separated bbox into a (possibly empty) QgsRectangle.

parseCrs

Parses the CRS URI bboxCrs (example: “http://www.opengis.net/def/crs/OGC/1.3/CRS84”) into a QGIS CRS object

parseTemporalDateInterval

Parses a date interval and returns a QgsDateRange

parseTemporalDateTimeInterval

Parses a datetime interval and returns a QgsDateTimeRange

publishedCrsList

Returns the list of CRSs (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) available for this project.

publishedWfsLayers

Returns the list of layers accessible to the service for a given project.

sanitizedFieldValue

Sanitizes the input value by removing URL encoding and checking for malicious content.

temporalDimensions

Returns a list of temporal dimensions information for the given layer (either configured in wmsDimensions or the first date/datetime field)

temporalExtent

temporalExtent returns a json array with an array of [min, max] temporal extent for the given layer.

temporalFilterExpression

Parses the interval and constructs a (possibly invalid) temporal filter expression for the given layer

appendMapParameter(path: str, requestUrl: QUrl) → str

Appends MAP query string parameter from current requestUrl to the given path

Parameters
  • path (str) –

  • requestUrl (QUrl) –

Return type

str

crsToOgcUri(crs: QgsCoordinateReferenceSystem) → str

Returns a crs as OGC URI (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) Returns an empty string on failure.

Parameters

crs (QgsCoordinateReferenceSystem) –

Return type

str

parseBbox(bbox: str) → QgsRectangle

Parses a comma separated bbox into a (possibly empty) QgsRectangle.

Note

Z values (i.e. a 6 elements bbox) are silently discarded

Parameters

bbox (str) –

Return type

QgsRectangle

parseCrs(bboxCrs: str) → QgsCoordinateReferenceSystem

Parses the CRS URI bboxCrs (example: “http://www.opengis.net/def/crs/OGC/1.3/CRS84”) into a QGIS CRS object

Parameters

bboxCrs (str) –

Return type

QgsCoordinateReferenceSystem

parseTemporalDateInterval(interval: str) → QgsDateRange

Parses a date interval and returns a QgsDateRange

Raises

QgsServerApiBadRequestException – if interval cannot be parsed

New in version 3.12.

Parameters

interval (str) –

Return type

QgsDateRange

parseTemporalDateTimeInterval(interval: str) → QgsDateTimeRange

Parses a datetime interval and returns a QgsDateTimeRange

Raises

QgsServerApiBadRequestException – if interval cannot be parsed

New in version 3.12.

Parameters

interval (str) –

Return type

QgsDateTimeRange

publishedCrsList(project: QgsProject) → List[str]

Returns the list of CRSs (format: http://www.opengis.net/def/crs/OGC/1.3/CRS84) available for this project. Information is read from project WMS configuration.

Parameters

project (QgsProject) –

Return type

List[str]

publishedWfsLayers(project: QgsProject) → object

Returns the list of layers accessible to the service for a given project.

This method takes into account the ACL restrictions provided by QGIS Server Access Control plugins.

Note

project must not be NULL

Parameters

project (QgsProject) –

Return type

object

sanitizedFieldValue(value: str) → str

Sanitizes the input value by removing URL encoding and checking for malicious content. In case of failure returns an empty string.

Parameters

value (str) –

Return type

str

temporalDimensions(layer: QgsVectorLayer) → List[QgsVectorLayerServerProperties.WmsDimensionInfo]

Returns a list of temporal dimensions information for the given layer (either configured in wmsDimensions or the first date/datetime field)

New in version 3.12.

Parameters

layer (QgsVectorLayer) –

Return type

List[QgsVectorLayerServerProperties.WmsDimensionInfo]

temporalExtent(layer: QgsVectorLayer) → List[Any]

temporalExtent returns a json array with an array of [min, max] temporal extent for the given layer. In case multiple temporal dimensions are available in the layer, a union of all dimensions is returned.

From specifications: http://schemas.opengis.net/ogcapi/features/part1/1.0/openapi/schemas/extent.yaml

One or more time intervals that describe the temporal extent of the dataset. The value null is supported and indicates an open time interval.

In the Core only a single time interval is supported. Extensions may support multiple intervals. If multiple intervals are provided, the union of the intervals describes the temporal extent.

Return type

List[Any]

Returns

An array of intervals

New in version 3.12.

Parameters

layer (QgsVectorLayer) –

temporalFilterExpression(layer: QgsVectorLayer, interval: str) → QgsExpression

Parses the interval and constructs a (possibly invalid) temporal filter expression for the given layer

Interval syntax:

interval-closed = date-time “/” date-time interval-open-start = [“..”] “/” date-time interval-open-end = date-time “/” [“..”] interval = interval-closed / interval-open-start / interval-open-end datetime = date-time / interval

New in version 3.12.

Parameters
Return type

QgsExpression