Skip to content

Commit

Permalink
[processing] fix input rasters check
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 9, 2017
1 parent 13610f6 commit 057ab17
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions python/plugins/processing/algs/saga/SagaAlgorithm.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -381,25 +381,26 @@ def checkParameterValues(self, parameters, context):
supported by SAGA, and that raster layers have the same grid extent supported by SAGA, and that raster layers have the same grid extent
""" """
extent = None extent = None
layers = []
for param in self.parameterDefinitions(): for param in self.parameterDefinitions():
layers = []
if isinstance(param, QgsProcessingParameterRasterLayer): if isinstance(param, QgsProcessingParameterRasterLayer):
layers.append(parameters[param.name()]) layers.append(parameters[param.name()])
elif (isinstance(param, QgsProcessingParameterMultipleLayers) and elif (isinstance(param, QgsProcessingParameterMultipleLayers) and
param.datatype == QgsProcessing.TypeRaster): param.layerType() == QgsProcessing.TypeRaster):
if parameters[param.name()] is not None: if parameters[param.name()]:
layers.append(parameters[param.name()]) layers.extend(parameters[param.name()])
for layer in layers:
if layer is None: for layer in layers:
continue if layer is None or layer == '':
if layer.bandCount() > 1: continue
return False, self.tr('Input layer {0} has more than one band.\n' if layer.bandCount() > 1:
'Multiband layers are not supported by SAGA').format(layer.name()) return False, self.tr('Input layer {0} has more than one band.\n'
if not self.allow_nonmatching_grid_extents: 'Multiband layers are not supported by SAGA').format(layer.name())
if extent is None: if not self.allow_nonmatching_grid_extents:
extent = (layer.extent(), layer.height(), layer.width()) if extent is None:
else: extent = (layer.extent(), layer.height(), layer.width())
extent2 = (layer.extent(), layer.height(), layer.width()) else:
if extent != extent2: extent2 = (layer.extent(), layer.height(), layer.width())
return False, self.tr("Input layers do not have the same grid extent.") if extent != extent2:
return False, self.tr("Input layers do not have the same grid extent.")
return super(SagaAlgorithm, self).checkParameterValues(parameters, context) return super(SagaAlgorithm, self).checkParameterValues(parameters, context)

0 comments on commit 057ab17

Please sign in to comment.