Skip to content
Permalink
Browse files

[processing][OTB] deal with parameter type Enum and Band

  • Loading branch information
troopa81 authored and nyalldawson committed Jan 5, 2021
1 parent cf3bee3 commit bb3e1a554cdb26b022141c35fd692af162661f7d
Showing with 9 additions and 2 deletions.
  1. +9 −2 python/plugins/processing/algs/otb/OtbAlgorithm.py
@@ -45,7 +45,8 @@
QgsProcessingParameterNumber,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterVectorDestination,
QgsProcessingParameterEnum)
QgsProcessingParameterEnum,
QgsProcessingParameterBand)

from processing.core.parameters import getParameterFromString
from processing.algs.otb.OtbChoiceWidget import OtbParameterChoice
@@ -213,8 +214,12 @@ def processAlgorithm(self, parameters, context, feedback):
param = self.parameterDefinition(k)
if param.isDestination():
continue
if isinstance(param, QgsProcessingParameterEnum):
if isinstance(param, QgsProcessingParameterEnum) and param.name() == "outputpixeltype":
value = self.parameterAsEnum(parameters, param.name(), context)
elif isinstance(param, QgsProcessingParameterEnum):
value = " ".join([param.options()[i]
for i in self.parameterAsEnums(parameters, param.name(), context)
if i >= 0 and i < len(param.options())])
elif isinstance(param, QgsProcessingParameterBoolean):
value = self.parameterAsBoolean(parameters, param.name(), context)
elif isinstance(param, QgsProcessingParameterCrs):
@@ -243,6 +248,8 @@ def processAlgorithm(self, parameters, context, feedback):
value = '"{}"'.format(self.getLayerSource(param.name(), self.parameterAsLayer(parameters, param.name(), context)))
elif isinstance(param, QgsProcessingParameterString):
value = '"{}"'.format(self.parameterAsString(parameters, param.name(), context))
elif isinstance(param, QgsProcessingParameterBand):
value = '"Channel{}"'.format(self.parameterAsInt(parameters, param.name(), context))
else:
# Use whatever is given
value = '"{}"'.format(parameters[param.name()])

0 comments on commit bb3e1a5

Please sign in to comment.
You can’t perform that action at this time.