Skip to content

Commit

Permalink
Fix variables name
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Jun 5, 2019
1 parent 1607f05 commit 8054794
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
8 changes: 4 additions & 4 deletions cadastre_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def __init__(self, dialog):
]
# List of database layers to load in QGIS
self.variableLayers = {
'Communes':{'var_key':'communes', 'unique_col':'geo_commune'},
'Sections':{'var_key':'sections', 'unique_col':'geo_section'},
'Parcelles':{'var_key':'parcelles', 'unique_col':'geo_parcelle'},
'Communes':{'var_key':'commune', 'unique_field':'geo_commune'},
'Sections':{'var_key':'section', 'unique_field':'geo_section'},
'Parcelles':{'var_key':'parcelle', 'unique_field':'geo_parcelle'},
}

def updateTimer(self):
Expand Down Expand Up @@ -374,7 +374,7 @@ def processLoading(self):
if layer.name() in self.variableLayers:
varlayer = self.variableLayers[layer.name()]
variables['cadastre_'+varlayer['var_key']+'_layer_id'] = layer.id()
variables['cadastre_'+varlayer['var_key']+'_unique_col'] = varlayer['unique_col']
variables['cadastre_'+varlayer['var_key']+'_unique_field'] = varlayer['unique_field']

QgsProject.instance().setCustomVariables(variables)

Expand Down
38 changes: 19 additions & 19 deletions processing/algorithms/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class ConfigProjectAlgorithm(QgsProcessingAlgorithm):
Algorithm to set project varaibles for cadastre use
"""

TOWN_LAYER = 'TOWN_LAYER'
TOWN_UNIQUE_FIELD = 'TOWN_UNIQUE_FIELD'
COMMUNE_LAYER = 'COMMUNE_LAYER'
COMMUNE_UNIQUE_FIELD = 'COMMUNE_UNIQUE_FIELD'
SECTION_LAYER = 'SECTION_LAYER'
SECTION_UNIQUE_FIELD = 'SECTION_UNIQUE_FIELD'
PARCEL_LAYER = 'PARCEL_LAYER'
PARCEL_UNIQUE_FIELD = 'PARCEL_UNIQUE_FIELD'
PARCELLE_LAYER = 'PARCELLE_LAYER'
PARCELLE_UNIQUE_FIELD = 'PARCELLE_UNIQUE_FIELD'

SUCCESS = 'SUCCESS'

Expand All @@ -50,7 +50,7 @@ def initAlgorithm(self, config):

self.addParameter(
QgsProcessingParameterVectorLayer(
self.TOWN_LAYER,
self.COMMUNE_LAYER,
self.tr('La couche communes'),
[QgsProcessing.TypeVectorPolygon],
defaultValue='Communes'
Expand All @@ -59,9 +59,9 @@ def initAlgorithm(self, config):

self.addParameter(
QgsProcessingParameterField(
self.TOWN_UNIQUE_FIELD,
self.COMMUNE_UNIQUE_FIELD,
self.tr('Champs identifiant les communes'),
parentLayerParameterName=self.TOWN_LAYER,
parentLayerParameterName=self.COMMUNE_LAYER,
defaultValue='geo_commune',
type=QgsProcessingParameterField.String
)
Expand All @@ -87,17 +87,17 @@ def initAlgorithm(self, config):

self.addParameter(
QgsProcessingParameterVectorLayer(
self.PARCEL_LAYER,
self.PARCELLE_LAYER,
self.tr('La couche parcelles'),
[QgsProcessing.TypeVectorPolygon]
)
)

self.addParameter(
QgsProcessingParameterField(
self.PARCEL_UNIQUE_FIELD,
self.PARCELLE_UNIQUE_FIELD,
self.tr('Champs identifiant les parcelles'),
parentLayerParameterName=self.PARCEL_LAYER,
parentLayerParameterName=self.PARCELLE_LAYER,
defaultValue='geo_parcelle',
type=QgsProcessingParameterField.String
)
Expand All @@ -110,25 +110,25 @@ def processAlgorithm(self, parameters, context, feedback):
Here is where the processing itself takes place.
"""

town_layer = self.parameterAsVectorLayer(parameters, self.TOWN_LAYER, context)
town_unique_field = self.parameterAsString(parameters, self.TOWN_UNIQUE_FIELD, context)
commune_layer = self.parameterAsVectorLayer(parameters, self.COMMUNE_LAYER, context)
commune_unique_field = self.parameterAsString(parameters, self.COMMUNE_UNIQUE_FIELD, context)

section_layer = self.parameterAsVectorLayer(parameters, self.SECTION_LAYER, context)
section_unique_field = self.parameterAsString(parameters, self.SECTION_UNIQUE_FIELD, context)

parcel_layer = self.parameterAsVectorLayer(parameters, self.PARCEL_LAYER, context)
parcel_unique_field = self.parameterAsString(parameters, self.PARCEL_UNIQUE_FIELD, context)
parcelle_layer = self.parameterAsVectorLayer(parameters, self.PARCELLE_LAYER, context)
parcelle_unique_field = self.parameterAsString(parameters, self.PARCELLE_UNIQUE_FIELD, context)

variables = context.project().customVariables()

variables['cadastre_commune_layer_id'] = town_layer.id()
variables['cadastre_commune_unique_col'] = town_unique_field
variables['cadastre_commune_layer_id'] = commune_layer.id()
variables['cadastre_commune_unique_field'] = commune_unique_field

variables['cadastre_section_layer_id'] = section_layer.id()
variables['cadastre_section_unique_col'] = section_unique_field
variables['cadastre_section_unique_field'] = section_unique_field

variables['cadastre_parcelle_layer_id'] = parcel_layer.id()
variables['cadastre_parcelle_unique_col'] = parcel_unique_field
variables['cadastre_parcelle_layer_id'] = parcelle_layer.id()
variables['cadastre_parcelle_unique_field'] = parcelle_unique_field

context.project().setCustomVariables(variables)
# Returns empty dict if no outputs
Expand Down

0 comments on commit 8054794

Please sign in to comment.