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


Python parameters.ParameterCrs类代码示例

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


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

示例1: testScriptCode

    def testScriptCode(self):
        parameter = ParameterCrs('myName', 'myDescription')
        code = parameter.getAsScriptCode()
        result = getParameterFromString(code)
        self.assertIsInstance(result, ParameterCrs)

        parameter.optional = True
        code = parameter.getAsScriptCode()
        result = getParameterFromString(code)
        self.assertIsInstance(result, ParameterCrs)
        self.assertTrue(result.optional)
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: testOptional

    def testOptional(self):
        optionalParameter = ParameterString('myName', 'myDesc', default='test', optional=True)
        self.assertEqual(optionalParameter.value, 'test')
        optionalParameter.setValue('check')
        self.assertEqual(optionalParameter.value, 'check')
        self.assertTrue(optionalParameter.setValue(None))
        self.assertEqual(optionalParameter.value, '')

        requiredParameter = ParameterCrs('myName', 'myDesc', default='test', optional=False)
        self.assertEqual(requiredParameter.value, 'test')
        requiredParameter.setValue('check')
        self.assertEqual(requiredParameter.value, 'check')
        self.assertFalse(requiredParameter.setValue(None))
        self.assertEqual(requiredParameter.value, 'check')
开发者ID:DHI-GRAS,项目名称:ESA_Processing,代码行数:14,代码来源:ParametersTest.py

示例3: testOptional

    def testOptional(self):
        optionalParameter = ParameterCrs("myName", "myDesc", default="EPSG:4326", optional=True)
        self.assertEqual(optionalParameter.value, "EPSG:4326")
        optionalParameter.setValue("EPSG:12003")
        self.assertEqual(optionalParameter.value, "EPSG:12003")
        self.assertTrue(optionalParameter.setValue(None))
        self.assertEqual(optionalParameter.value, None)

        requiredParameter = ParameterCrs("myName", "myDesc", default="EPSG:4326", optional=False)
        self.assertEqual(requiredParameter.value, "EPSG:4326")
        requiredParameter.setValue("EPSG:12003")
        self.assertEqual(requiredParameter.value, "EPSG:12003")
        self.assertFalse(requiredParameter.setValue(None))
        self.assertEqual(requiredParameter.value, "EPSG:12003")
开发者ID:blazek,项目名称:QGIS,代码行数:14,代码来源:ParametersTest.py

示例4: testParameterCRS

 def testParameterCRS(self):
     param = ParameterCrs('name', 'desc')
     assert param.setValue('EPSG:12003')
     assert param.value == 'EPSG:12003'
     assert param.setValue(None)
     assert param.value == param.default
     s = param.serialize()
     param2 = ParameterCrs()
     param2.deserialize(s)
     assert param.default == param2.default
     assert param.description == param2.description
     assert param.name == param2.name
开发者ID:ACorradini,项目名称:QGIS,代码行数:12,代码来源:ParametersTest.py

示例5: ModelerParameterDefinitionDialog


#.........这里部分代码省略.........
            for param in list(self.alg.inputs.values()):
                if isinstance(param.param, (ParameterVector, ParameterTable)):
                    self.parentCombo.addItem(param.param.description(), param.param.name())
                    if self.param is not None:
                        if self.param.parent_layer == param.param.name():
                            self.parentCombo.setCurrentIndex(idx)
                    idx += 1
            self.verticalLayout.addWidget(self.parentCombo)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or
                isinstance(self.param, ParameterString)):
            self.verticalLayout.addWidget(QLabel(self.tr('Default value')))
            self.defaultTextBox = QLineEdit()
            if self.param is not None:
                self.defaultTextBox.setText(self.param.defaultValue())
            self.verticalLayout.addWidget(self.defaultTextBox)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or
                isinstance(self.param, ParameterFile)):
            self.verticalLayout.addWidget(QLabel(self.tr('Type')))
            self.fileFolderCombo = QComboBox()
            self.fileFolderCombo.addItem(self.tr('File'))
            self.fileFolderCombo.addItem(self.tr('Folder'))
            if self.param is not None:
                self.fileFolderCombo.setCurrentIndex(
                    1 if self.param.isFolder else 0)
            self.verticalLayout.addWidget(self.fileFolderCombo)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_POINT or
                isinstance(self.param, ParameterPoint)):
            self.verticalLayout.addWidget(QLabel(self.tr('Default value')))
            self.defaultTextBox = QLineEdit()
            if self.param is not None:
                self.defaultTextBox.setText(self.param.defaultValue())
            self.verticalLayout.addWidget(self.defaultTextBox)
        elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_CRS or
                isinstance(self.param, ParameterCrs)):
            self.verticalLayout.addWidget(QLabel(self.tr('Default value')))
            self.selector = QgsProjectionSelectionWidget()
            if self.param is not None:
                self.selector.setCrs(QgsCoordinateReferenceSystem(self.param.defaultValue()))
            else:
                self.selector.setCrs(QgsCoordinateReferenceSystem('EPSG:4326'))
            self.verticalLayout.addWidget(self.selector)

        self.verticalLayout.addSpacing(20)
        self.requiredCheck = QCheckBox()
        self.requiredCheck.setText(self.tr('Mandatory'))
        self.requiredCheck.setChecked(True)
        if self.param is not None:
            self.requiredCheck.setChecked(not self.param.flags() & QgsProcessingParameterDefinition.FlagOptional)
        self.verticalLayout.addWidget(self.requiredCheck)

        self.buttonBox = QDialogButtonBox(self)
        self.buttonBox.setOrientation(Qt.Horizontal)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
                                          QDialogButtonBox.Ok)
        self.buttonBox.setObjectName('buttonBox')
        self.buttonBox.accepted.connect(self.okPressed)
        self.buttonBox.rejected.connect(self.cancelPressed)

        self.verticalLayout.addStretch()
        self.verticalLayout.addWidget(self.buttonBox)

        self.setLayout(self.verticalLayout)

    def okPressed(self):
        description = str(self.nameTextBox.text())
        if description.strip() == '':
开发者ID:rskelly,项目名称:QGIS,代码行数:67,代码来源:ModelerParameterDefinitionDialog.py

示例6: okPressed

 def okPressed(self):
     description = str(self.nameTextBox.text())
     if description.strip() == '':
         QMessageBox.warning(self, self.tr('Unable to define parameter'),
                             self.tr('Invalid parameter name'))
         return
     if self.param is None:
         validChars = \
             'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
         safeName = ''.join(c for c in description if c in validChars)
         name = safeName.lower()
         i = 2
         while name in self.alg.inputs:
             name = safeName.lower() + str(i)
     else:
         name = self.param.name()
     if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
             isinstance(self.param, ParameterBoolean)):
         self.param = ParameterBoolean(name, description, self.state.isChecked())
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
           isinstance(self.param, ParameterTableField)):
         if self.parentCombo.currentIndex() < 0:
             QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                 self.tr('Wrong or missing parameter values'))
             return
         parent = self.parentCombo.currentData()
         datatype = self.datatypeCombo.currentData()
         self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
             isinstance(self.param, ParameterRaster)):
         self.param = ParameterRaster(
             name, description)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE or
             isinstance(self.param, ParameterTable)):
         self.param = ParameterTable(
             name, description)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_VECTOR or
             isinstance(self.param, ParameterVector)):
         self.param = ParameterVector(
             name, description,
             [self.shapetypeCombo.currentIndex() - 1])
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_MULTIPLE or
             isinstance(self.param, ParameterMultipleInput)):
         self.param = ParameterMultipleInput(
             name, description,
             self.datatypeCombo.currentIndex() - 1)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_NUMBER or
             isinstance(self.param, ParameterNumber)):
         try:
             vmin = self.minTextBox.text().strip()
             if vmin == '':
                 vmin = None
             else:
                 vmin = float(vmin)
             vmax = self.maxTextBox.text().strip()
             if vmax == '':
                 vmax = None
             else:
                 vmax = float(vmax)
             self.param = ParameterNumber(name, description, vmin, vmax,
                                          str(self.defaultTextBox.text()))
         except:
             QMessageBox.warning(self, self.tr('Unable to define parameter'),
                                 self.tr('Wrong or missing parameter values'))
             return
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION or
             isinstance(self.param, ParameterExpression)):
         parent = self.parentCombo.currentData()
         self.param = ParameterExpression(name, description,
                                          default=str(self.defaultEdit.expression()),
                                          parent_layer=parent)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or
             isinstance(self.param, ParameterString)):
         self.param = ParameterString(name, description,
                                      str(self.defaultTextBox.text()))
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or
             isinstance(self.param, ParameterExtent)):
         self.param = ParameterExtent(name, description)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or
             isinstance(self.param, ParameterFile)):
         isFolder = self.fileFolderCombo.currentIndex() == 1
         self.param = ParameterFile(name, description, isFolder=isFolder)
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_POINT or
             isinstance(self.param, ParameterPoint)):
         self.param = ParameterPoint(name, description,
                                     str(self.defaultTextBox.text()))
     elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_CRS or
             isinstance(self.param, ParameterCrs)):
         self.param = ParameterCrs(name, description, default=self.selector.crs().authid())
     if not self.requiredCheck.isChecked():
         self.param.setFlags(self.param.flags() | QgsProcessingParameterDefinition.FlagOptional)
     self.close()
开发者ID:rskelly,项目名称:QGIS,代码行数:92,代码来源:ModelerParameterDefinitionDialog.py

示例7: testSetValue

 def testSetValue(self):
     parameter = ParameterCrs("myName", "myDesc")
     self.assertTrue(parameter.setValue("EPSG:12003"))
     self.assertEqual(parameter.value, "EPSG:12003")
开发者ID:blazek,项目名称:QGIS,代码行数:4,代码来源:ParametersTest.py


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