本文整理汇总了Python中processing.modeler.ModelerAlgorithm.Algorithm类的典型用法代码示例。如果您正苦于以下问题:Python Algorithm类的具体用法?Python Algorithm怎么用?Python Algorithm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Algorithm类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createAlgorithm
def createAlgorithm(self):
alg = Algorithm(self._alg.commandLineName())
alg.setName(self.model)
alg.description = self.descriptionBox.text()
params = self._alg.parameters
outputs = self._alg.outputs
for param in params:
if param.hidden:
continue
if not self.setParamValue(alg, param, self.valueItems[param.name]):
return None
for output in outputs:
if not output.hidden:
name = unicode(self.valueItems[output.name].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
alg.outputs[output.name] = ModelerOutput(name)
selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies()
self.dependencies = []
for selected in selectedOptions:
s = availableDependencies[selected]
alg.dependencies.append(s)
return alg
示例2: createAlgorithm
def createAlgorithm(self):
alg = Algorithm(self._alg.commandLineName())
alg.setName(self.model)
alg.description = self.descriptionBox.text()
params = self._alg.parameters
outputs = self._alg.outputs
for param in params:
if param.hidden:
continue
if not self.setParamValue(alg, param, self.wrappers[param.name]):
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description,
level=QgsMessageBar.WARNING)
return None
for output in outputs:
if not output.hidden:
name = str(self.valueItems[output.name].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
alg.outputs[output.name] = ModelerOutput(name)
selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies()
for selected in selectedOptions:
alg.dependencies.append(availableDependencies[selected].name)
self._alg.processBeforeAddingToModeler(alg, self.model)
return alg
示例3: createAlgorithm
def createAlgorithm(self):
alg = Algorithm(self._alg.id())
alg.setName(self.model)
alg.description = self.descriptionBox.text()
params = self._alg.parameterDefinitions()
outputs = self._alg.outputs
for param in params:
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if not param.checkValueIsAcceptable(self.wrappers[param.name()].value):
self.bar.pushMessage("Error", "Wrong or missing value for parameter '%s'" % param.description(),
level=QgsMessageBar.WARNING)
return None
for output in outputs:
if not output.flags() & QgsProcessingParameterDefinition.FlagHidden:
name = str(self.valueItems[output.name()].text())
if name.strip() != '' and name != ModelerParametersDialog.ENTER_NAME:
alg.outputs[output.name()] = ModelerOutput(name)
selectedOptions = self.dependenciesPanel.selectedoptions
availableDependencies = self.getAvailableDependencies() # spellok
for selected in selectedOptions:
alg.dependencies.append(availableDependencies[selected].name) # spellok
self._alg.processBeforeAddingToModeler(alg, self.model)
return alg
示例4: testModelerAlgorithmHasDependencies
def testModelerAlgorithmHasDependencies(self):
# test hasDependencies from ModelerAlgorithm
m = ModelerAlgorithm()
a = Algorithm("qgis:clip")
m.addAlgorithm(a)
a2 = Algorithm("qgis:clip")
m.addAlgorithm(a2)
# test parent algorithm dependency
self.assertEqual(m.hasDependencies('QGISCLIP_1'), False)
a2.dependencies = ['QGISCLIP_1']
self.assertEqual(m.hasDependencies('QGISCLIP_1'), True)
# test output algorithm dependency
a2.dependencies = []
a.outputs['OUTPUT'] = ModelerOutput('out')
a2.params['INPUT'] = ValueFromOutput('QGISCLIP_1', 'OUTPUT')
self.assertEqual(m.hasDependencies('QGISCLIP_1'), True)
示例5: createAlgorithm
def createAlgorithm(self):
alg = Algorithm('modelertools:calculator')
alg.setName(self.model)
alg.description = self.tr('Calculator', 'CalculatorModelerParametersDialog')
formula = self.formulaText.text()
alg.params[FORMULA] = formula
for i in xrange(AVAILABLE_VARIABLES):
paramname = NUMBER + unicode(i)
alg.params[paramname] = None
numbers = self.getAvailableValuesOfType(ParameterNumber, OutputNumber)
used = []
for i in range(len(numbers)):
if unicode(chr(i + 97)) in formula:
used.append(numbers[i])
for i, variable in enumerate(used):
paramname = NUMBER + unicode(i)
alg.params[paramname] = variable
# TODO check formula is correct
return alg