|
24 | 24 | from sextante.parameters.ParameterSelection import ParameterSelection |
25 | 25 | from sextante.core.LayerExporter import LayerExporter |
26 | 26 | import subprocess |
| 27 | +from sextante.parameters.ParameterExtent import ParameterExtent |
27 | 28 |
|
28 | 29 | class SagaAlgorithm(GeoAlgorithm): |
29 | 30 |
|
| 31 | + OUTPUT_EXTENT = "OUTPUT_EXTENT" |
| 32 | + |
30 | 33 | def __init__(self, descriptionfile): |
31 | 34 | self.resample = True #True if it should resample |
32 | 35 | #in case several non-matching raster layers are used as input |
@@ -70,6 +73,9 @@ def defineCharacteristicsFromFile(self): |
70 | 73 | self.addParameter(ParameterFactory.getFromString(line)) |
71 | 74 | elif line.startswith("DontResample"): |
72 | 75 | self.resample = False |
| 76 | + elif line.startswith("Extent"): #An extent parameter that wraps 4 SAGA numerical parameters |
| 77 | + self.extentParamNames = line[6:].strip().split(" ") |
| 78 | + self.addParameter(ParameterExtent(self.OUTPUT_EXTENT, "Output extent", "0,1,0,1")) |
73 | 79 | else: |
74 | 80 | self.addOutput(OutputFactory.getFromString(line)) |
75 | 81 | line = lines.readline().strip("\n").strip() |
@@ -200,12 +206,18 @@ def processAlgorithm(self, progress): |
200 | 206 | elif isinstance(param, ParameterBoolean): |
201 | 207 | if param.value: |
202 | 208 | command+=(" -" + param.name); |
| 209 | + elif isinstance(param, ParameterExtent): |
| 210 | + values = param.value.split(",") |
| 211 | + for i in range(4): |
| 212 | + command+=(" -" + self.extentParamNames[i] + " " + str(values[i])); |
203 | 213 | elif isinstance(param, (ParameterNumber, ParameterSelection)): |
204 | 214 | command+=(" -" + param.name + " " + str(param.value)); |
205 | 215 | else: |
206 | 216 | command+=(" -" + param.name + " \"" + str(param.value) + "\""); |
207 | 217 |
|
208 | 218 |
|
| 219 | + |
| 220 | + |
209 | 221 | for out in self.outputs: |
210 | 222 | if isinstance(out, OutputRaster): |
211 | 223 | filename = out.value |
|
0 commit comments