diff --git a/python/plugins/processing/algs/gdal/GdalAlgorithm.py b/python/plugins/processing/algs/gdal/GdalAlgorithm.py
index 2591311685d..be93eb89518 100644
--- a/python/plugins/processing/algs/gdal/GdalAlgorithm.py
+++ b/python/plugins/processing/algs/gdal/GdalAlgorithm.py
@@ -95,10 +95,11 @@ class GdalAlgorithm(GeoAlgorithm):
'''.format(self.commandName(), url)
def commandName(self):
+ parameters = {}
for output in self.outputs:
output.setValue("dummy")
- for param in self.parameters:
- param.setValue("1")
+ for param in self.parameterDefinitions():
+ parameters[param.name()] = "1"
name = self.getConsoleCommands(parameters)[0]
if name.endswith(".py"):
name = name[:-3]
diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py
index 95694080f20..ad757eb1867 100644
--- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py
+++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py
@@ -132,11 +132,11 @@ class Grass7Algorithm(GeoAlgorithm):
lines = infile.readlines()
for i in range(len(lines)):
if lines[i].startswith('
'):
- for param in self.parameters:
- searchLine = '' + param.name + ''
+ for param in self.parameterDefinitions():
+ searchLine = '' + param.name() + ''
if searchLine in lines[i]:
i += 1
- descs[param.name] = (lines[i])[4:-6]
+ descs[param.name()] = (lines[i])[4:-6]
break
except Exception:
@@ -217,14 +217,14 @@ class Grass7Algorithm(GeoAlgorithm):
param.setFlags(param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
self.addParameter(param)
- def getDefaultCellsize(self):
- context = dataobjects.createContext()
+ def getDefaultCellsize(self, parameters, context):
cellsize = 0
- for param in self.parameters:
- if param.value:
+ for param in self.parameterDefinitions():
+ if param.name() in parameters:
+ value = parameters[param.name()]
if isinstance(param, ParameterRaster):
- if isinstance(param.value, QgsRasterLayer):
- layer = param.value
+ if isinstance(value, QgsRasterLayer):
+ layer = value
else:
layer = QgsProcessingUtils.mapLayerFromString(param.value, context)
cellsize = max(cellsize, (layer.extent().xMaximum() -
@@ -232,7 +232,7 @@ class Grass7Algorithm(GeoAlgorithm):
layer.width())
elif isinstance(param, ParameterMultipleInput):
- layers = param.value.split(';')
+ layers = value.split(';')
for layername in layers:
layer = QgsProcessingUtils.mapLayerFromString(layername, context)
if isinstance(layer, QgsRasterLayer):
@@ -274,7 +274,7 @@ class Grass7Algorithm(GeoAlgorithm):
func = getattr(self.module, 'processInputs')
func(self)
else:
- self.processInputs()
+ self.processInputs(parameters,context)
if hasattr(self.module, 'processCommand'):
func = getattr(self.module, 'processCommand')
@@ -288,7 +288,7 @@ class Grass7Algorithm(GeoAlgorithm):
else:
self.processOutputs()
else:
- self.processInputs()
+ self.processInputs(parameters,context)
self.processCommand()
self.processOutputs()
@@ -317,13 +317,13 @@ class Grass7Algorithm(GeoAlgorithm):
else:
Grass7Utils.endGrass7Session()
- def processInputs(self):
+ def processInputs(self, parameters, context):
"""Prepare the GRASS import commands"""
- for param in self.parameters:
+ for param in self.parameterDefinitions():
if isinstance(param, ParameterRaster):
- if param.value is None:
+ if not param.name() in parameters():
continue
- value = param.value
+ value = parameters[param.name()]
# Check if the layer hasn't already been exported in, for
# example, previous GRASS calls in this session
@@ -333,9 +333,9 @@ class Grass7Algorithm(GeoAlgorithm):
self.setSessionProjectionFromLayer(value, self.commands)
self.commands.append(self.exportRasterLayer(value))
if isinstance(param, ParameterVector):
- if param.value is None:
+ if not param.name() in parameters():
continue
- value = param.value
+ value = parameters[param.name()]
if value in list(self.exportedLayers.keys()):
continue
else:
@@ -344,9 +344,10 @@ class Grass7Algorithm(GeoAlgorithm):
if isinstance(param, ParameterTable):
pass
if isinstance(param, ParameterMultipleInput):
- if param.value is None:
+ if not param.name() in parameters():
continue
- layers = param.value.split(';')
+ value = parameters[param.name()]
+ layers = value.split(';')
if layers is None or len(layers) == 0:
continue
if param.datatype == dataobjects.TYPE_RASTER:
@@ -384,7 +385,7 @@ class Grass7Algorithm(GeoAlgorithm):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(self.getDefaultCellsize())
+ command += ' res=' + str(self.getDefaultCellsize(parameters, context))
alignToResolution = \
self.getParameterValue(self.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
diff --git a/python/plugins/processing/algs/grass7/ext/i.py b/python/plugins/processing/algs/grass7/ext/i.py
index aeb56057190..cf4cef784c8 100644
--- a/python/plugins/processing/algs/grass7/ext/i.py
+++ b/python/plugins/processing/algs/grass7/ext/i.py
@@ -93,7 +93,7 @@ def orderedInput(alg, inputParameter, targetParameterDef, numSeq=None):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = \
alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
diff --git a/python/plugins/processing/algs/grass7/ext/r_blend_combine.py b/python/plugins/processing/algs/grass7/ext/r_blend_combine.py
index 39eb685d3b5..5f4e951149e 100644
--- a/python/plugins/processing/algs/grass7/ext/r_blend_combine.py
+++ b/python/plugins/processing/algs/grass7/ext/r_blend_combine.py
@@ -57,7 +57,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py b/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py
index 98c1e4b069b..aec81a8c255 100644
--- a/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py
+++ b/python/plugins/processing/algs/grass7/ext/r_blend_rgb.py
@@ -59,7 +59,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_category.py b/python/plugins/processing/algs/grass7/ext/r_category.py
index 538250353d1..04b67143812 100644
--- a/python/plugins/processing/algs/grass7/ext/r_category.py
+++ b/python/plugins/processing/algs/grass7/ext/r_category.py
@@ -75,13 +75,13 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
alg.commands.append(command)
else:
- alg.processInputs()
+ alg.processInputs(context, parameters)
def processCommand(alg, parameters):
diff --git a/python/plugins/processing/algs/grass7/ext/r_colors.py b/python/plugins/processing/algs/grass7/ext/r_colors.py
index 64ed1d67e94..ad73c812a00 100644
--- a/python/plugins/processing/algs/grass7/ext/r_colors.py
+++ b/python/plugins/processing/algs/grass7/ext/r_colors.py
@@ -65,7 +65,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py b/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py
index 1a27c4dbb5b..0bc283a583f 100644
--- a/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py
+++ b/python/plugins/processing/algs/grass7/ext/r_colors_stddev.py
@@ -53,7 +53,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters, context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_mapcalc.py b/python/plugins/processing/algs/grass7/ext/r_mapcalc.py
index 58d35f7b23a..546c90448c5 100644
--- a/python/plugins/processing/algs/grass7/ext/r_mapcalc.py
+++ b/python/plugins/processing/algs/grass7/ext/r_mapcalc.py
@@ -67,7 +67,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters,context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_null.py b/python/plugins/processing/algs/grass7/ext/r_null.py
index 9f73aa2ed4e..9f3440e057c 100644
--- a/python/plugins/processing/algs/grass7/ext/r_null.py
+++ b/python/plugins/processing/algs/grass7/ext/r_null.py
@@ -62,7 +62,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters,context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_rgb.py b/python/plugins/processing/algs/grass7/ext/r_rgb.py
index 02b36b24e5b..7b5e3525ac5 100644
--- a/python/plugins/processing/algs/grass7/ext/r_rgb.py
+++ b/python/plugins/processing/algs/grass7/ext/r_rgb.py
@@ -55,7 +55,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters,context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_shade.py b/python/plugins/processing/algs/grass7/ext/r_shade.py
index af57d6b8669..ffc4a709b72 100644
--- a/python/plugins/processing/algs/grass7/ext/r_shade.py
+++ b/python/plugins/processing/algs/grass7/ext/r_shade.py
@@ -63,7 +63,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters,context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/r_what_color.py b/python/plugins/processing/algs/grass7/ext/r_what_color.py
index 53f88fbc803..ad111cfb1aa 100644
--- a/python/plugins/processing/algs/grass7/ext/r_what_color.py
+++ b/python/plugins/processing/algs/grass7/ext/r_what_color.py
@@ -53,7 +53,7 @@ def processInputs(alg):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(alg.getDefaultCellsize())
+ command += ' res=' + str(alg.getDefaultCellsize(parameters,context))
alignToResolution = alg.getParameterValue(alg.GRASS_REGION_ALIGN_TO_RESOLUTION)
if alignToResolution:
command += ' -a'
diff --git a/python/plugins/processing/algs/grass7/ext/v_lrs_segment.py b/python/plugins/processing/algs/grass7/ext/v_lrs_segment.py
index 8c5570bf10c..4d699f209f4 100644
--- a/python/plugins/processing/algs/grass7/ext/v_lrs_segment.py
+++ b/python/plugins/processing/algs/grass7/ext/v_lrs_segment.py
@@ -45,7 +45,7 @@ def processInputs(alg):
alg.exportedLayers[rstable]
)
alg.commands.append(command)
- alg.processInputs()
+ alg.processInputs(context,parameters)
def processCommand(alg, parameters):
diff --git a/python/plugins/processing/algs/grass7/ext/v_lrs_where.py b/python/plugins/processing/algs/grass7/ext/v_lrs_where.py
index bd88625ba2a..0aef023f02d 100644
--- a/python/plugins/processing/algs/grass7/ext/v_lrs_where.py
+++ b/python/plugins/processing/algs/grass7/ext/v_lrs_where.py
@@ -37,7 +37,7 @@ def processInputs(alg):
alg.exportedLayers[rstable]
)
alg.commands.append(command)
- alg.processInputs()
+ alg.processInputs(parameters,context)
def processCommand(alg, parameters):
diff --git a/python/plugins/processing/algs/grass7/nviz7.py b/python/plugins/processing/algs/grass7/nviz7.py
index aec5857cd7b..e60cabd57ae 100644
--- a/python/plugins/processing/algs/grass7/nviz7.py
+++ b/python/plugins/processing/algs/grass7/nviz7.py
@@ -115,7 +115,7 @@ class nviz7(GeoAlgorithm):
if cellsize:
command += ' res=' + str(cellsize)
else:
- command += ' res=' + str(self.getDefaultCellsize())
+ command += ' res=' + str(self.getDefaultCellsize(parameters,context))
commands.append(command)
command = 'nviz7'
@@ -170,22 +170,22 @@ class nviz7(GeoAlgorithm):
command += ' --overwrite -o'
return (command, destFilename)
- def getDefaultCellsize(self):
+ def getDefaultCellsize(self, parameters, context):
cellsize = 0
- context = dataobjects.createContext()
- for param in self.parameters:
- if param.value:
+ for param in self.parameterDefinitions():
+ if param.name() in parameters:
+ value = parameters[param.name()]
if isinstance(param, ParameterRaster):
- if isinstance(param.value, QgsRasterLayer):
- layer = param.value
+ if isinstance(value, QgsRasterLayer):
+ layer = value
else:
- layer = QgsProcessingUtils.mapLayerFromString(param.value, context)
+ layer = QgsProcessingUtils.mapLayerFromString(value, context)
cellsize = max(cellsize, (layer.extent().xMaximum() -
layer.extent().xMinimum()) /
layer.width())
elif isinstance(param, ParameterMultipleInput):
- layers = param.value.split(';')
+ layers = value.split(';')
for layername in layers:
layer = QgsProcessingUtils.mapLayerFromString(layername, context)
if isinstance(layer, QgsRasterLayer):