Skip to content

Commit

Permalink
[processing][saga] Fix error in raster calculator
Browse files Browse the repository at this point in the history
Fixes #18751
  • Loading branch information
nyalldawson committed Jun 4, 2018
1 parent a1d46de commit 268aa17
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/saga/SagaAlgorithm.py
Expand Up @@ -261,7 +261,8 @@ def processAlgorithm(self, parameters, context, feedback):
if isinstance(param, (QgsProcessingParameterRasterLayer, QgsProcessingParameterFeatureSource)):
command += ' -{} "{}"'.format(param.name(), self.exportedLayers[param.name()])
elif isinstance(param, QgsProcessingParameterMultipleLayers):
command += ' -{} "{}"'.format(param.name(), ';'.join(self.exportedLayers[param.name()]))
if parameters[param.name()]: # parameter may have been an empty list
command += ' -{} "{}"'.format(param.name(), ';'.join(self.exportedLayers[param.name()]))
elif isinstance(param, QgsProcessingParameterBoolean):
if self.parameterAsBool(parameters, param.name(), context):
command += ' -{} true'.format(param.name().strip())
Expand Down
60 changes: 60 additions & 0 deletions python/plugins/processing/tests/testdata/saga_algorithm_tests.yaml
Expand Up @@ -67,3 +67,63 @@ tests:
GRID_OUT:
hash: 57437ebf7eb3667c5aa390598120967b0a2cd5d85751185bb445d1f8
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 1 input
params:
FORMULA: a*10
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params: []
type: multi
results:
RESULT:
hash: 68d805a45416467e0f1be3066dd642772cf8ffdff9535f3254cd5ffb
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 2 inputs
params:
FORMULA: a*10+b
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params:
- name: raster.tif
type: raster
type: multi
results:
RESULT:
hash: c8c2c7c32ad3eaa1ebb491aed7af7d16f1c7f574a3de1f7622894092
type: rasterhash

- algorithm: saga:rastercalculator
name: Raster calculator, 3 inputs
params:
FORMULA: a*10+b-c
GRIDS:
name: raster.tif
type: raster
RESAMPLING: 3
TYPE: 7
USE_NODATA: false
XGRIDS:
params:
- name: dem.tif
type: raster
- name: raster.tif
type: raster
type: multi
results:
RESULT:
hash: a11f159696f5726eedaa16e872fd2582cf8a88c8c1d84d72560e4647
type: rasterhash

2 comments on commit 268aa17

@ghtmtt
Copy link
Contributor

@ghtmtt ghtmtt commented on 268aa17 Jun 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson testing this fix. With simple operations (a*100) no problems, but with something like a>1000 I get an output as point vector (empty). Should I reopen the ticket?

Thanks!

@nyalldawson
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ghtmtt check if it actually works in saga first... And if so, see if you can find what's wrong with the command qgis passes to saga

Please sign in to comment.