Skip to content
Permalink
Browse files
Merge pull request #1389 from radosuav/small_processing_fixes
[processing] Small fixes
  • Loading branch information
volaya committed Jun 12, 2014
2 parents fa88eb2 + 2ef7dcf commit 023fc007e6e0862dad0e9ff9db011c40f73bc1d4
@@ -0,0 +1,10 @@
r.slope.aspect
r.slope - Generates raster maps of slope from a elevation raster map.
Raster (r.*)
ParameterRaster|elevation|Name of elevation raster map|False
ParameterSelection|format|Format for reporting the slope|degrees;percent
ParameterSelection|prec|Type of output aspect and slope maps|float;double;int
ParameterNumber|zfactor|Multiplicative factor to convert elevation units to meters|None|None|1.0
ParameterNumber|min_slp_allowed|Minimum slope val. (in percent) for which aspect is computed|None|None|0.0
ParameterBoolean|-a|Do not align the current region to the elevation layer|True
OutputRaster|slope|Name for output slope raster map
@@ -0,0 +1,29 @@
<root>
<key>SplitImage</key>
<exec>otbcli_SplitImage</exec>
<longname>Split Image</longname>
<group>Image Manipulation</group>
<description>Rescale the image between two given values.</description>
<parameter>
<parameter_type source_parameter_type="ParameterType_InputImage">ParameterRaster</parameter_type>
<key>in</key>
<name>Input Image</name>
<description>Input image to be split into individual images.</description>
<optional>False</optional>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_OutputImage">OutputFile</parameter_type>
<key>out</key>
<name>Output Image</name>
<description>The base filename of the split images.</description>
</parameter>
<parameter>
<parameter_type source_parameter_type="ParameterType_RAM">ParameterNumber</parameter_type>
<key>ram</key>
<name>Available RAM (Mb)</name>
<description>Available memory for processing (in MB)</description>
<minValue />
<maxValue />
<default>128</default>
</parameter>
</root>
@@ -239,7 +239,7 @@ def processAlgorithm(self, progress):
if self.showPlots:
htmlfilename = self.getOutputValue(RAlgorithm.RPLOTS)
f = open(htmlfilename, 'w')
f.write('<img src="' + self.plotsFilename + '"/>')
f.write('<html><img src="' + self.plotsFilename + '"/></html>')
f.close()
if self.showConsoleOutput:
htmlfilename = self.getOutputValue(RAlgorithm.R_CONSOLE_OUTPUT)
@@ -88,16 +88,17 @@ def _loadAlgorithms(self):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('rsx'):
try:
fullpath = os.path.join(folder, descriptionFile)
alg = RAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load R script:' + descriptionFile + '\n'
+ unicode(e))
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('rsx'):
try:
fullpath = os.path.join(path, descriptionFile)
alg = RAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load R script:' + descriptionFile + '\n'
+ unicode(e))
@@ -65,6 +65,8 @@ class Processing:
listeners = []
providers = []

toolbox = None

# A dictionary of algorithms. Keys are names of providers
# and values are list with all algorithms from that provider
algs = {}
@@ -77,6 +79,10 @@ class Processing:

modeler = ModelerAlgorithmProvider()

@staticmethod
def setToolbox(toolbox):
Processing.toolbox = toolbox

@staticmethod
def addProvider(provider, updateList=False):
"""Use this method to add algorithms from external providers.
@@ -89,8 +95,8 @@ def addProvider(provider, updateList=False):
provider.initializeSettings()
Processing.providers.append(provider)
ProcessingConfig.readSettings()
if updateList:
Processing.updateAlgsList()
if updateList and Processing.toolbox:
Processing.toolbox.updateTree()
except:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load provider:'
@@ -109,7 +115,8 @@ def removeProvider(provider):
provider.unload()
Processing.providers.remove(provider)
ProcessingConfig.readSettings()
Processing.updateAlgsList()
if Processing.toolbox:
Processing.toolbox.updateTree()
except:
# This try catch block is here to avoid problems if the
# plugin with a provider is unloaded after the Processing
@@ -248,6 +248,11 @@ def accept(self):
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))

self.setInfo('<b>Algorithm %s starting...</b>' % self.alg.name)
# make sure the log tab is visible before executing the algorithm
try:
self.repaint()
except:
pass
if self.iterateParam:
if UnthreadedAlgorithmExecutor.runalgIterating(self.alg,
self.iterateParam, self):
@@ -200,6 +200,11 @@ def accept(self):
for (i, alg) in enumerate(self.algs):
self.setBaseText('Processing algorithm ' + str(i + 1) + '/'
+ str(len(self.algs)) + '...')
# make sure the log tab is visible before executing the algorithm
try:
self.repaint()
except:
pass
if UnthreadedAlgorithmExecutor.runalg(alg, self) \
and not self.canceled:
if self.load[i]:
@@ -72,6 +72,7 @@ def __init__(self):
if hasattr(self.searchBox, 'setPlaceholderText'):
self.searchBox.setPlaceholderText(self.tr('Search...'))

Processing.setToolbox(self)
self.fillTree()

def textChanged(self):
@@ -81,16 +81,17 @@ def _loadAlgorithms(self):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('model'):
try:
alg = ModelerAlgorithm()
fullpath = os.path.join(folder, descriptionFile)
alg.openModel(fullpath)
if alg.name.strip() != '':
alg.provider = self
self.algs.append(alg)
except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + descriptionFile + '\n'
+ e.msg)
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('model'):
try:
alg = ModelerAlgorithm()
fullpath = os.path.join(path, descriptionFile)
alg.openModel(fullpath)
if alg.name.strip() != '':
alg.provider = self
self.algs.append(alg)
except WrongModelException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load model ' + descriptionFile + '\n'
+ e.msg)
@@ -35,7 +35,13 @@ class OutputRaster(Output):
compatible = None

def getFileFilter(self, alg):
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
providerExts = alg.provider.getSupportedOutputRasterLayerExtensions()
if providerExts == ['tif']:
# use default extensions
exts = dataobjects.getSupportedOutputRasterLayerExtensions()
else:
# use extensions given by the algorithm provider
exts = providerExts
for i in range(len(exts)):
exts[i] = exts[i].upper() + ' files(*.' + exts[i].lower() + ')'
return ';;'.join(exts)
@@ -83,16 +83,17 @@ def _loadAlgorithms(self):
def loadFromFolder(self, folder):
if not os.path.exists(folder):
return
for descriptionFile in os.listdir(folder):
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(folder, descriptionFile)
alg = ScriptAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load script:' + descriptionFile + '\n'
+ unicode(e))
for path, subdirs, files in os.walk(folder):
for descriptionFile in files:
if descriptionFile.endswith('py'):
try:
fullpath = os.path.join(path, descriptionFile)
alg = ScriptAlgorithm(fullpath)
if alg.name.strip() != '':
self.algs.append(alg)
except WrongScriptException, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg)
except Exception, e:
ProcessingLog.addToLog(ProcessingLog.LOG_ERROR,
'Could not load script:' + descriptionFile + '\n'
+ unicode(e))

0 comments on commit 023fc00

Please sign in to comment.