35
35
from processing .core .outputs import OutputRaster , OutputVector , OutputTable
36
36
import SagaUtils
37
37
from processing .tools import dataobjects
38
- from processing .tools .system import getTempFilenameInTempFolder , getTempFilename , isWindows
38
+ from processing .tools .system import getTempFilename
39
39
40
40
sessionExportedLayers = {}
41
41
@@ -161,50 +161,23 @@ def processAlgorithm(self, progress):
161
161
command += ' -' + param .name + ' "' + str (param .value ) + '"'
162
162
163
163
for out in self .outputs :
164
- if isinstance (out , OutputRaster ):
165
- filename = out .getCompatibleFileName (self )
166
- filename += '.sgrd'
167
- command += ' -' + out .name + ' "' + filename + '"'
168
- if isinstance (out , OutputVector ):
169
- filename = out .getCompatibleFileName (self )
170
- command += ' -' + out .name + ' "' + filename + '"'
171
- if isinstance (out , OutputTable ):
172
- filename = out .getCompatibleFileName (self )
173
- command += ' -' + out .name + ' "' + filename + '"'
164
+ command += ' -' + out .name + ' "' + out .getCompatibleFileName (self ) + '"'
174
165
175
166
commands .append (command )
176
167
177
- # 3: Export resulting raster layers
178
- # optim = ProcessingConfig.getSetting( SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION)
168
+ # special treatment for RGB algorithm
169
+ #TODO: improve this and put this code somewhere else
179
170
for out in self .outputs :
180
171
if isinstance (out , OutputRaster ):
181
172
filename = out .getCompatibleFileName (self )
182
173
filename2 = filename + '.sgrd'
183
- formatIndex = (4 if isWindows () else 1 )
184
- sessionExportedLayers [filename ] = filename2
185
- # Do not export is the output is not a final output
186
- # of the model
187
- # dontExport = True
188
- #if self.model is not None and optim:
189
- # for subalg in self.model.algOutputs:
190
- # if out.name in subalg:
191
- # if subalg[out.name] is not None:
192
- # dontExport = False
193
- # break
194
- # if dontExport:
195
- # continue
196
-
197
174
if self .cmdname == 'RGB Composite' :
198
175
commands .append ('io_grid_image 0 -IS_RGB -GRID:"' + filename2
199
176
+ '" -FILE:"' + filename
200
177
+ '"' )
201
- else :
202
- commands .append ('io_gdal 1 -GRIDS "' + filename2
203
- + '" -FORMAT ' + str (formatIndex )
204
- + ' -TYPE 0 -FILE "' + filename + '"' )
205
178
206
179
207
- # 4 : Run SAGA
180
+ # 3 : Run SAGA
208
181
commands = self .editCommands (commands )
209
182
SagaUtils .createSagaBatchJobFileFromSagaCommands (commands )
210
183
loglines = []
@@ -216,25 +189,4 @@ def processAlgorithm(self, progress):
216
189
ProcessingLog .addToLog (ProcessingLog .LOG_INFO , loglines )
217
190
SagaUtils .executeSaga (progress )
218
191
219
- def exportRasterLayer (self , source ):
220
- global sessionExportedLayers
221
- if source in sessionExportedLayers :
222
- exportedLayer = sessionExportedLayers [source ]
223
- if os .path .exists (exportedLayer ):
224
- self .exportedLayers [source ] = exportedLayer
225
- return None
226
- else :
227
- del sessionExportedLayers [source ]
228
- layer = dataobjects .getObjectFromUri (source , False )
229
- if layer :
230
- filename = layer .name ()
231
- else :
232
- filename = os .path .basename (source )
233
- validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:'
234
- filename = '' .join (c for c in filename if c in validChars )
235
- if len (filename ) == 0 :
236
- filename = 'layer'
237
- destFilename = getTempFilenameInTempFolder (filename + '.sgrd' )
238
- self .exportedLayers [source ] = destFilename
239
- sessionExportedLayers [source ] = destFilename
240
- return 'io_gdal 0 -TRANSFORM -INTERPOL 0 -GRIDS "' + destFilename + '" -FILES "' + source + '"'
192
+
0 commit comments