当前位置: 首页>>代码示例>>Python>>正文


Python parameters.ParameterSelection类代码示例

本文整理汇总了Python中processing.core.parameters.ParameterSelection的典型用法代码示例。如果您正苦于以下问题:Python ParameterSelection类的具体用法?Python ParameterSelection怎么用?Python ParameterSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ParameterSelection类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMultiple

 def testMultiple(self):
     parameter = ParameterSelection("myName", "myDesc", ["option1", "option2", "option3"], multiple=True)
     self.assertEqual(parameter.setValue(1), True)
     self.assertEqual(parameter.value, 1)
     self.assertEqual(parameter.setValue([0, 1]), True)
     self.assertEqual(parameter.value, [0, 1])
     self.assertEqual(parameter.setValue(["0", "1"]), True)
     self.assertEqual(parameter.value, [0, 1])
开发者ID:kalxas,项目名称:QGIS,代码行数:8,代码来源:ParametersTest.py

示例2: defineCharacteristicsFromFile

    def defineCharacteristicsFromFile(self):
        with open(self.descriptionFile) as lines:
            line = lines.readline().strip('\n').strip()
            self.name = line
            if '|' in self.name:
                tokens = self.name.split('|')
                self.name = tokens[0]
                #cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
                self.cmdname = tokens[1]

            else:
                self.cmdname = self.name
                self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", str(self.name))
            #_commandLineName is the name used in processing to call the algorithm
            #Most of the time will be equal to the cmdname, but in same cases, several processing algorithms
            #call the same SAGA one
            self._commandLineName = self.createCommandLineName(self.name)
            self.name = decoratedAlgorithmName(self.name)
            self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", str(self.name))
            line = lines.readline().strip('\n').strip()
            self.undecoratedGroup = line
            self.group = decoratedGroupName(self.undecoratedGroup)
            self.i18n_group = QCoreApplication.translate("SAGAAlgorithm", self.group)
            line = lines.readline().strip('\n').strip()
            while line != '':
                if line.startswith('Hardcoded'):
                    self.hardcodedStrings.append(line[len('Hardcoded|'):])
                elif line.startswith('Parameter'):
                    self.addParameter(getParameterFromString(line))
                elif line.startswith('AllowUnmatching'):
                    self.allowUnmatchingGridExtents = True
                elif line.startswith('NoResamplingChoice'):
                    self.noResamplingChoice = True
                elif line.startswith('Extent'):
                    # An extent parameter that wraps 4 SAGA numerical parameters
                    self.extentParamNames = line[6:].strip().split(' ')
                    self.addParameter(ParameterExtent(self.OUTPUT_EXTENT,
                                                      'Output extent'))
                else:
                    self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
            hasRaster = False
            for param in self.parameters:
                if (isinstance(param, ParameterRaster) or
                    (isinstance(param, ParameterMultipleInput)
                        and param.datatype == ParameterMultipleInput.TYPE_RASTER)):
                    hasRaster = True
                    break

            if (not self.noResamplingChoice and hasRaster):
                param = ParameterSelection(self.RESAMPLING, "Resampling method", ["Nearest Neighbour", "Bilinear Interpolation", "Bicubic Spline Interpolation", "B-Spline Interpolation"], 3)
                param.isAdvanced = True
                self.addParameter(param)
开发者ID:DHI-GRAS,项目名称:ESA_Processing,代码行数:53,代码来源:SagaAlgorithm.py

示例3: __init__

    def __init__(self):
        super().__init__()
        self.addParameter(ParameterVector(self.INPUT_LAYER,
                                          self.tr('Point layer'), [dataobjects.TYPE_VECTOR_POINT]))
        self.addParameter(ParameterNumber(self.RADIUS,
                                          self.tr('Radius (layer units)'),
                                          0.0, 9999999999, 100.0))

        radius_field_param = ParameterTableField(self.RADIUS_FIELD,
                                                 self.tr('Radius from field'), self.INPUT_LAYER, optional=True, datatype=ParameterTableField.DATA_TYPE_NUMBER)
        radius_field_param.setFlags(radius_field_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(radius_field_param)

        class ParameterHeatmapPixelSize(ParameterNumber):

            def __init__(self, name='', description='', parent_layer=None, radius_param=None, radius_field_param=None, minValue=None, maxValue=None,
                         default=None, optional=False, metadata={}):
                ParameterNumber.__init__(self, name, description, minValue, maxValue, default, optional, metadata)
                self.parent_layer = parent_layer
                self.radius_param = radius_param
                self.radius_field_param = radius_field_param

        self.addParameter(ParameterHeatmapPixelSize(self.PIXEL_SIZE,
                                                    self.tr('Output raster size'), parent_layer=self.INPUT_LAYER, radius_param=self.RADIUS,
                                                    radius_field_param=self.RADIUS_FIELD,
                                                    minValue=0.0, maxValue=9999999999, default=0.1,
                                                    metadata={'widget_wrapper': HeatmapPixelSizeWidgetWrapper}))

        weight_field_param = ParameterTableField(self.WEIGHT_FIELD,
                                                 self.tr('Weight from field'), self.INPUT_LAYER, optional=True, datatype=ParameterTableField.DATA_TYPE_NUMBER)
        weight_field_param.setFlags(weight_field_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(weight_field_param)
        kernel_shape_param = ParameterSelection(self.KERNEL,
                                                self.tr('Kernel shape'), self.KERNELS)
        kernel_shape_param.setFlags(kernel_shape_param.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(kernel_shape_param)
        decay_ratio = ParameterNumber(self.DECAY,
                                      self.tr('Decay ratio (Triangular kernels only)'),
                                      -100.0, 100.0, 0.0)
        decay_ratio.setFlags(decay_ratio.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(decay_ratio)
        output_scaling = ParameterSelection(self.OUTPUT_VALUE,
                                            self.tr('Output value scaling'), self.OUTPUT_VALUES)
        output_scaling.setFlags(output_scaling.flags() | QgsProcessingParameterDefinition.FlagAdvanced)
        self.addParameter(output_scaling)
        self.addOutput(OutputRaster(self.OUTPUT_LAYER,
                                    self.tr('Heatmap')))
开发者ID:rskelly,项目名称:QGIS,代码行数:47,代码来源:Heatmap.py

示例4: testOptional

    def testOptional(self):
        optionalParameter = ParameterSelection(
            "myName", "myDesc", ["option1", "option2", "option3"], default=0, optional=True
        )
        self.assertEqual(optionalParameter.value, 0)
        optionalParameter.setValue(1)
        self.assertEqual(optionalParameter.value, 1)
        self.assertTrue(optionalParameter.setValue(None))
        self.assertEqual(optionalParameter.value, None)

        requiredParameter = ParameterSelection(
            "myName", "myDesc", ["option1", "option2", "option3"], default=0, optional=False
        )
        self.assertEqual(requiredParameter.value, 0)
        requiredParameter.setValue(1)
        self.assertEqual(requiredParameter.value, 1)
        self.assertFalse(requiredParameter.setValue(None))
        self.assertEqual(requiredParameter.value, 1)
开发者ID:kalxas,项目名称:QGIS,代码行数:18,代码来源:ParametersTest.py

示例5: testSetValue

 def testSetValue(self):
     parameter = ParameterSelection("myName", "myDesc", ["option1", "option2", "option3"])
     self.assertIsNone(parameter.value)
     self.assertEqual(parameter.setValue(1), True)
     self.assertEqual(parameter.value, 1)
     self.assertEqual(parameter.setValue("1"), True)
     self.assertEqual(parameter.value, 1)
     self.assertEqual(parameter.setValue(1.0), True)
     self.assertEqual(parameter.value, 1)
     self.assertEqual(parameter.setValue("1a"), False)
     self.assertEqual(parameter.setValue([1]), False)
开发者ID:kalxas,项目名称:QGIS,代码行数:11,代码来源:ParametersTest.py

示例6: testTupleOptions

    def testTupleOptions(self):
        options = (("o1", "option1"), ("o2", "option2"), ("o3", "option3"))

        optionalParameter = ParameterSelection("myName", "myDesc", options, default="o1")
        self.assertEqual(optionalParameter.value, "o1")
        optionalParameter.setValue("o2")
        self.assertEqual(optionalParameter.value, "o2")

        optionalParameter = ParameterSelection("myName", "myDesc", options, default=["o1", "o2"], multiple=True)
        self.assertEqual(optionalParameter.value, ["o1", "o2"])
        optionalParameter.setValue(["o2"])
        self.assertEqual(optionalParameter.value, ["o2"])
开发者ID:kalxas,项目名称:QGIS,代码行数:12,代码来源:ParametersTest.py

示例7: testTupleOptions

    def testTupleOptions(self):
        options = (
            ('o1', 'option1'),
            ('o2', 'option2'),
            ('o3', 'option3'))

        optionalParameter = ParameterSelection('myName', 'myDesc', options, default='o1')
        self.assertEqual(optionalParameter.value, 'o1')
        optionalParameter.setValue('o2')
        self.assertEqual(optionalParameter.value, 'o2')

        optionalParameter = ParameterSelection('myName', 'myDesc', options, default=['o1', 'o2'], multiple=True)
        self.assertEqual(optionalParameter.value, ['o1', 'o2'])
        optionalParameter.setValue(['o2'])
        self.assertEqual(optionalParameter.value, ['o2'])
开发者ID:GeoCat,项目名称:QGIS,代码行数:15,代码来源:ParametersTest.py


注:本文中的processing.core.parameters.ParameterSelection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。