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


Python ModelerAlgorithm.Algorithm类代码示例

本文整理汇总了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
开发者ID:JanisE,项目名称:QGIS,代码行数:25,代码来源:ModelerParametersDialog.py

示例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
开发者ID:,项目名称:,代码行数:26,代码来源:

示例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
开发者ID:rskelly,项目名称:QGIS,代码行数:26,代码来源:ModelerParametersDialog.py

示例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)
开发者ID:,项目名称:,代码行数:20,代码来源:

示例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
开发者ID:redwoodxiao,项目名称:QGIS,代码行数:24,代码来源:CalculatorModelerAlgorithm.py


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