gws.plugin.qgis.provider¶
QGIS project provider.
Source code: gws.plugin.qgis.provider
Module Contents¶
- class gws.plugin.qgis.provider.Config(*args, **kwargs)¶
Bases:
gws.ConfigQGIS project, served by QGIS Server.
- defaultLegendOptions: dict | None¶
Legend options applied to all layers of this project.
- forceCrs: gws.CrsName | None¶
CRS for QGIS Server requests.
- path: gws.FilePath | None¶
QGIS project file.
- watchFrequency: gws.Duration | None¶
Interval between checks for project changes.
- class gws.plugin.qgis.provider.Object¶
Bases:
gws.OwsServiceProviderProvider for a QGIS project, served by QGIS Server.
The provider loads and parses the project, computes the project bounds and sends requests to QGIS Server.
- caps: gws.plugin.qgis.caps.Caps¶
Parsed project capabilities.
- defaultLegendOptions: dict¶
Legend options applied to all layers of the project.
- directRender: set[str]¶
Data source providers rendered directly, not through QGIS Server (
wms,wmts,xyz).
- directSearch: set[str]¶
Data source providers searched directly, not through QGIS Server (
wms,wfs,postgres).
- printTemplates: list[gws.plugin.qgis.caps.PrintTemplate]¶
Print layouts of the project.
- store: gws.plugin.qgis.project.Store¶
Location of the project.
- cache_hash()¶
Compute a hash of the provider settings that affect rendering.
- Returns:
Hash string, built from the store and the request CRS.
- call_server(params: dict) gws.lib.net.HTTPResponse¶
Send a request to QGIS Server.
- Parameters:
params – Request parameters, completed by
server_params.- Returns:
HTTP response.
- Raises:
gws.lib.net.Error – If the request fails.
- configure()¶
Configuration hook.
Called when the node is initialized. Raising an exception here aborts the creation of the node.
- configure_store()¶
Set the project store from
pathorprojectName.- Raises:
gws.ConfigurationError – If neither
pathnorprojectNameis configured.
- create_leaf_layer_config(source_layers)¶
Create the configuration of a leaf layer for the
qgistree layer.By default, this is a
qgisflatlayer. For a single source layer whose data source provider is listed indirectRenderordirectSearch, the layer is rendered directly (wmsflat,wmtsortile) and gets its own finders and models.- Parameters:
source_layers – Source layers of the leaf.
- Returns:
Layer configuration dict.
- get_features(search, source_layers)¶
Search for features in the given source layers.
- Parameters:
args – Search query.
source_layers – Source layers to search.
- Returns:
Found feature records.
- get_map(bounds: gws.Bounds, width: float, height: float, params: dict) bytes¶
Render a map image with a GetMap request.
- Parameters:
bounds – Box to render.
width – Image width in pixels.
height – Image height in pixels.
params – Extra request parameters, e.g.
LAYERS; they override the defaults (transparent PNG).
- Returns:
Image bytes.
- Raises:
gws.Error – If QGIS Server returns a non-image response.
- periodic_task()¶
Periodic task hook.
Called by the server monitor for nodes registered with
register_periodic_task.
- postgres_provider_from_datasource(ds: dict) gws.plugin.postgres.provider.Object¶
Find or create a Postgres provider for a QGIS data source.
An existing provider with the same connection URL is reused, otherwise a new provider is created.
- Parameters:
ds – Parsed Postgres data source.
- Returns:
Postgres provider.
- qgis_project() gws.plugin.qgis.project.Object¶
Load the project from its store.
- Returns:
A freshly loaded project.
- Raises:
project.Error – If the project cannot be loaded.
- server_params(params: dict) dict¶
Add default parameters to a QGIS Server request.
- Parameters:
params – Request parameters; keys are converted to upper case.
- Returns:
Parameters with
MAP,SERVICEandVERSIONdefaults.
- server_project_path()¶
Return the project address for the QGIS Server
MAPparameter.For a file store this is the file path. For a Postgres store this is the database connection URL with
schemaandprojectparameters; when watching is enabled, the project hash is appended to invalidate the QGIS Server cache.- Returns:
Project path or URL.