Skip to content
Permalink
Browse files

[processing] fix input rasters check

  • Loading branch information
alexbruy committed Nov 7, 2017
1 parent 13610f6 commit 057ab170da7c88dc946ae80b307853582e653f0a
Showing with 18 additions and 17 deletions.
  1. +18 −17 python/plugins/processing/algs/saga/SagaAlgorithm.py
@@ -381,25 +381,26 @@ def checkParameterValues(self, parameters, context):
supported by SAGA, and that raster layers have the same grid extent
"""
extent = None
layers = []
for param in self.parameterDefinitions():
layers = []
if isinstance(param, QgsProcessingParameterRasterLayer):
layers.append(parameters[param.name()])
elif (isinstance(param, QgsProcessingParameterMultipleLayers) and
param.datatype == QgsProcessing.TypeRaster):
if parameters[param.name()] is not None:
layers.append(parameters[param.name()])
for layer in layers:
if layer is None:
continue
if layer.bandCount() > 1:
return False, self.tr('Input layer {0} has more than one band.\n'
'Multiband layers are not supported by SAGA').format(layer.name())
if not self.allow_nonmatching_grid_extents:
if extent is None:
extent = (layer.extent(), layer.height(), layer.width())
else:
extent2 = (layer.extent(), layer.height(), layer.width())
if extent != extent2:
return False, self.tr("Input layers do not have the same grid extent.")
param.layerType() == QgsProcessing.TypeRaster):
if parameters[param.name()]:
layers.extend(parameters[param.name()])

for layer in layers:
if layer is None or layer == '':
continue
if layer.bandCount() > 1:
return False, self.tr('Input layer {0} has more than one band.\n'
'Multiband layers are not supported by SAGA').format(layer.name())
if not self.allow_nonmatching_grid_extents:
if extent is None:
extent = (layer.extent(), layer.height(), layer.width())
else:
extent2 = (layer.extent(), layer.height(), layer.width())
if extent != extent2:
return False, self.tr("Input layers do not have the same grid extent.")
return super(SagaAlgorithm, self).checkParameterValues(parameters, context)

0 comments on commit 057ab17

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