Skip to content
Permalink
Browse files

[processing] allow using layer names as input values

  • Loading branch information
volaya committed Jul 3, 2015
1 parent 12736ac commit 2083d6db258b7d92a0a0ead1d3240d656c574db1
Showing with 20 additions and 2 deletions.
  1. +20 −2 python/plugins/processing/core/GeoAlgorithm.py
@@ -38,7 +38,7 @@
from processing.core.ProcessingLog import ProcessingLog
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterRaster, ParameterVector, ParameterMultipleInput, Parameter
from processing.core.parameters import ParameterRaster, ParameterVector, ParameterMultipleInput, ParameterTable, Parameter
from processing.core.outputs import OutputVector, OutputRaster, OutputTable, OutputHTML, Output
from processing.algs.gdal.GdalUtils import GdalUtils
from processing.tools import dataobjects, vector
@@ -222,6 +222,7 @@ def execute(self, progress=None, model=None):
try:
self.setOutputCRS()
self.resolveTemporaryOutputs()
self.resolveDataObjects()
self.checkOutputFileExtensions()
self.runPreExecutionScript(progress)
self.processAlgorithm(progress)
@@ -256,7 +257,7 @@ def _checkParameterValuesBeforeExecuting(self):
else:
inputlayers = [param.value]
for inputlayer in inputlayers:
obj = dataobjects.getObjectFromUri(inputlayer)
obj = dataobjects.getObject(inputlayer)
if obj is None:
return "Wrong parameter value: " + param.value
return self.checkParameterValuesBeforeExecuting()
@@ -421,6 +422,23 @@ def setOutputCRS(self):
except:
pass

def resolveDataObjects(self):
layers = dataobjects.getAllLayers()
for param in self.parameters:
if isinstance(param, (ParameterRaster, ParameterVector, ParameterTable,
ParameterMultipleInput)):
if param.value:
if isinstance(param, ParameterMultipleInput):
inputlayers = param.value.split(';')
else:
inputlayers = [param.value]
for i, inputlayer in enumerate(inputlayers):
for layer in layers:
if layer.name() == inputlayer:
inputlayers[i] = layer.source()
break
param.setValue(",".join(inputlayers))


def checkInputCRS(self):
"""It checks that all input layers use the same CRS. If so,

0 comments on commit 2083d6d

Please sign in to comment.
You can’t perform that action at this time.