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


Python QgsProcessingOutputLayerDefinition.sink方法代码示例

本文整理汇总了Python中qgis.core.QgsProcessingOutputLayerDefinition.sink方法的典型用法代码示例。如果您正苦于以下问题:Python QgsProcessingOutputLayerDefinition.sink方法的具体用法?Python QgsProcessingOutputLayerDefinition.sink怎么用?Python QgsProcessingOutputLayerDefinition.sink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsProcessingOutputLayerDefinition的用法示例。


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

示例1: getParamValues

# 需要导入模块: from qgis.core import QgsProcessingOutputLayerDefinition [as 别名]
# 或者: from qgis.core.QgsProcessingOutputLayerDefinition import sink [as 别名]
    def getParamValues(self):
        if self.mUpdateExistingGroupBox.isChecked():
            fieldName = self.mExistingFieldComboBox.currentText()
        else:
            fieldName = self.mOutputFieldNameLineEdit.text()

        layer = self.cmbInputLayer.currentLayer()

        context = dataobjects.createContext()

        parameters = {}
        parameters['INPUT'] = layer
        parameters['FIELD_NAME'] = fieldName
        parameters['FIELD_TYPE'] = self.mOutputFieldTypeComboBox.currentIndex()
        parameters['FIELD_LENGTH'] = self.mOutputFieldWidthSpinBox.value()
        parameters['FIELD_PRECISION'] = self.mOutputFieldPrecisionSpinBox.value()
        parameters['NEW_FIELD'] = self.mNewFieldGroupBox.isChecked()
        parameters['FORMULA'] = self.builder.expressionText()
        output = QgsProcessingOutputLayerDefinition()
        if self.leOutputFile.text().strip():
            output.sink = QgsProperty.fromValue(self.leOutputFile.text().strip())
        else:
            output.sink = QgsProperty.fromValue('memory:')
        output.destinationProject = context.project()
        parameters['OUTPUT'] = output

        ok, msg = self.alg.checkParameterValues(parameters, context)
        if not ok:
            QMessageBox.warning(
                self, self.tr('Unable to execute algorithm'), msg)
            return {}
        return parameters
开发者ID:dwsilk,项目名称:QGIS,代码行数:34,代码来源:FieldsCalculatorDialog.py

示例2: getConsoleCommands

# 需要导入模块: from qgis.core import QgsProcessingOutputLayerDefinition [as 别名]
# 或者: from qgis.core.QgsProcessingOutputLayerDefinition import sink [as 别名]
    def getConsoleCommands(self, parameters, context, feedback):
        arguments = []
        arguments.append('-resolution')
        arguments.append(self.RESOLUTION_OPTIONS[self.parameterAsEnum(parameters, self.RESOLUTION, context)])
        if self.parameterAsBool(parameters, buildvrt.SEPARATE, context):
            arguments.append('-separate')
        if self.parameterAsBool(parameters, buildvrt.PROJ_DIFFERENCE, context):
            arguments.append('-allow_projection_difference')
        # Always write input files to a text file in case there are many of them and the
        # length of the command will be longer then allowed in command prompt
        listFile = os.path.join(QgsProcessingUtils.tempFolder(), 'buildvrtInputFiles.txt')
        with open(listFile, 'w') as f:
            layers = []
            for l in self.parameterAsLayerList(parameters, self.INPUT, context):
                layers.append(l.source())
            f.write('\n'.join(layers))
        arguments.append('-input_file_list')
        arguments.append(listFile)

        out = self.parameterAsOutputLayer(parameters, self.OUTPUT, context)
        # Ideally the file extensions should be limited to just .vrt but I'm not sure how
        # to do it simply so instead a check is performed.
        _, ext = os.path.splitext(out)
        if not ext.lower() == '.vrt':
            out = out[:-len(ext)] + '.vrt'
            if isinstance(parameters[self.OUTPUT], QgsProcessingOutputLayerDefinition):
                output_def = QgsProcessingOutputLayerDefinition(parameters[self.OUTPUT])
                output_def.sink = QgsProperty.fromValue(out)
                self.setOutputValue(self.OUTPUT, output_def)
            else:
                self.setOutputValue(self.OUTPUT, out)
        arguments.append(out)

        return ['gdalbuildvrt', GdalUtils.escapeAndJoin(arguments)]
开发者ID:exlimit,项目名称:QGIS,代码行数:36,代码来源:buildvrt.py


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