Skip to content

Commit

Permalink
[processing] added specific algorithm for saga 214
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jan 20, 2015
1 parent e9228b6 commit b029198
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
75 changes: 75 additions & 0 deletions python/plugins/processing/algs/saga/SagaAlgorithm214.py
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
SagaAlgorithm213.py
---------------------
Date : December 2014
Copyright : (C) 2014 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""

__author__ = 'Victor Olaya'
__date__ = 'December 2014'
__copyright__ = '(C) 2014, Victor Olaya'

# This will get replaced with a git SHA1 when you do a git archive

__revision__ = '$Format:%H$'

from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from SagaAlgorithm213 import SagaAlgorithm213
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.ProcessingLog import ProcessingLog
from processing.core.GeoAlgorithmExecutionException import \
GeoAlgorithmExecutionException
from processing.core.parameters import *
from processing.core.outputs import *
import SagaUtils
from processing.tools import dataobjects
from processing.tools.system import *

sessionExportedLayers = {}

class SagaAlgorithm214(SagaAlgorithm213):


def getCopy(self):
newone = SagaAlgorithm214(self.descriptionFile)
newone.provider = self.provider
return newone

def exportRasterLayer(self, source):
global sessionExportedLayers
if source in sessionExportedLayers:
exportedLayer = sessionExportedLayers[source]
if os.path.exists(exportedLayer):
self.exportedLayers[source] = exportedLayer
return None
else:
del sessionExportedLayers[source]
layer = dataobjects.getObjectFromUri(source, False)
if layer:
filename = layer.name()
else:
filename = os.path.basename(source)
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
filename = 'layer'
destFilename = getTempFilenameInTempFolder(filename + '.sgrd')
self.exportedLayers[source] = destFilename
sessionExportedLayers[source] = destFilename
return 'io_gdal -TRANSFORM -INTERPOL 0 -GRIDS "' + destFilename + '" -FILES "' + source + '"'
3 changes: 2 additions & 1 deletion python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Expand Up @@ -33,6 +33,7 @@
from processing.core.ProcessingLog import ProcessingLog
from SagaAlgorithm212 import SagaAlgorithm212
from SagaAlgorithm213 import SagaAlgorithm213
from SagaAlgorithm214 import SagaAlgorithm214
from SplitRGBBands import SplitRGBBands
import SagaUtils
from processing.tools.system import *
Expand All @@ -41,7 +42,7 @@ class SagaAlgorithmProvider(AlgorithmProvider):

supportedVersions = {"2.1.2": ("2.1.2", SagaAlgorithm212),
"2.1.3": ("2.1.3", SagaAlgorithm213),
"2.1.4": ("2.1.3", SagaAlgorithm213)}
"2.1.4": ("2.1.3", SagaAlgorithm214)}

def __init__(self):
AlgorithmProvider.__init__(self)
Expand Down

2 comments on commit b029198

@pcav
Copy link
Member

@pcav pcav commented on b029198 Oct 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"2.1.4": ("2.1.3", SagaAlgorithm214)}

is this a typo?

@gioman
Copy link
Contributor

@gioman gioman commented on b029198 Oct 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"2.1.4": ("2.1.3", SagaAlgorithm214)}

is this a typo?

As far as I can see is ok since 2.12

Please sign in to comment.