Skip to content

Commit

Permalink
[processing][grass] Fix r.colors (color or rules or raster parameter)
Browse files Browse the repository at this point in the history
Allow to use either the color parameter or the rules parameter or the raster parameter
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Aug 7, 2024
1 parent 893da91 commit b80bd0a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/plugins/grassprovider/ext/r_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit b80bd0a

Please sign in to comment.