Skip to content

Commit 3d9f712

Browse files
author
cpolymeris@gmail.com
committed
otb: region of interest.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@249 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 1c4a756 commit 3d9f712

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/sextante/otb/OTBAlgorithm.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
from sextante.parameters.ParameterSelection import ParameterSelection
1313
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
1414
from sextante.core.SextanteLog import SextanteLog
15+
#~ from sextante.core.Sextante import Sextante
1516
from sextante.parameters.ParameterFactory import ParameterFactory
1617
from sextante.outputs.OutputFactory import OutputFactory
1718
from sextante.otb.OTBUtils import OTBUtils
19+
from sextante.parameters.ParameterExtent import ParameterExtent
1820

1921
class OTBAlgorithm(GeoAlgorithm):
2022

23+
REGION_OF_INTEREST = "ROI"
24+
2125
def __init__(self, descriptionfile):
2226
GeoAlgorithm.__init__(self)
27+
self.roiFile = None
2328
self.descriptionFile = descriptionfile
2429
self.defineCharacteristicsFromFile()
2530
self.numExportedLayers = 0
@@ -60,8 +65,11 @@ def defineCharacteristicsFromFile(self):
6065
param.default = OTBUtils.otbSRTMPath()
6166
if param.name == "-elev.dem.geoid":
6267
param.default = OTBUtils.otbGeoidPath()
63-
6468
self.addParameter(param)
69+
elif line.startswith("Extent"):
70+
self.extentParamNames = line[6:].strip().split(" ")
71+
self.addParameter(ParameterExtent(self.REGION_OF_INTEREST, "Region of interest", "0,1,0,1"))
72+
self.roiFile = SextanteUtils.getTempFilename()
6573
else:
6674
self.addOutput(OutputFactory.getFromString(line))
6775
line = lines.readline().strip("\n").strip()
@@ -83,9 +91,16 @@ def processAlgorithm(self, progress):
8391
for param in self.parameters:
8492
if param.value == None or param.value == "":
8593
continue
86-
if isinstance(param, (ParameterRaster, ParameterVector)):
94+
if isinstance(param, ParameterVector):
8795
commands.append(param.name)
8896
commands.append(param.value)
97+
if isinstance(param, ParameterRaster):
98+
commands.append(param.name)
99+
if self.roiFile:
100+
commands.append(self.roiFile)
101+
self.roiInput = param.name
102+
else:
103+
commands.append(param.value)
89104
elif isinstance(param, ParameterMultipleInput):
90105
commands.append(param.name)
91106
commands.append(str(param.value.replace(";"," ")))
@@ -97,14 +112,24 @@ def processAlgorithm(self, progress):
97112
if param.value:
98113
commands.append(param.name)
99114
commands.append(str(param.value).lower())
115+
elif isinstance(param, ParameterExtent):
116+
self.roiValues = param.value.split(",")
100117
else:
101118
commands.append(param.name)
102119
commands.append(str(param.value))
103120

104121
for out in self.outputs:
105122
commands.append(out.name)
106-
commands.append(out.value);
107-
123+
commands.append(out.value)
124+
125+
if self.roiFile:
126+
args = {"in": self.roiInput,
127+
"out": self.roiFile,
128+
"startx": self.roiValues[0],
129+
"starty": self.roiValues[1],
130+
"sizex": self.roiValues[2],
131+
"sizey": self.roiValues[3]}
132+
Sextante.runalg("ExtractROI", *args)
108133

109134
loglines = []
110135
loglines.append("OTB execution command")

0 commit comments

Comments
 (0)