Skip to content
Permalink
Browse files

renamed ParameterExpression in raster calculator to avoid name clash

  • Loading branch information
volaya committed Dec 1, 2016
1 parent 44f963f commit 40053f81f22c63cc12458da8246da2fb5aad5c35
Showing with 11 additions and 11 deletions.
  1. +11 −11 python/plugins/processing/algs/qgis/RasterCalculator.py
@@ -55,17 +55,17 @@ def defineCharacteristics(self):
self.tr('Input layers'),
datatype=dataobjects.TYPE_RASTER,
optional=True,
metadata = {'widget_wrapper': LayersListWidgetWrapper}))
class ParameterExpression(ParameterString):
def evaluateForModeler(self, value, model):
#print value
metadata={'widget_wrapper': LayersListWidgetWrapper}))
class ParameterRasterCalculatorExpression(ParameterString):
def evaluateForModeler(self, value, model):
# print value
for i in list(model.inputs.values()):
param = i.param
if isinstance(param, ParameterRaster):
new = "%s@" % os.path.basename(param.value)
old = "%s@" % param.name
value = value.replace(old, new)

for alg in list(model.algs.values()):
for out in alg.algorithm.outputs:
if isinstance(out, OutputRaster):
@@ -75,15 +75,15 @@ def evaluateForModeler(self, value, model):
value = value.replace(old, new)
return value

self.addParameter(ParameterExpression(self.EXPRESSION, self.tr('Expression'),
self.addParameter(ParameterRasterCalculatorExpression(self.EXPRESSION, self.tr('Expression'),
multiline=True,
metadata = {'widget_wrapper': ExpressionWidgetWrapper}))
metadata={'widget_wrapper': ExpressionWidgetWrapper}))
self.addParameter(ParameterNumber(self.CELLSIZE,
self.tr('Cellsize (use 0 or empty to set it automatically)'),
minValue=0.0, default=0.0, optional=True))
self.addParameter(ParameterExtent(self.EXTENT,
self.tr('Output extent'),
optional=True))
optional=True))
self.addOutput(OutputRaster(self.OUTPUT, self.tr('Output')))


@@ -149,15 +149,15 @@ def processBeforeAddingToModeler(self, algorithm, model):
if isinstance(param, ParameterRaster) and "%s@" % param.name in expression:
values.append(ValueFromInput(param.name))

if algorithm.name:
if algorithm.name:
dependent = model.getDependentAlgorithms(algorithm.name)
else:
dependent = []
for alg in list(model.algs.values()):
if alg.name not in dependent:
for out in alg.algorithm.outputs:
if (isinstance(out, OutputRaster)
if (isinstance(out, OutputRaster)
and "%s:%s@" % (alg.name, out.name) in expression):
values.append(ValueFromOutput(alg.name, out.name))

algorithm.params[self.LAYERS] = values
algorithm.params[self.LAYERS] = values

0 comments on commit 40053f8

Please sign in to comment.
You can’t perform that action at this time.