Skip to content
Permalink
Browse files
[processing] multidirectional and combined shading options are mutually
exclusive (fix #45957)
  • Loading branch information
alexbruy authored and github-actions committed Nov 9, 2021
1 parent bd608ab commit e6bd1b62f231daa028463fb36f1b5b8f8669a432
Showing with 18 additions and 3 deletions.
  1. +5 −3 python/plugins/processing/algs/gdal/hillshade.py
  2. +13 −0 python/plugins/processing/tests/GdalAlgorithmsRasterTest.py
@@ -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:
@@ -27,6 +27,7 @@
import tempfile

from qgis.core import (QgsProcessingContext,
QgsProcessingException,
QgsProcessingFeedback,
QgsRectangle,
QgsRasterLayer,
@@ -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()

0 comments on commit e6bd1b6

Please sign in to comment.