Skip to content

Commit

Permalink
Fix multiple enum parameters handling and some ext scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Médéric RIBREUX committed Dec 27, 2017
1 parent 3fa9e3c commit 36311ff
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 56 deletions.
8 changes: 6 additions & 2 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Expand Up @@ -524,8 +524,12 @@ def processCommand(self, parameters, context, delOutputs=False):
command += ' {}'.format(paramName)
# For enumeration, we need to grab the string value
elif isinstance(param, QgsProcessingParameterEnum):
idx = self.parameterAsEnum(parameters, paramName, context)
value = '"{}"'.format(param.options()[idx])
# Handle multiple values
if param.allowMultiple():
indexes = self.parameterAsEnums(parameters, paramName, context)
else:
indexes = [self.parameterAsEnum(parameters, paramName, context)]
value = '"{}"'.format(','.join([param.options()[i] for i in indexes]))
# For strings, we just translate as string
elif isinstance(param, QgsProcessingParameterString):
data = self.parameterAsString(parameters, paramName, context)
Expand Down
6 changes: 0 additions & 6 deletions python/plugins/processing/algs/grass7/TODO.md
Expand Up @@ -14,12 +14,6 @@ QGIS3 Processing Port
* r_mask_vect.py
* r_mask_rast.py
* r_statistics.py
* v_voronoi.py
* v_to_3d.py.
* v_what_rast_points.py.
* v_what_rast_centroids.py.
* v_vect_stats.py
* v_rast_stats.py
* v_net.py
* v_net_alloc.py
* v_net_allpairs.py
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/v_rast_stats.py
Expand Up @@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
def processOutputs(alg, parameters, context):
# We need to add the initial vector layer to outputs:
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
grassName = '{}{}'.format('map', alg.uniqueSuffix)
grassName = alg.exportedLayers['map']
dataType = 'auto'
alg.exportVectorLayer(grassName, fileName, dataType)
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/v_to_3d.py
Expand Up @@ -40,6 +40,6 @@ def processInputs(alg, parameters, context):
if 'input' in alg.exportedLayers:
return

# We need to import all the bands and color tables of the input raster
# We need to import the vector layer with v.in.ogr
alg.loadVectorLayerFromParameter('input', parameters, context, False)
alg.postInputs()
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/grass7/ext/v_vect_stats.py
Expand Up @@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
def processOutputs(alg, parameters, context):
# We need to add the initial vector layer to outputs:
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
grassName = '{}{}'.format('map', alg.uniqueSuffix)
grassName = alg.exportedLayers['areas']
dataType = 'auto'
alg.exportVectorLayer(grassName, fileName, dataType)
Expand Up @@ -2,10 +2,10 @@

"""
***************************************************************************
v_what_rast_points.py
v_what_rast.py
---------------------
Date : January 2016
Copyright : (C) 2016 by Médéric Ribreux
Date : December 2017
Copyright : (C) 2017 by Médéric Ribreux
Email : medspx at medspx dot fr
***************************************************************************
* *
Expand All @@ -18,8 +18,8 @@
"""

__author__ = 'Médéric Ribreux'
__date__ = 'January 2016'
__copyright__ = '(C) 2016, Médéric Ribreux'
__date__ = 'December 2017'
__copyright__ = '(C) 2017, Médéric Ribreux'

# This will get replaced with a git SHA1 when you do a git archive

Expand All @@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
def processOutputs(alg, parameters, context):
# We need to add the initial vector layer to outputs:
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
grassName = '{}{}'.format('map', alg.uniqueSuffix)
grassName = alg.exportedLayers['map']
dataType = 'auto'
alg.exportVectorLayer(grassName, fileName, dataType)
39 changes: 0 additions & 39 deletions python/plugins/processing/algs/grass7/ext/v_what_rast_centroids.py

This file was deleted.

0 comments on commit 36311ff

Please sign in to comment.