Skip to content

Commit

Permalink
[Processing] Add SAGA LTR support in 2.18
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Mar 22, 2017
1 parent 616868e commit f568ca2
Show file tree
Hide file tree
Showing 250 changed files with 2,299 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/plugins/processing/algs/saga/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ FILE(GLOB DESCR214_FILES description/2.1.4/*.txt)
FILE(GLOB DESCR220_FILES description/2.2.0/*.txt)
FILE(GLOB DESCR222_FILES description/2.2.2/*.txt)
FILE(GLOB DESCR223_FILES description/2.2.3/*.txt)
FILE(GLOB DESCR230_FILES description/2.3.0/*.txt)
FILE(GLOB HELP_FILES help/*.rst)

ADD_SUBDIRECTORY(ext)
Expand All @@ -16,4 +17,5 @@ PLUGIN_INSTALL(processing algs/saga/description/2.1.4 ${DESCR214_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.0 ${DESCR220_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.2 ${DESCR222_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.2.3 ${DESCR223_FILES})
PLUGIN_INSTALL(processing algs/saga/description/2.3.0 ${DESCR230_FILES})
PLUGIN_INSTALL(processing algs/saga/help ${HELP_FILES})
64 changes: 64 additions & 0 deletions python/plugins/processing/algs/saga/SagaAlgorithm230.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
SagaAlgorithm230.py
---------------------
Date : March 2017
Copyright : (C) 2017 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__ = 'March 2017'
__copyright__ = '(C) 2017, Victor Olaya'

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

__revision__ = '$Format:%H$'

import os
from SagaAlgorithm214 import SagaAlgorithm214
from processing.tools import dataobjects
from processing.tools.system import getTempFilenameInTempFolder

sessionExportedLayers = {}


class SagaAlgorithm230(SagaAlgorithm214):

def getCopy(self):
newone = SagaAlgorithm230(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 0 -TRANSFORM 1 -RESAMPLING 0 -GRIDS "' + destFilename + '" -FILES "' + source + '"'
5 changes: 4 additions & 1 deletion python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .SagaAlgorithm212 import SagaAlgorithm212
from .SagaAlgorithm213 import SagaAlgorithm213
from .SagaAlgorithm214 import SagaAlgorithm214
from SagaAlgorithm230 import SagaAlgorithm230
from .SplitRGBBands import SplitRGBBands
from . import SagaUtils
from processing.tools.system import isWindows, isMac
Expand All @@ -50,7 +51,9 @@ class SagaAlgorithmProvider(AlgorithmProvider):
"2.2.0": ("2.2.0", SagaAlgorithm214),
"2.2.1": ("2.2.0", SagaAlgorithm214),
"2.2.2": ("2.2.2", SagaAlgorithm214),
"2.2.3": ("2.2.3", SagaAlgorithm214)}
"2.2.3": ("2.2.3", SagaAlgorithm214),
"2.3.0": ("2.3.0", SagaAlgorithm230),
"2.3.1": ("2.3.1", SagaAlgorithm230)}

def __init__(self):
AlgorithmProvider.__init__(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Accumulated Cost (Anisotropic)
grid_analysis
ParameterRaster|COST|Cost Grid|False
ParameterRaster|DIRECTION|Direction of max cost|False
ParameterRaster|POINTS|Destination Points|False
ParameterNumber|K|k factor|None|None|1
ParameterNumber|THRESHOLD|Threshold for different route|None|None|0
OutputRaster|ACCCOST|Accumulated Cost
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Accumulated Cost (Isotropic)
grid_analysis
ParameterRaster|COST|Cost Grid|False
ParameterRaster|POINTS|Destination Points|False
ParameterNumber|THRESHOLD|Threshold for different route|None|None|0.0
OutputRaster|ACCCOST|Accumulated Cost
OutputRaster|CLOSESTPT|Closest Point
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Add Coordinates to points
shapes_points
ParameterVector|INPUT|Points|0|False
OutputVector|OUTPUT|Points with coordinates
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Add Grid Values to Points
shapes_grid
ParameterVector|SHAPES|Points|0|False
ParameterMultipleInput|GRIDS|Grids|3|False
ParameterSelection|INTERPOL|Interpolation|[0] Nearest Neighbor;[1] Bilinear Interpolation;[2] Inverse Distance Interpolation;[3] Bicubic Spline Interpolation;[4] B-Spline Interpolation
OutputVector|RESULT|Result
AllowUnmatching
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Add Grid Values to Shapes
shapes_grid
ParameterVector|SHAPES|Shapes|-1|False
ParameterMultipleInput|GRIDS|Grids|3|False
ParameterSelection|INTERPOL|Interpolation|[0] Nearest Neighbor;[1] Bilinear Interpolation;[2] Inverse Distance Interpolation;[3] Bicubic Spline Interpolation;[4] B-Spline Interpolation
OutputVector|RESULT|Result
AllowUnmatching
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Add Point Attributes to Polygons
shapes_polygons
ParameterVector|INPUT|Polygons|2|False
ParameterVector|POINTS|Points|0|False
ParameterTableField|FIELDS|Attributes|POINTS|-1|False
ParameterBoolean|ADD_LOCATION_INFO|Add location info|False
OutputVector|OUTPUT|Result
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Add Polygon Attributes to Points
shapes_points
ParameterVector|INPUT|Points|0|False
ParameterVector|POLYGONS|Polygons|2|False
ParameterTableField|FIELDS|Attribute|POLYGONS|-1|False
OutputVector|OUTPUT|Result
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Aggregate
grid_tools
ParameterRaster|INPUT|Grid|False
ParameterNumber|SIZE|Aggregation Size|None|None|3
ParameterSelection|METHOD|Method|[0] Sum;[1] Min;[2] Max
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Aggregate Point Observations
shapes_points
ParameterVector|REFERENCE|Reference Points|-1|False
ParameterTableField|REFERENCE_ID|ID|REFERENCE|-1|False
ParameterTable|OBSERVATIONS|Observations|False
ParameterTableField|X|X|OBSERVATIONS|-1|False
ParameterTableField|Y|Y|OBSERVATIONS|-1|False
ParameterTableField|TRACK|Track|OBSERVATIONS|-1|False
ParameterTableField|DATE|Date|OBSERVATIONS|-1|False
ParameterTableField|TIME|Time|OBSERVATIONS|-1|False
ParameterTableField|PARAMETER|Parameter|OBSERVATIONS|-1|False
ParameterNumber|EPS_TIME|Maximum Time Span (Seconds)|None|None|60.0
ParameterNumber|EPS_SPACE|Maximum Distance|None|None|0.002
OutputTable|AGGREGATED|Aggregated