コード例 #1
0
ファイル: SagaAlgorithm.py プロジェクト: sbrunner/QGIS
    def defineCharacteristicsFromFile(self):
        with open(self.description_file) as lines:
            line = lines.readline().strip('\n').strip()
            self._name = line
            if '|' in self._name:
                tokens = self._name.split('|')
                self._name = tokens[0]
                # cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
                self.cmdname = tokens[1]

            else:
                self.cmdname = self._name
                self._display_name = self.tr(str(self._name))
            self._name = decoratedAlgorithmName(self._name)
            self._display_name = self.tr(str(self._name))

            self._name = self._name.lower()
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
            self._name = ''.join(c for c in self._name if c in validChars)

            line = lines.readline().strip('\n').strip()
            self.undecorated_group = line
            self._group = self.tr(decoratedGroupName(self.undecorated_group))

            validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
            grpName = decoratedGroupName(self.undecorated_group).lower()
            self._groupId = ''.join(c for c in grpName if c in validChars)
            line = lines.readline().strip('\n').strip()
            while line != '':
                if line.startswith('Hardcoded'):
                    self.hardcoded_strings.append(line[len('Hardcoded|'):])
                elif line.startswith('QgsProcessingParameter') or line.startswith('Parameter'):
                    self.params.append(getParameterFromString(line))
                elif line.startswith('AllowUnmatching'):
                    self.allow_nonmatching_grid_extents = True
                elif line.startswith('Extent'):
                    # An extent parameter that wraps 4 SAGA numerical parameters
                    self.extentParamNames = line[6:].strip().split(' ')
                    self.params.append(QgsProcessingParameterExtent(self.OUTPUT_EXTENT,
                                                                    'Output extent'))
                else:
                    pass # TODO
                    #self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
コード例 #2
0
ファイル: SagaAlgorithm.py プロジェクト: manisandro/QGIS
    def defineCharacteristicsFromFile(self):
        with open(self.description_file, encoding="utf-8") as lines:
            line = lines.readline().strip('\n').strip()

            self._name = line
            if '|' in self._name:
                tokens = self._name.split('|')
                self._name = tokens[0]
                # cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
                self.cmdname = tokens[1]

            else:
                self.cmdname = self._name
                self._display_name = self.tr(str(self._name))
            self._name = decoratedAlgorithmName(self._name)
            self._display_name = self.tr(str(self._name))

            self._name = self._name.lower()
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
            self._name = ''.join(c for c in self._name if c in validChars)

            line = lines.readline().strip('\n').strip()
            if line == '##known_issues':
                self.known_issues = True
                line = lines.readline().strip('\n').strip()

            self.undecorated_group = line
            self._group = self.tr(decoratedGroupName(self.undecorated_group))

            validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
            grpName = decoratedGroupName(self.undecorated_group).lower()
            self._groupId = ''.join(c for c in grpName if c in validChars)
            line = lines.readline().strip('\n').strip()
            while line != '':
                if line.startswith('Hardcoded'):
                    self.hardcoded_strings.append(line[len('Hardcoded|'):])
                elif Parameters.is_parameter_line(line):
                    self.params.append(Parameters.create_parameter_from_line(line))
                elif line.startswith('AllowUnmatching'):
                    self.allow_nonmatching_grid_extents = True
                else:
                    pass # TODO
                    #self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
コード例 #3
0
    def defineCharacteristicsFromFile(self):
        with open(self.descriptionFile) as lines:
            line = lines.readline().strip('\n').strip()
            self.name = line
            if '|' in self.name:
                tokens = self.name.split('|')
                self.name = tokens[0]
                #cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
                self.cmdname = tokens[1]

            else:
                self.cmdname = self.name
                self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", str(self.name))
            #_commandLineName is the name used in processing to call the algorithm
            #Most of the time will be equal to the cmdname, but in same cases, several processing algorithms
            #call the same SAGA one
            self._commandLineName = self.createCommandLineName(self.name)
            self.name = decoratedAlgorithmName(self.name)
            self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", str(self.name))
            line = lines.readline().strip('\n').strip()
            self.undecoratedGroup = line
            self.group = decoratedGroupName(self.undecoratedGroup)
            self.i18n_group = QCoreApplication.translate("SAGAAlgorithm", self.group)
            line = lines.readline().strip('\n').strip()
            while line != '':
                if line.startswith('Hardcoded'):
                    self.hardcodedStrings.append(line[len('Hardcoded|'):])
                elif line.startswith('Parameter'):
                    self.addParameter(getParameterFromString(line))
                elif line.startswith('AllowUnmatching'):
                    self.allowUnmatchingGridExtents = True
                elif line.startswith('NoResamplingChoice'):
                    self.noResamplingChoice = True
                elif line.startswith('Extent'):
                    # An extent parameter that wraps 4 SAGA numerical parameters
                    self.extentParamNames = line[6:].strip().split(' ')
                    self.addParameter(ParameterExtent(self.OUTPUT_EXTENT,
                                                      'Output extent'))
                else:
                    self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
            hasRaster = False
            for param in self.parameters:
                if (isinstance(param, ParameterRaster) or
                    (isinstance(param, ParameterMultipleInput)
                        and param.datatype == ParameterMultipleInput.TYPE_RASTER)):
                    hasRaster = True
                    break

            if (not self.noResamplingChoice and hasRaster):
                param = ParameterSelection(self.RESAMPLING, "Resampling method", ["Nearest Neighbour", "Bilinear Interpolation", "Bicubic Spline Interpolation", "B-Spline Interpolation"], 3)
                param.isAdvanced = True
                self.addParameter(param)
コード例 #4
0
ファイル: SagaAlgorithm.py プロジェクト: riddle911/QGIS
    def defineCharacteristicsFromFile(self):
        with open(self.descriptionFile) as lines:
            line = lines.readline().strip('\n').strip()
            self._name = line
            if '|' in self._name:
                tokens = self._name.split('|')
                self._name = tokens[0]
                # cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
                self.cmdname = tokens[1]

            else:
                self.cmdname = self._name
                self._display_name = QCoreApplication.translate(
                    "SAGAAlgorithm", str(self._name))
            self._name = decoratedAlgorithmName(self._name)
            self._display_name = QCoreApplication.translate(
                "SAGAAlgorithm", str(self._name))

            self._name = self._name.lower()
            validChars = \
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
            self._name = ''.join(c for c in self._name if c in validChars)

            line = lines.readline().strip('\n').strip()
            self.undecoratedGroup = line
            self._group = QCoreApplication.translate(
                "SAGAAlgorithm", decoratedGroupName(self.undecoratedGroup))
            line = lines.readline().strip('\n').strip()
            while line != '':
                if line.startswith('Hardcoded'):
                    self.hardcodedStrings.append(line[len('Hardcoded|'):])
                elif line.startswith('Parameter'):
                    self.addParameter(getParameterFromString(line))
                elif line.startswith('AllowUnmatching'):
                    self.allowUnmatchingGridExtents = True
                elif line.startswith('Extent'):
                    # An extent parameter that wraps 4 SAGA numerical parameters
                    self.extentParamNames = line[6:].strip().split(' ')
                    self.addParameter(
                        ParameterExtent(self.OUTPUT_EXTENT, 'Output extent'))
                else:
                    self.addOutput(getOutputFromString(line))
                line = lines.readline().strip('\n').strip()
コード例 #5
0
    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip('\n').strip()
        self.name = line
        if '|' in self.name:
            tokens = self.name.split('|')
            self.name = tokens[0]
            #cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
            self.cmdname = tokens[1]

        else:
            self.cmdname = self.name
            self.i18n_name = QCoreApplication.translate(
                "SAGAAlgorithm", unicode(self.name))
        #_commandLineName is the name used in processing to call the algorithm
        #Most of the time will be equal to the cmdname, but in same cases, several processing algorithms
        #call the same SAGA one
        self._commandLineName = self.createCommandLineName(self.name)
        self.name = decoratedAlgorithmName(self.name)
        self.i18n_name = QCoreApplication.translate("SAGAAlgorithm",
                                                    unicode(self.name))
        line = lines.readline().strip('\n').strip()
        self.undecoratedGroup = line
        self.group = decoratedGroupName(self.undecoratedGroup)
        self.i18n_group = QCoreApplication.translate("SAGAAlgorithm",
                                                     self.group)
        line = lines.readline().strip('\n').strip()
        while line != '':
            if line.startswith('Hardcoded'):
                self.hardcodedStrings.append(line[len('Hardcoded|'):])
            elif line.startswith('Parameter'):
                self.addParameter(getParameterFromString(line))
            elif line.startswith('AllowUnmatching'):
                self.allowUnmatchingGridExtents = True
            elif line.startswith('Extent'):
                # An extent parameter that wraps 4 SAGA numerical parameters
                self.extentParamNames = line[6:].strip().split(' ')
                self.addParameter(
                    ParameterExtent(self.OUTPUT_EXTENT, 'Output extent', ''))
            else:
                self.addOutput(getOutputFromString(line))
            line = lines.readline().strip('\n').strip()
        lines.close()
コード例 #6
0
ファイル: SagaAlgorithm212.py プロジェクト: AM7000000/QGIS
    def defineCharacteristicsFromFile(self):
        lines = open(self.descriptionFile)
        line = lines.readline().strip('\n').strip()
        self.name = line
        if '|' in self.name:
            tokens = self.name.split('|')
            self.name = tokens[0]
            #cmdname is the name of the algorithm in SAGA, that is, the name to use to call it in the console
            self.cmdname = tokens[1]

        else:
            self.cmdname = self.name
            self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", unicode(self.name))
        #_commandLineName is the name used in processing to call the algorithm
        #Most of the time will be equal to the cmdname, but in same cases, several processing algorithms
        #call the same SAGA one
        self._commandLineName = self.createCommandLineName(self.name)
        self.name = decoratedAlgorithmName(self.name)
        self.i18n_name = QCoreApplication.translate("SAGAAlgorithm", unicode(self.name))
        line = lines.readline().strip('\n').strip()
        self.undecoratedGroup = line
        self.group = decoratedGroupName(self.undecoratedGroup)
        self.i18n_group = QCoreApplication.translate("SAGAAlgorithm", self.group)
        line = lines.readline().strip('\n').strip()
        while line != '':
            if line.startswith('Hardcoded'):
                self.hardcodedStrings.append(line[len('Hardcoded|'):])
            elif line.startswith('Parameter'):
                self.addParameter(getParameterFromString(line))
            elif line.startswith('AllowUnmatching'):
                self.allowUnmatchingGridExtents = True
            elif line.startswith('Extent'):
                # An extent parameter that wraps 4 SAGA numerical parameters
                self.extentParamNames = line[6:].strip().split(' ')
                self.addParameter(ParameterExtent(self.OUTPUT_EXTENT,
                                                  'Output extent', ''))
            else:
                self.addOutput(getOutputFromString(line))
            line = lines.readline().strip('\n').strip()
        lines.close()