mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] i18n support for SAGA provider
This commit is contained in:
parent
e1d8710d8c
commit
07462f5476
@ -125,7 +125,7 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
self.exportedLayers[param.value] = filename
|
||||
elif not param.value.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
if isinstance(param, ParameterTable):
|
||||
if param.value is None:
|
||||
continue
|
||||
@ -135,7 +135,7 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
self.exportedLayers[param.value] = filename
|
||||
elif not param.value.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
if isinstance(param, ParameterMultipleInput):
|
||||
if param.value is None:
|
||||
continue
|
||||
@ -156,7 +156,7 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
self.exportedLayers[layerfile] = filename
|
||||
elif not layerfile.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
|
||||
# 2: Set parameters and outputs
|
||||
command = self.undecoratedGroup + ' "' + self.cmdname + '"'
|
||||
@ -246,8 +246,8 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
|
||||
if self.cmdname == 'RGB Composite':
|
||||
commands.append('io_grid_image 0 -IS_RGB -GRID:"' + filename2
|
||||
+ '" -FILE:"' + filename
|
||||
+ '"')
|
||||
+ '" -FILE:"' + filename
|
||||
+ '"')
|
||||
else:
|
||||
commands.append('io_gdal 1 -GRIDS "' + filename2
|
||||
+ '" -FORMAT ' + str(formatIndex)
|
||||
@ -258,7 +258,7 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
commands = self.editCommands(commands)
|
||||
SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
|
||||
loglines = []
|
||||
loglines.append('SAGA execution commands')
|
||||
loglines.append(self.tr('SAGA execution commands'))
|
||||
for line in commands:
|
||||
progress.setCommand(line)
|
||||
loglines.append(line)
|
||||
@ -340,18 +340,15 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
if layer is None:
|
||||
continue
|
||||
if layer.bandCount() > 1:
|
||||
return 'Input layer ' + str(layer.name()) \
|
||||
+ ' has more than one band.\n' \
|
||||
+ 'Multiband layers are not supported by SAGA'
|
||||
return self.tr('Input layer %s has more than one band.\n'
|
||||
'Multiband layers are not supported by SAGA' % str(layer.name()))
|
||||
if not self.allowUnmatchingGridExtents:
|
||||
if extent is None:
|
||||
extent = (layer.extent(), layer.height(), layer.width())
|
||||
else:
|
||||
extent2 = (layer.extent(), layer.height(), layer.width())
|
||||
if extent != extent2:
|
||||
return "Input layers do not have the same grid extent."
|
||||
|
||||
|
||||
return self.tr("Input layers do not have the same grid extent.")
|
||||
|
||||
def help(self):
|
||||
name = self.cmdname.lower()
|
||||
@ -364,4 +361,3 @@ class SagaAlgorithm212(GeoAlgorithm):
|
||||
imgpath = os.path.join(os.path.dirname(__file__),os.pardir, os.pardir, 'images', 'saga100x100.jpg')
|
||||
html = ('<img src="%s"/>' % imgpath) + html
|
||||
return True, html
|
||||
|
||||
|
@ -79,7 +79,7 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
self.exportedLayers[param.value] = filename
|
||||
elif not param.value.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
if isinstance(param, ParameterTable):
|
||||
if param.value is None:
|
||||
continue
|
||||
@ -89,7 +89,7 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
self.exportedLayers[param.value] = filename
|
||||
elif not param.value.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
if isinstance(param, ParameterMultipleInput):
|
||||
if param.value is None:
|
||||
continue
|
||||
@ -110,7 +110,7 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
self.exportedLayers[layerfile] = filename
|
||||
elif not layerfile.endswith('shp'):
|
||||
raise GeoAlgorithmExecutionException(
|
||||
'Unsupported file format')
|
||||
self.tr('Unsupported file format'))
|
||||
|
||||
# 2: Set parameters and outputs
|
||||
command = self.undecoratedGroup + ' "' + self.cmdname + '"'
|
||||
@ -202,8 +202,8 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
|
||||
if self.cmdname == 'RGB Composite':
|
||||
commands.append('io_grid_image 0 -IS_RGB -GRID:"' + filename2
|
||||
+ '" -FILE:"' + filename
|
||||
+ '"')
|
||||
+ '" -FILE:"' + filename
|
||||
+ '"')
|
||||
else:
|
||||
commands.append('io_gdal 1 -GRIDS "' + filename2
|
||||
+ '" -FORMAT ' + str(formatIndex)
|
||||
@ -214,7 +214,7 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
commands = self.editCommands(commands)
|
||||
SagaUtils.createSagaBatchJobFileFromSagaCommands(commands)
|
||||
loglines = []
|
||||
loglines.append('SAGA execution commands')
|
||||
loglines.append(self.tr('SAGA execution commands'))
|
||||
for line in commands:
|
||||
progress.setCommand(line)
|
||||
loglines.append(line)
|
||||
@ -222,7 +222,6 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_INFO, loglines)
|
||||
SagaUtils.executeSaga(progress)
|
||||
|
||||
|
||||
def exportRasterLayer(self, source):
|
||||
global sessionExportedLayers
|
||||
if source in sessionExportedLayers:
|
||||
@ -242,8 +241,3 @@ class SagaAlgorithm213(SagaAlgorithm212):
|
||||
self.exportedLayers[source] = destFilename
|
||||
sessionExportedLayers[source] = destFilename
|
||||
return 'io_gdal 0 -TRANSFORM -INTERPOL 0 -GRIDS "' + destFilename + '" -FILES "' + source + '"'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -51,17 +51,16 @@ class SagaAlgorithmProvider(AlgorithmProvider):
|
||||
AlgorithmProvider.initializeSettings(self)
|
||||
if isWindows() or isMac():
|
||||
ProcessingConfig.addSetting(Setting("SAGA",
|
||||
SagaUtils.SAGA_FOLDER, 'SAGA folder', ''))
|
||||
SagaUtils.SAGA_FOLDER, self.tr('SAGA folder'), ''))
|
||||
ProcessingConfig.addSetting(Setting("SAGA",
|
||||
SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION,
|
||||
'Enable SAGA Import/Export optimizations',
|
||||
False))
|
||||
SagaUtils.SAGA_IMPORT_EXPORT_OPTIMIZATION,
|
||||
self.tr('Enable SAGA Import/Export optimizations'), False))
|
||||
ProcessingConfig.addSetting(Setting("SAGA",
|
||||
SagaUtils.SAGA_LOG_COMMANDS,
|
||||
'Log execution commands', True))
|
||||
SagaUtils.SAGA_LOG_COMMANDS,
|
||||
self.tr('Log execution commands'), True))
|
||||
ProcessingConfig.addSetting(Setting("SAGA",
|
||||
SagaUtils.SAGA_LOG_CONSOLE,
|
||||
'Log console output', True))
|
||||
SagaUtils.SAGA_LOG_CONSOLE,
|
||||
self.tr('Log console output'), True))
|
||||
|
||||
def unload(self):
|
||||
AlgorithmProvider.unload(self)
|
||||
@ -71,17 +70,16 @@ class SagaAlgorithmProvider(AlgorithmProvider):
|
||||
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_CONSOLE)
|
||||
ProcessingConfig.removeSetting(SagaUtils.SAGA_LOG_COMMANDS)
|
||||
|
||||
|
||||
def _loadAlgorithms(self):
|
||||
self.algs = []
|
||||
version = SagaUtils.getSagaInstalledVersion(True)
|
||||
if version is None:
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
|
||||
'Problem with SAGA installation: SAGA was not found or is not correctly installed')
|
||||
self.tr('Problem with SAGA installation: SAGA was not found or is not correctly installed'))
|
||||
return
|
||||
if version not in self.supportedVersions:
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
|
||||
'Problem with SAGA installation: installed SAGA version (%s) is not supported' % version)
|
||||
self.tr('Problem with SAGA installation: installed SAGA version (%s) is not supported' % version))
|
||||
return
|
||||
|
||||
folder = SagaUtils.sagaDescriptionPath()
|
||||
@ -99,12 +97,10 @@ class SagaAlgorithmProvider(AlgorithmProvider):
|
||||
self.algs.append(alg)
|
||||
else:
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
|
||||
'Could not open SAGA algorithm: '
|
||||
+ descriptionFile)
|
||||
self.tr('Could not open SAGA algorithm: %s' % descriptionFile))
|
||||
except Exception, e:
|
||||
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
|
||||
'Could not open SAGA algorithm: '
|
||||
+ descriptionFile + '\n' + str(e))
|
||||
self.tr('Could not open SAGA algorithm: %s\n%s' % (descriptionFile, str(e))))
|
||||
def getDescription(self):
|
||||
return 'SAGA (%s)' % SagaUtils.getSagaInstalledVersion()
|
||||
|
||||
|
@ -137,7 +137,7 @@ def executeSaga(progress):
|
||||
| stat.S_IREAD | stat.S_IWRITE)
|
||||
command = [sagaBatchJobFilename()]
|
||||
loglines = []
|
||||
loglines.append('SAGA execution console output')
|
||||
loglines.append(QCoreApplication.translate('SagaUtils', 'SAGA execution console output'))
|
||||
proc = subprocess.Popen(
|
||||
command,
|
||||
shell=True,
|
||||
|
@ -47,11 +47,14 @@ class SplitRGBBands(GeoAlgorithm):
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'Split RGB bands'
|
||||
self.group = 'Grid - Tools'
|
||||
self.addParameter(ParameterRaster(SplitRGBBands.INPUT, 'Input layer',
|
||||
False))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.R, 'Output R band layer'))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.G, 'Output G band layer'))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.B, 'Output B band layer'))
|
||||
self.addParameter(ParameterRaster(SplitRGBBands.INPUT,
|
||||
self.tr('Input layer'), False))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.R,
|
||||
self.tr('Output R band layer')))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.G,
|
||||
self.tr('Output G band layer')))
|
||||
self.addOutput(OutputRaster(SplitRGBBands.B,
|
||||
self.tr('Output B band layer')))
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
# TODO: check correct num of bands
|
||||
|
Loading…
x
Reference in New Issue
Block a user