[processing][grass] Fix r.colors (color or rules or raster parameter)

Allow to use either the color parameter or the rules parameter or the raster parameter
This commit is contained in:
Andrea Giudiceandrea 2024-08-06 04:33:42 +02:00 committed by Nyall Dawson
parent 893da91e32
commit b80bd0afa0

View File

@ -31,6 +31,12 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
if txtRules and rules:
return False, alg.tr("You need to set either inline rules or a rules file!")
rules_or_txtRules = bool(txtRules or rules)
color = bool(alg.parameterAsEnum(parameters, 'color', context))
raster = bool(alg.parameterAsString(parameters, 'raster', context))
if not sum([rules_or_txtRules, color, raster]) == 1:
return False, alg.tr("The color table, color rules and raster map parameters are mutually exclusive. You need to set one and only one of them!")
return True, None
@ -64,6 +70,9 @@ def processCommand(alg, parameters, context, feedback):
alg.removeParameter('txtrules')
parameters['rules'] = tempRulesName
if alg.parameterAsEnum(parameters, 'color', context) == 0:
alg.removeParameter('color')
alg.processCommand(parameters, context, feedback, True)