本文整理汇总了Python中processing.gui.DestinationSelectionPanel.DestinationSelectionPanel.getValue方法的典型用法代码示例。如果您正苦于以下问题:Python DestinationSelectionPanel.getValue方法的具体用法?Python DestinationSelectionPanel.getValue怎么用?Python DestinationSelectionPanel.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类processing.gui.DestinationSelectionPanel.DestinationSelectionPanel
的用法示例。
在下文中一共展示了DestinationSelectionPanel.getValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testVectorDestination
# 需要导入模块: from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel [as 别名]
# 或者: from processing.gui.DestinationSelectionPanel.DestinationSelectionPanel import getValue [as 别名]
def testVectorDestination(self):
param = QgsProcessingParameterVectorDestination('test')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)
panel.setValue(QgsProcessing.TEMPORARY_OUTPUT)
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.sink.staticValue(), QgsProcessing.TEMPORARY_OUTPUT)
panel.setValue('''ogr:dbname='/me/a.gpkg' table="d" (geom) sql=''')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), '''ogr:dbname='/me/a.gpkg' table="d" (geom) sql=''')
panel.setValue('''postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table="stufff"."output" (the_geom) sql=''')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), '''postgis:dbname='oraclesux' host=10.1.1.221 port=5432 user='qgis' password='qgis' table="stufff"."output" (the_geom) sql=''')
panel.setValue('/home/me/test.shp')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), '/home/me/test.shp')
ProcessingConfig.setSettingValue(ProcessingConfig.OUTPUT_FOLDER, testDataPath)
panel.setValue('test.shp')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), os.path.join(testDataPath, 'test.shp'))
示例2: testFileDestination
# 需要导入模块: from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel [as 别名]
# 或者: from processing.gui.DestinationSelectionPanel.DestinationSelectionPanel import getValue [as 别名]
def testFileDestination(self):
param = QgsProcessingParameterFileDestination('test')
alg = QgsApplication.processingRegistry().createAlgorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)
panel.setValue('/home/me/test.tif')
v = panel.getValue()
self.assertEqual(v, '/home/me/test.tif')
ProcessingConfig.setSettingValue(ProcessingConfig.OUTPUT_FOLDER, testDataPath)
panel.setValue('test.tif')
v = panel.getValue()
self.assertEqual(v, os.path.join(testDataPath, 'test.tif'))
示例3: testRasterDestination
# 需要导入模块: from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel [as 别名]
# 或者: from processing.gui.DestinationSelectionPanel.DestinationSelectionPanel import getValue [as 别名]
def testRasterDestination(self):
param = QgsProcessingParameterRasterDestination('test')
alg = QgsApplication.processingRegistry().algorithmById('native:centroids')
panel = DestinationSelectionPanel(param, alg)
panel.setValue('/home/me/test.tif')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), '/home/me/test.tif')
ProcessingConfig.setSettingValue(ProcessingConfig.OUTPUT_FOLDER, testDataPath)
panel.setValue('test.tif')
v = panel.getValue()
self.assertIsInstance(v, QgsProcessingOutputLayerDefinition)
self.assertEqual(v.createOptions, {'fileEncoding': 'System'})
self.assertEqual(v.sink.staticValue(), os.path.join(testDataPath, 'test.tif'))
示例4: ModelerParameterDefinitionDialog
# 需要导入模块: from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel [as 别名]
# 或者: from processing.gui.DestinationSelectionPanel.DestinationSelectionPanel import getValue [as 别名]
#.........这里部分代码省略.........
vmax = self.maxTextBox.text().strip()
if not vmax == '':
self.param.setMaximum(float(vmax))
except:
QMessageBox.warning(self, self.tr('Unable to define parameter'),
self.tr('Wrong or missing parameter values'))
return
elif (self.paramType == parameters.PARAMETER_EXPRESSION or
isinstance(self.param, QgsProcessingParameterExpression)):
parent = self.parentCombo.currentData()
self.param = QgsProcessingParameterExpression(name, description,
str(self.defaultEdit.expression()),
parent)
elif (self.paramType == parameters.PARAMETER_STRING or
isinstance(self.param, QgsProcessingParameterString)):
self.param = QgsProcessingParameterString(name, description,
str(self.defaultTextBox.text()))
elif (self.paramType == parameters.PARAMETER_EXTENT or
isinstance(self.param, QgsProcessingParameterExtent)):
self.param = QgsProcessingParameterExtent(name, description)
elif (self.paramType == parameters.PARAMETER_FILE or
isinstance(self.param, QgsProcessingParameterFile)):
isFolder = self.fileFolderCombo.currentIndex() == 1
self.param = QgsProcessingParameterFile(name, description,
QgsProcessingParameterFile.Folder if isFolder else QgsProcessingParameterFile.File)
elif (self.paramType == parameters.PARAMETER_POINT or
isinstance(self.param, QgsProcessingParameterPoint)):
self.param = QgsProcessingParameterPoint(name, description,
str(self.defaultTextBox.text()))
elif (self.paramType == parameters.PARAMETER_CRS or
isinstance(self.param, QgsProcessingParameterCrs)):
self.param = QgsProcessingParameterCrs(name, description, self.selector.crs().authid())
elif (self.paramType == parameters.PARAMETER_ENUM or
isinstance(self.param, QgsProcessingParameterEnum)):
self.param = QgsProcessingParameterEnum(name, description, self.widget.options(), self.widget.allowMultiple(), self.widget.defaultOptions())
elif (self.paramType == parameters.PARAMETER_MATRIX or
isinstance(self.param, QgsProcessingParameterMatrix)):
self.param = QgsProcessingParameterMatrix(name, description, hasFixedNumberRows=self.widget.fixedRows(), headers=self.widget.headers(), defaultValue=self.widget.value())
# Destination parameter
elif (isinstance(self.param, QgsProcessingParameterFeatureSink)):
self.param = QgsProcessingParameterFeatureSink(
name=name,
description=self.param.description(),
type=self.param.dataType(),
defaultValue=self.defaultWidget.getValue())
elif (isinstance(self.param, QgsProcessingParameterFileDestination)):
self.param = QgsProcessingParameterFileDestination(
name=name,
description=self.param.description(),
fileFilter=self.param.fileFilter(),
defaultValue=self.defaultWidget.getValue())
elif (isinstance(self.param, QgsProcessingParameterFolderDestination)):
self.param = QgsProcessingParameterFolderDestination(
name=name,
description=self.param.description(),
defaultValue=self.defaultWidget.getValue())
elif (isinstance(self.param, QgsProcessingParameterRasterDestination)):
self.param = QgsProcessingParameterRasterDestination(
name=name,
description=self.param.description(),
defaultValue=self.defaultWidget.getValue())
elif (isinstance(self.param, QgsProcessingParameterVectorDestination)):
self.param = QgsProcessingParameterVectorDestination(
name=name,
description=self.param.description(),
type=self.param.dataType(),
defaultValue=self.defaultWidget.getValue())
else:
if self.paramType:
typeId = self.paramType
else:
typeId = self.param.type()
paramTypeDef = QgsApplication.instance().processingRegistry().parameterType(typeId)
if not paramTypeDef:
msg = self.tr('The parameter `{}` is not registered, are you missing a required plugin?'.format(typeId))
raise UndefinedParameterException(msg)
self.param = paramTypeDef.create(name)
self.param.setDescription(description)
self.param.setMetadata(paramTypeDef.metadata())
if not self.requiredCheck.isChecked():
self.param.setFlags(self.param.flags() | QgsProcessingParameterDefinition.FlagOptional)
else:
self.param.setFlags(self.param.flags() & ~QgsProcessingParameterDefinition.FlagOptional)
settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())
QDialog.accept(self)
def reject(self):
self.param = None
settings = QgsSettings()
settings.setValue("/Processing/modelParametersDefinitionDialogGeometry", self.saveGeometry())
QDialog.reject(self)