Skip to content
Permalink
Browse files

[processing] support for output geometry types in scripts and modeler

  • Loading branch information
alexbruy committed Sep 2, 2016
1 parent 7e26124 commit 12d6e15fda0682346d7e496928a035def3186d97
@@ -291,7 +291,10 @@ def getAvailableValuesOfType(self, paramType, outType=None, dataType=None):
if alg.name not in dependent:
for out in alg.algorithm.outputs:
if isinstance(out, outType):
values.append(ValueFromOutput(alg.name, out.name))
if subType is not None and out.datatype in dataType:
values.append(ValueFromOutput(alg.name, out.name))
else:
values.append(ValueFromOutput(alg.name, out.name))

return values

@@ -350,11 +353,11 @@ def getWidgetFromParameter(self, param):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT:
options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_POINT])
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE:
options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_LINE])
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON:
options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_POLYGON])
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
else:
@@ -524,8 +527,16 @@ def setPreviousValues(self):
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
else:
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
else:
options = self.getAvailableValuesOfType(ParameterFile, OutputFile)
selected = []
for i, opt in enumerate(options):
if opt in value:
@@ -751,8 +762,16 @@ def setParamValue(self, alg, param, widget):
elif isinstance(param, ParameterMultipleInput):
if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector)
else:
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON:
options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY])
elif param.datatype == ParameterMultipleInput.TYPE_RASTER:
options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster)
else:
options = self.getAvailableValuesOfType(ParameterFile, OutputFile)
values = [options[i] for i in widget.selectedoptions]
if len(values) == 0 and not param.optional:
return False
@@ -313,8 +313,14 @@ def processOutputParameterToken(self, token):

if token.lower().strip().startswith('raster'):
out = OutputRaster()
elif token.lower().strip().startswith('vector'):
elif token.lower().strip() == 'vector':
out = OutputVector()
elif token.lower().strip() == 'vector point':
out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_POINT])
elif token.lower().strip() == 'vector line':
out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_LINE])
elif token.lower().strip() == 'vector polygon':
out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_POLYGON])
elif token.lower().strip().startswith('table'):
out = OutputTable()
elif token.lower().strip().startswith('html'):

0 comments on commit 12d6e15

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