gws.plugin.qgis.caps¶
QGIS project xml parser.
Source code: gws.plugin.qgis.caps
Module Contents¶
- class gws.plugin.qgis.caps.Caps(*args, **kwargs)¶
Bases:
gws.DataCapabilities of a QGIS project, as parsed from the project XML.
- metadata: gws.Metadata¶
Project metadata.
- printTemplates: list[PrintTemplate]¶
Print layouts.
- projectBounds: gws.Bounds | None¶
Explicit WMS extent of the project, if set.
- projectCanvasBounds: gws.Bounds | None¶
Map canvas extent of the project, if set.
- properties: dict¶
Project properties.
- sourceLayers: list[gws.SourceLayer]¶
Top-level layers and groups of the project layer tree.
- gws.plugin.qgis.caps.parse(xml: str) Caps¶
Parse a QGIS project XML string.
- Parameters:
xml – Project XML.
- Returns:
Project capabilities.
- Raises:
gws.Error – If the project CRS is invalid.
- gws.plugin.qgis.caps.parse_datasource(prov, text)¶
Parse a QGIS layer data source string.
Common formats (ampersand-delimited, space-delimited, plain URL, pipe-delimited path) are parsed into a dict with lower-case keys, anything else is returned as
{'text': text}. Theproviderkey is always set; WMS sources with a tile matrix set are classified aswmts, and WMS sources of typexyzasxyz.- Parameters:
prov – Data provider name from the project, e.g.
postgres.text – Data source string.
- Returns:
Data source properties.
- Raises:
ValueError – If a space- or pipe-delimited string is malformed.
- gws.plugin.qgis.caps.parse_element(root_el: gws.XmlElement) Caps¶
Parse a QGIS project XML element.
Layers listed as restricted in the project WMS settings are skipped.
- Parameters:
root_el – Root element of the project XML.
- Returns:
Project capabilities.
- Raises:
gws.Error – If the project CRS is invalid.
- class gws.plugin.qgis.caps.PrintTemplate(*args, **kwargs)¶
Bases:
gws.DataA QGIS print layout.
- attributes: dict¶
XML attributes of the layout element.
- elements: list[PrintTemplateElement]¶
Pages and items of the layout.
- class gws.plugin.qgis.caps.PrintTemplateElement(*args, **kwargs)¶
Bases:
gws.DataAn item of a QGIS print layout.
- attributes: dict¶
XML attributes of the item element.
- position: gws.UomPoint¶
Position of the item on the page.
- size: gws.UomSize¶
Size of the item.
- gws.plugin.qgis.caps.qgis_extent(layer_el: gws.XmlElement, layer_crs: gws.Crs)¶
Compute the WGS extent of a map layer.
The extent is taken from the first valid source of the following: the explicit extent in the layer metadata, the
wgs84extentelement, and theextentelement, which is assumed to be in the layer CRS.- Parameters:
layer_el –
maplayerelement.layer_crs – CRS of the layer.
- Returns:
WGS extent, or
Noneif no valid extent is found.