From 0b749558b9d47ecff38b3d323c7942956a084b4c Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Sun, 5 Jan 2020 13:34:55 +0200 Subject: [PATCH] [processing] add proper support for range parameters (fix #29269) --- python/plugins/processing/algs/grass7/Grass7Algorithm.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python/plugins/processing/algs/grass7/Grass7Algorithm.py b/python/plugins/processing/algs/grass7/Grass7Algorithm.py index f7a9e712700d..fcb06099a051 100644 --- a/python/plugins/processing/algs/grass7/Grass7Algorithm.py +++ b/python/plugins/processing/algs/grass7/Grass7Algorithm.py @@ -25,6 +25,7 @@ import os import re import uuid +import math import importlib from qgis.PyQt.QtCore import QCoreApplication, QUrl @@ -48,6 +49,7 @@ QgsProcessingParameterField, QgsProcessingParameterPoint, QgsProcessingParameterBoolean, + QgsProcessingParameterRange, QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer, QgsProcessingParameterRasterLayer, @@ -617,6 +619,12 @@ def processCommand(self, parameters, context, feedback, delOutputs=False): elif isinstance(param, (QgsProcessingParameterNumber, QgsProcessingParameterPoint)): value = self.parameterAsString(parameters, paramName, context) + elif isinstance(param, QgsProcessingParameterRange): + v = self.parameterAsRange(parameters, paramName, context) + if (param.flags() & QgsProcessingParameterDefinition.FlagOptional) and (math.isnan(v[0]) or math.isnan(v[1])): + continue + else: + value = '{},{}'.format(v[0], v[1]) # For everything else, we assume that it is a string else: value = '"{}"'.format(