Beispiel #1
0
    def _loadAlgorithms(self):
        self.algs = []
        version = SagaUtils.getSagaInstalledVersion(True)
        if version is None:
            ProcessingLog.addToLog(
                ProcessingLog.LOG_ERROR,
                self.
                tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'
                   ))
            return
        if version not in self.supportedVersions:
            ProcessingLog.addToLog(
                ProcessingLog.LOG_ERROR,
                self.
                tr('Problem with SAGA installation: installed SAGA version (%s) is not supported'
                   % version))
            return

        folder = SagaUtils.sagaDescriptionPath()
        folder = os.path.join(
            folder,
            self.supportedVersions[SagaUtils.getSagaInstalledVersion()][0])
        for descriptionFile in os.listdir(folder):
            if descriptionFile.endswith('txt'):
                f = os.path.join(folder, descriptionFile)
                self._loadAlgorithm(f)
        self.algs.append(SplitRGBBands())
Beispiel #2
0
    def processAlgorithm(self, progress):
        # TODO: check correct num of bands
        input = self.getParameterValue(SplitRGBBands.INPUT)
        temp = getTempFilename(None).replace('.', '')
        basename = os.path.basename(temp)
        validChars = \
            'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
        safeBasename = ''.join(c for c in basename if c in validChars)
        temp = os.path.join(os.path.dirname(temp), safeBasename)

        r = self.getOutputValue(SplitRGBBands.R)
        g = self.getOutputValue(SplitRGBBands.G)
        b = self.getOutputValue(SplitRGBBands.B)
        commands = []
        version = SagaUtils.getSagaInstalledVersion(True)
        trailing = "000" if version != "2.1.4" else ""
        lib = "" if isWindows() else "lib"
        commands.append('%sio_gdal 0 -GRIDS "%s" -FILES "%s"' % (lib, temp, input)
                        + '"')
        commands.append('%sio_gdal 1 -GRIDS "%s_%s1.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %(lib, temp, trailing, r)
                        )
        commands.append('%sio_gdal 1 -GRIDS "%s_%s2.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %(lib, temp, trailing, g)
                        )
        commands.append('%sio_gdal 1 -GRIDS "%s_%s3.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %(lib, temp, trailing, b)
                        )


        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        SagaUtils.executeSaga(progress)
Beispiel #3
0
    def processAlgorithm(self, progress):
        # TODO: check correct num of bands
        input = self.getParameterValue(SplitRGBBands.INPUT)
        temp = getTempFilename(None).replace('.', '')
        basename = os.path.basename(temp)
        validChars = \
            'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
        safeBasename = ''.join(c for c in basename if c in validChars)
        temp = os.path.join(os.path.dirname(temp), safeBasename)

        r = self.getOutputValue(SplitRGBBands.R)
        g = self.getOutputValue(SplitRGBBands.G)
        b = self.getOutputValue(SplitRGBBands.B)
        commands = []
        version = SagaUtils.getSagaInstalledVersion(True)
        trailing = ""
        lib = ""
        commands.append('%sio_gdal 0 -GRIDS "%s" -FILES "%s"' %
                        (lib, temp, input))
        commands.append(
            '%sio_gdal 1 -GRIDS "%s_%s1.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %
            (lib, temp, trailing, r))
        commands.append(
            '%sio_gdal 1 -GRIDS "%s_%s2.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %
            (lib, temp, trailing, g))
        commands.append(
            '%sio_gdal 1 -GRIDS "%s_%s3.sgrd" -FORMAT 1 -TYPE 0 -FILE "%s"' %
            (lib, temp, trailing, b))

        SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
        SagaUtils.executeSaga(progress)
Beispiel #4
0
    def _loadAlgorithms(self):
        self.algs = []
        version = SagaUtils.getSagaInstalledVersion(True)
        if version is None:
            ProcessingLog.addToLog(
                ProcessingLog.LOG_ERROR,
                self.tr("Problem with SAGA installation: SAGA was not found or is not correctly installed"),
            )
            return
        if version not in self.supportedVersions:
            lastVersion = sorted(self.supportedVersions.keys())[-1]
            if version > lastVersion:
                version = lastVersion
            else:
                ProcessingLog.addToLog(
                    ProcessingLog.LOG_ERROR,
                    self.tr("Problem with SAGA installation: installed SAGA version (%s) is not supported" % version),
                )
                return

        folder = SagaUtils.sagaDescriptionPath()
        folder = os.path.join(folder, self.supportedVersions[version][0])
        for descriptionFile in os.listdir(folder):
            if descriptionFile.endswith("txt"):
                f = os.path.join(folder, descriptionFile)
                self._loadAlgorithm(f, version)
        self.algs.append(SplitRGBBands())
Beispiel #5
0
    def _loadAlgorithms(self):
        self.algs = []
        version = SagaUtils.getSagaInstalledVersion(True)
        if version is None:
            ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
            return
        if version not in self.supportedVersions:
            ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                self.tr('Problem with SAGA installation: installed SAGA version (%s) is not supported' % version))
            return

        folder = SagaUtils.sagaDescriptionPath()
        folder = os.path.join(folder, self.supportedVersions[SagaUtils.getSagaInstalledVersion()][0])
        for descriptionFile in os.listdir(folder):
            if descriptionFile.endswith('txt'):
                f = os.path.join(folder, descriptionFile)
                self._loadAlgorithm(f)
        self.algs.append(SplitRGBBands())
 def _loadAlgorithm(self, descriptionFile):
     try:
         alg = self.supportedVersions[SagaUtils.getSagaInstalledVersion()][1](descriptionFile)
         if alg.name.strip() != '':
             self.algs.append(alg)
         else:
             ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                 self.tr('Could not open SAGA algorithm: %s' % descriptionFile))
     except Exception, e:
         ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
             self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))
 def _loadAlgorithm(self, descriptionFile):
     try:
         alg = self.supportedVersions[SagaUtils.getSagaInstalledVersion()][1](descriptionFile)
         if alg.name.strip() != '':
             self.algs.append(alg)
         else:
             ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
                 self.tr('Could not open SAGA algorithm: %s' % descriptionFile))
     except Exception, e:
         ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
             self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))
Beispiel #8
0
 def getDescription(self):
     version = SagaUtils.getSagaInstalledVersion()
     return 'SAGA (%s)' % version if version is not None else 'SAGA'
 def getDescription(self):
     version = SagaUtils.getSagaInstalledVersion()
     return 'SAGA (%s)' %  version if version is not None else 'SAGA'
Beispiel #10
0
 def getDescription(self):
     return "SAGA (%s)" % SagaUtils.getSagaInstalledVersion()