Skip to content

Commit

Permalink
[processing] multidirectional and combined shading options are mutually
Browse files Browse the repository at this point in the history
exclusive (fix #45957)
  • Loading branch information
alexbruy authored and github-actions[bot] committed Nov 9, 2021
1 parent bd608ab commit e6bd1b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/plugins/processing/algs/gdal/hillshade.py
Expand Up @@ -168,11 +168,13 @@ def getConsoleCommands(self, parameters, context, feedback, executing=True):
arguments.append('-alg')
arguments.append('ZevenbergenThorne')

if self.parameterAsBoolean(parameters, self.COMBINED, context):
combined = self.parameterAsBoolean(parameters, self.COMBINED, context)
if combined and not multidirectional:
arguments.append('-combined')

if multidirectional:
elif multidirectional and not combined:
arguments.append('-multidirectional')
elif multidirectional and combined:
raise QgsProcessingException(self.tr('Options -multirectional and -combined are mutually exclusive.'))

options = self.parameterAsString(parameters, self.OPTIONS, context)
if options:
Expand Down
13 changes: 13 additions & 0 deletions python/plugins/processing/tests/GdalAlgorithmsRasterTest.py
Expand Up @@ -27,6 +27,7 @@
import tempfile

from qgis.core import (QgsProcessingContext,
QgsProcessingException,
QgsProcessingFeedback,
QgsRectangle,
QgsRasterLayer,
Expand Down Expand Up @@ -1206,6 +1207,18 @@ def testHillshade(self):
source + ' ' +
outdir + '/check.tif -of GTiff -b 1 -z 1.0 -s 1.0 -az 315.0 -alt 45.0 -q'])

# multidirectional and combined are mutually exclusive
self.assertRaises(
QgsProcessingException,
lambda: alg.getConsoleCommands({'INPUT': source,
'BAND': 1,
'Z_FACTOR': 5,
'SCALE': 2,
'AZIMUTH': 90,
'COMBINED': True,
'MULTIDIRECTIONAL': True,
'OUTPUT': outdir + '/check.tif'}, context, feedback))

def testAspect(self):
context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
Expand Down

0 comments on commit e6bd1b6

Please sign in to comment.