16
16
* *
17
17
***************************************************************************
18
18
"""
19
- from processing . gui . Help2Html import getHtmlFromRstFile
19
+
20
20
21
21
__author__ = 'Victor Olaya'
22
22
__date__ = 'August 2012'
30
30
from qgis .core import *
31
31
from PyQt4 .QtCore import *
32
32
from PyQt4 .QtGui import *
33
-
33
+ from processing . gui . Help2Html import getHtmlFromRstFile
34
34
from processing .core .GeoAlgorithm import GeoAlgorithm
35
35
from processing .core .ProcessingConfig import ProcessingConfig
36
36
from processing .core .ProcessingLog import ProcessingLog
37
37
from processing .core .GeoAlgorithmExecutionException import \
38
38
GeoAlgorithmExecutionException
39
39
from processing .core .parameters import *
40
40
from processing .core .outputs import *
41
- from SagaUtils import SagaUtils
41
+ import SagaUtils
42
42
from SagaGroupNameDecorator import SagaGroupNameDecorator
43
43
from processing .tools import dataobjects
44
44
from processing .tools .system import *
45
45
46
46
sessionExportedLayers = {}
47
47
48
48
49
- class SagaAlgorithm (GeoAlgorithm ):
49
+ class SagaAlgorithm212 (GeoAlgorithm ):
50
50
51
51
OUTPUT_EXTENT = 'OUTPUT_EXTENT'
52
52
@@ -58,7 +58,7 @@ def __init__(self, descriptionfile):
58
58
self .defineCharacteristicsFromFile ()
59
59
60
60
def getCopy (self ):
61
- newone = SagaAlgorithm (self .descriptionFile )
61
+ newone = SagaAlgorithm212 (self .descriptionFile )
62
62
newone .provider = self .provider
63
63
return newone
64
64
@@ -100,12 +100,6 @@ def defineCharacteristicsFromFile(self):
100
100
101
101
102
102
def processAlgorithm (self , progress ):
103
- if isWindows ():
104
- path = SagaUtils .sagaPath ()
105
- if path == '' :
106
- raise GeoAlgorithmExecutionException (
107
- 'SAGA folder is not configured.\n Please configure \
108
- it before running SAGA algorithms.' )
109
103
commands = list ()
110
104
self .exportedLayers = {}
111
105
@@ -165,12 +159,7 @@ def processAlgorithm(self, progress):
165
159
'Unsupported file format' )
166
160
167
161
# 2: Set parameters and outputs
168
- saga208 = SagaUtils .isSaga208 ()
169
- if isWindows () or isMac () or not saga208 :
170
- command = self .undecoratedGroup + ' "' + self .cmdname + '"'
171
- else :
172
- command = 'lib' + self .undecoratedGroup + ' "' + self .cmdname + '"'
173
-
162
+ command = self .undecoratedGroup + ' "' + self .cmdname + '"'
174
163
if self .hardcodedStrings :
175
164
for s in self .hardcodedStrings :
176
165
command += ' ' + s
@@ -240,7 +229,7 @@ def processAlgorithm(self, progress):
240
229
if isinstance (out , OutputRaster ):
241
230
filename = out .getCompatibleFileName (self )
242
231
filename2 = filename + '.sgrd'
243
- formatIndex = (4 if not saga208 and isWindows () else 1 )
232
+ formatIndex = (4 if isWindows () else 1 )
244
233
sessionExportedLayers [filename ] = filename2
245
234
dontExport = True
246
235
@@ -256,23 +245,14 @@ def processAlgorithm(self, progress):
256
245
# continue
257
246
258
247
if self .cmdname == 'RGB Composite' :
259
- if isWindows () or isMac () or not saga208 :
260
- commands .append ('io_grid_image 0 -IS_RGB -GRID:"' + filename2
261
- + '" -FILE:"' + filename
262
- + '"' )
263
- else :
264
- commands .append ('libio_grid_image 0 -IS_RGB -GRID:"' + filename2
248
+ commands .append ('io_grid_image 0 -IS_RGB -GRID:"' + filename2
265
249
+ '" -FILE:"' + filename
266
250
+ '"' )
267
251
else :
268
- if isWindows () or isMac () or not saga208 :
269
- commands .append ('io_gdal 1 -GRIDS "' + filename2
270
- + '" -FORMAT ' + str (formatIndex )
271
- + ' -TYPE 0 -FILE "' + filename + '"' )
272
- else :
273
- commands .append ('libio_gdal 1 -GRIDS "' + filename2
274
- + '" -FORMAT 1 -TYPE 0 -FILE "' + filename
275
- + '"' )
252
+ commands .append ('io_gdal 1 -GRIDS "' + filename2
253
+ + '" -FORMAT ' + str (formatIndex )
254
+ + ' -TYPE 0 -FILE "' + filename + '"' )
255
+
276
256
277
257
# 4: Run SAGA
278
258
commands = self .editCommands (commands )
@@ -339,28 +319,7 @@ def exportRasterLayer(self, source):
339
319
destFilename = getTempFilenameInTempFolder (filename + '.sgrd' )
340
320
self .exportedLayers [source ] = destFilename
341
321
sessionExportedLayers [source ] = destFilename
342
- saga208 = SagaUtils .isSaga208 ()
343
- if saga208 :
344
- if isWindows () or isMac ():
345
- return 'io_gdal 0 -GRIDS "' + destFilename + '" -FILES "' + source \
346
- + '"'
347
- else :
348
- return 'libio_gdal 0 -GRIDS "' + destFilename + '" -FILES "' \
349
- + source + '"'
350
- else :
351
- return 'io_gdal 0 -TRANSFORM -INTERPOL 0 -GRIDS "' + destFilename + '" -FILES "' + source \
352
- + '"'
353
-
354
- def checkBeforeOpeningParametersDialog (self ):
355
- msg = SagaUtils .checkSagaIsInstalled ()
356
- if msg is not None :
357
- print msg
358
- html = '<p>This algorithm requires SAGA to be run.Unfortunately, \
359
- it seems that SAGA is not installed in your system, or it \
360
- is not correctly configured to be used from QGIS</p>'
361
- html += '<p><a href= "http://docs.qgis.org/2.0/en/docs/user_manual/processing/3rdParty.html">\
362
- Click here</a> to know more about how to install and configure SAGA to be used with QGIS</p>'
363
- return html
322
+ return 'io_gdal 0 -TRANSFORM -INTERPOL 0 -GRIDS "' + destFilename + '" -FILES "' + source + '"'
364
323
365
324
def checkParameterValuesBeforeExecuting (self ):
366
325
"""
@@ -372,7 +331,8 @@ def checkParameterValuesBeforeExecuting(self):
372
331
files = []
373
332
if isinstance (param , ParameterRaster ):
374
333
files = [param .value ]
375
- elif isinstance (param , ParameterMultipleInput ) and param .datatype == ParameterMultipleInput .TYPE_RASTER :
334
+ elif (isinstance (param , ParameterMultipleInput ) and
335
+ param .datatype == ParameterMultipleInput .TYPE_RASTER ):
376
336
if param .value is not None :
377
337
files = param .value .split (";" )
378
338
for f in files :
@@ -405,17 +365,3 @@ def help(self):
405
365
html = ('<img src="%s"/>' % imgpath ) + html
406
366
return True , html
407
367
408
- def getPostProcessingErrorMessage (self , wrongLayers ):
409
- html = GeoAlgorithm .getPostProcessingErrorMessage (self , wrongLayers )
410
- msg = SagaUtils .checkSagaIsInstalled (True )
411
- html += '<p>This algorithm requires SAGA to be run. A test to check \
412
- if SAGA is correctly installed and configured in your system \
413
- has been performed, with the following result:</p><ul><i>'
414
- if msg is None :
415
- html += 'SAGA seems to be correctly installed and \
416
- configured</li></ul>'
417
- else :
418
- html += msg + '</i></li></ul>'
419
- html += '<p><a href= "http://docs.qgis.org/2.0/en/docs/user_manual/processing/3rdParty.html">Click here</a> to know more about how to install and configure SAGA to be used with QGIS</p>'
420
-
421
- return html
0 commit comments