Skip to content

Commit

Permalink
Hidden output parameters are not used in the main command anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Dec 27, 2017
1 parent feaecea commit 9b6f98a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
3 changes: 3 additions & 0 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -558,6 +558,9 @@ def processCommand(self, parameters, context, delOutputs=False):
# Handle outputs
if not delOutputs:
for out in self.destinationParameterDefinitions():
# We exclude hidden parameters
if out.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
outName = out.name()
# For File destination
if isinstance(out, QgsProcessingParameterFileDestination):
Expand Down
Expand Up @@ -4,11 +4,11 @@ Vector (v.*)
QgsProcessingParameterVectorLayer|from|'from' vector map|-1|None|False
*QgsProcessingParameterEnum|from_type|'from' feature type|point;line;boundary;area;centroid|True|0,1,3|True
QgsProcessingParameterVectorLayer|to|'to' vector map|-1|None|False
*QgsProcessingParameterEnum|to_type|'from' feature type|point;line;boundary;area;centroid|True|0,1,3|True
*QgsProcessingParameterEnum|to_type|'to' feature type|point;line;boundary;area;centroid|True|0,1,3|True
QgsProcessingParameterNumber|dmax|Maximum distance or -1.0 for no limit|QgsProcessingParameterNumber.Double|-1.0|True|-1.0|None
QgsProcessingParameterNumber|dmin|Minimum distance or -1.0 for no limit|QgsProcessingParameterNumber.Double|-1.0|Truee|-1.0|None
QgsProcessingParameterString|upload|'upload': Values describing the relation between two nearest features (cat,dist,to_x,to_y,to_along,to_angle,to_attr)|cat|False|True
QgsProcessingParameterString|column|Column name(s) where values specified by 'upload' option will be uploaded|None|False|True
QgsProcessingParameterNumber|dmin|Minimum distance or -1.0 for no limit|QgsProcessingParameterNumber.Double|-1.0|True|-1.0|None
QgsProcessingParameterEnum|upload|'upload': Values describing the relation between two nearest features|cat;dist;to_x;to_y;to_along;to_angle;to_attr)|True|0|False
QgsProcessingParameterField|column|Column name(s) where values specified by 'upload' option will be uploaded|None|from|0|True|False
QgsProcessingParameterField|to_column|Column name of nearest feature (used with upload=to_attr)|None|to|-1|False|True
QgsProcessingParameterVectorDestination|from_output|Nearest
QgsProcessingParameterVectorDestination|output|Distance
33 changes: 11 additions & 22 deletions python/plugins/processing/algs/grass7/ext/v_distance.py
Expand Up @@ -25,36 +25,25 @@

__revision__ = '$Format:%H$'

import os

from qgis.core import QgsProcessingParameterDefinition

def checkParameterValuesBeforeExecuting(alg, parameters, context):
""" Verify if we have the right parameters """
# Verify upload value
upload = alg.parameterAsString(parameters, 'upload', context)
if upload:
uploadList = [f for f in upload.split(",") if f not in ['cat', 'dist', 'to_x', 'to_y', 'to_along', 'to_angle', 'to_attr']]
if len(uploadList) > 0:
return alg.tr(u"Upload parameters should be a list of elements taken in the following values:\n'cat', 'dist', 'to_x', 'to_y', 'to_along', 'to_angle', 'to_attr'")
# Verifiy that we have the good number of columns
column = alg.parameterAsString(parameters, 'column', context)
if ((column is None or len(column) == 0) and upload) or (len(column.split(",")) != len(upload.split(","))):
return alg.tr(u"The number of columns and the number of upload parameters should be equal!")

# Verify from_type and to_type values
for geom in [u'from', u'to']:
geoType = alg.parameterAsString(parameters, '{}_type'.format(geom), context)
if geoType:
geoTypeList = [f for f in geoType.split(",") if f not in ['point', 'line', 'boundary', 'centroid', 'area']]
if len(geoTypeList) > 0:
return alg.tr(u"Feature type for '{}' should be a list of elements taken in the following values:\n'point', 'line', 'boundary', 'centroid', 'area'".format(geom))
# Verifiy that we have the good number of columns
uploads = alg.parameterAsEnums(parameters, 'upload', context)
columns = alg.parameterAsFields(parameters, 'column', context)
if len(columns) != len(uploads):
return alg.tr(u"The number of columns and the number of upload parameters should be equal!")

return None


def processCommand(alg, parameters, context):
# We do not incorporate outputs in commands
alg.processCommand(parameters, context, True)
# We need to disable only from_output parameter
fromOutput = alg.parameterDefinition('from_output')
fromOutput.setFlags(fromOutput.flags() | QgsProcessingParameterDefinition.FlagHidden)
alg.processCommand(parameters, context, False)
fromOutput.setFlags(fromOutput.flags() | QgsProcessingParameterDefinition.FlagHidden)


def processOutputs(alg, parameters, context):
Expand Down

0 comments on commit 9b6f98a

Please sign in to comment.