12
12
from sextante .parameters .ParameterSelection import ParameterSelection
13
13
from sextante .core .GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
14
14
from sextante .core .SextanteLog import SextanteLog
15
- #~ from sextante.core.Sextante import Sextante
15
+ from sextante .core .SextanteUtils import SextanteUtils
16
16
from sextante .parameters .ParameterFactory import ParameterFactory
17
17
from sextante .outputs .OutputFactory import OutputFactory
18
18
from sextante .otb .OTBUtils import OTBUtils
@@ -69,7 +69,7 @@ def defineCharacteristicsFromFile(self):
69
69
elif line .startswith ("Extent" ):
70
70
self .extentParamNames = line [6 :].strip ().split (" " )
71
71
self .addParameter (ParameterExtent (self .REGION_OF_INTEREST , "Region of interest" , "0,1,0,1" ))
72
- self .roiFile = SextanteUtils .getTempFilename ()
72
+ self .roiFile = SextanteUtils .getTempFilename ('tif' )
73
73
else :
74
74
self .addOutput (OutputFactory .getFromString (line ))
75
75
line = lines .readline ().strip ("\n " ).strip ()
@@ -98,7 +98,7 @@ def processAlgorithm(self, progress):
98
98
commands .append (param .name )
99
99
if self .roiFile :
100
100
commands .append (self .roiFile )
101
- self .roiInput = param .name
101
+ self .roiInput = param .value
102
102
else :
103
103
commands .append (param .value )
104
104
elif isinstance (param , ParameterMultipleInput ):
@@ -121,15 +121,20 @@ def processAlgorithm(self, progress):
121
121
for out in self .outputs :
122
122
commands .append (out .name )
123
123
commands .append (out .value )
124
-
124
+
125
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 )
126
+ startX , startY = float (self .roiValues [0 ]), float (self .roiValues [0 ])
127
+ sizeX = float (self .roiValues [2 ]) - startX
128
+ sizeY = float (self .roiValues [3 ]) - startY
129
+ helperCommands = [
130
+ path + os .sep + "otbcli_ExtractROI" ,
131
+ "-in" , self .roiInput ,
132
+ "-out" , self .roiFile ,
133
+ "-startx" , startX ,
134
+ "-starty" , startY ,
135
+ "-sizex" , sizeX ,
136
+ "-sizey" , sizeY ]
137
+ OTBUtils .executeOtb (helperCommands , progress )
133
138
134
139
loglines = []
135
140
loglines .append ("OTB execution command" )
0 commit comments