gws.plugin.qfieldcloud.caps¶
Parser for QField-related capabilities of a QGIS project.
Source code: gws.plugin.qfieldcloud.caps
Module Contents¶
- class gws.plugin.qfieldcloud.caps.Caps(*args, **kwargs)¶
Bases:
gws.DataQField related capabilities extracted from the QGIS project and GWS config.
- areaOfInterest: gws.Bounds | None¶
Area of interest.
- layerMap: dict[str, LayerEntry]¶
Layer entries by QGIS layer id.
- modelMap: dict[str, ModelEntry]¶
Model entries by GeoPackage name.
- projectProps: ProjectProps¶
QFieldSync project properties.
- class gws.plugin.qfieldcloud.caps.LayerAction¶
Bases:
gws.EnumWhat the packager does with a layer.
- baseMap = 'baseMap'¶
Render the layer into the base map.
- edit = 'edit'¶
Package the layer data for offline editing.
- remove = 'remove'¶
Remove the layer from the project.
- class gws.plugin.qfieldcloud.caps.LayerEntry(*args, **kwargs)¶
Bases:
gws.DataQField-related information about a QGIS layer.
- action: LayerAction¶
What to do with the layer.
- modelEntry: ModelEntry¶
Model entry, for
editlayers.
- props: LayerProps¶
QFieldSync layer properties.
- sourceLayer: gws.SourceLayer¶
Source layer from the QGIS project.
- class gws.plugin.qfieldcloud.caps.LayerProps(*args, **kwargs)¶
Bases:
gws.DataCustom layer properties as defined by QField.
- attachment_naming: dict¶
Naming rules for attachments.
- photo_naming: dict¶
Naming rules for photos.
- relationship_maximum_visible: dict¶
Maximum number of visible related features.
- tracking_distance_requirement_minimum_meters: int¶
Minimum distance between tracked positions, in meters.
- tracking_erroneous_distance_safeguard_maximum_meters: int¶
Maximum distance of a tracked position before it is considered erroneous, in meters.
- class gws.plugin.qfieldcloud.caps.ModelEntry(*args, **kwargs)¶
Bases:
gws.DataA model for an offline table, with its GeoPackage layer name.
- model: gws.DatabaseModel¶
Model for the table.
- class gws.plugin.qfieldcloud.caps.Parser(qfc_project: gws.plugin.qfieldcloud.core.QfcProject)¶
Reads QField-related capabilities from a QGIS project.
parsereads the project and layer properties.create_modelsandassign_path_propscomplete the layer entries and are called separately.- qfcProject: gws.plugin.qfieldcloud.core.QfcProject¶
QField project.
- qgisCaps: gws.plugin.qgis.caps.Caps¶
Capabilities of the QGIS project.
- assign_path_props()¶
Set the data file name, data source and provider of
editandbaseMaplayers in the package.
- create_model_entry_for_layer(le: LayerEntry)¶
Assign a model entry to an
editlayer.If no model is found, or the layer is editable but the model is not, the layer gets the
removeaction.- Parameters:
le – Layer entry.
- create_models()¶
Create model entries for all
editlayers.
- extract_layer_props(sl: gws.SourceLayer) LayerProps¶
Read the QFieldSync properties of a layer.
- Parameters:
sl – Source layer.
- Returns:
Layer properties.
- extract_project_props() ProjectProps¶
Read the QFieldSync project properties.
- Returns:
Project properties.
- gp_name_for_model(table_name)¶
Return the GeoPackage name for a table.
- Parameters:
table_name – Table name, optionally with a schema (
publicby default).- Returns:
Name in the form
qm_<schema>_<table>, lowercase.
- iter_layers()¶
Create layer entries for all non-group source layers.
- layer_entry(sl: gws.SourceLayer) LayerEntry | None¶
Create a layer entry for a source layer.
- Parameters:
sl – Source layer.
- Returns:
Layer entry, or
Noneif the layer is left unchanged in the package.
- layer_entry_2(sl: gws.SourceLayer) LayerEntry | None¶
Determine the action for a source layer.
Base map layers get
baseMap. Layers with the cloud actionremovegetremove. Postgres layers with the cloud actionofflinegetedit, offline layers of other providers getremove.- Parameters:
sl – Source layer.
- Returns:
Layer entry without the id and source layer, or
Nonefor other layers.
- model_entry_for_source_layer(sl: gws.SourceLayer) ModelEntry | None¶
Find or create a model entry for the table of a source layer.
A configured model with the same table name is used if present. Otherwise a generic Postgres model is created for the table.
- Parameters:
sl – Source layer.
- Returns:
Model entry, or
Noneif the layer has no table or the table does not exist.
- parse() Caps¶
Parse the QGIS project.
Reads the project properties, the area of interest, the directories to copy, the base map layers and the layer entries.
- Returns:
Capabilities, also stored in
self.caps.
- parse_area_of_interest()¶
Set the area of interest from the project properties.
- parse_base_map()¶
Set the base map layer ids from the map theme or the single base map layer.
- parse_copy_dirs()¶
Set the directories to copy into the package.
Relative paths are resolved against the QGIS project file. Nested directories are dropped.
- postgres_layer_entry(sl, props: LayerProps) LayerEntry¶
Create a layer entry for an offline Postgres layer.
Layers without a plain table name (e.g. SQL queries) get the
removeaction.- Parameters:
sl – Source layer.
props – QFieldSync layer properties.
- Returns:
Layer entry.