Skip to content

Commit 36311ff

Browse files
author
Médéric RIBREUX
committedDec 27, 2017
Fix multiple enum parameters handling and some ext scripts
1 parent 3fa9e3c commit 36311ff

File tree

7 files changed

+15
-56
lines changed

7 files changed

+15
-56
lines changed
 

‎python/plugins/processing/algs/grass7/Grass7Algorithm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,12 @@ def processCommand(self, parameters, context, delOutputs=False):
524524
command += ' {}'.format(paramName)
525525
# For enumeration, we need to grab the string value
526526
elif isinstance(param, QgsProcessingParameterEnum):
527-
idx = self.parameterAsEnum(parameters, paramName, context)
528-
value = '"{}"'.format(param.options()[idx])
527+
# Handle multiple values
528+
if param.allowMultiple():
529+
indexes = self.parameterAsEnums(parameters, paramName, context)
530+
else:
531+
indexes = [self.parameterAsEnum(parameters, paramName, context)]
532+
value = '"{}"'.format(','.join([param.options()[i] for i in indexes]))
529533
# For strings, we just translate as string
530534
elif isinstance(param, QgsProcessingParameterString):
531535
data = self.parameterAsString(parameters, paramName, context)

‎python/plugins/processing/algs/grass7/TODO.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ QGIS3 Processing Port
1414
* r_mask_vect.py
1515
* r_mask_rast.py
1616
* r_statistics.py
17-
* v_voronoi.py
18-
* v_to_3d.py.
19-
* v_what_rast_points.py.
20-
* v_what_rast_centroids.py.
21-
* v_vect_stats.py
22-
* v_rast_stats.py
2317
* v_net.py
2418
* v_net_alloc.py
2519
* v_net_allpairs.py

‎python/plugins/processing/algs/grass7/ext/v_rast_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
3434
def processOutputs(alg, parameters, context):
3535
# We need to add the initial vector layer to outputs:
3636
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
37-
grassName = '{}{}'.format('map', alg.uniqueSuffix)
37+
grassName = alg.exportedLayers['map']
3838
dataType = 'auto'
3939
alg.exportVectorLayer(grassName, fileName, dataType)

‎python/plugins/processing/algs/grass7/ext/v_to_3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ def processInputs(alg, parameters, context):
4040
if 'input' in alg.exportedLayers:
4141
return
4242

43-
# We need to import all the bands and color tables of the input raster
43+
# We need to import the vector layer with v.in.ogr
4444
alg.loadVectorLayerFromParameter('input', parameters, context, False)
4545
alg.postInputs()

‎python/plugins/processing/algs/grass7/ext/v_vect_stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
3434
def processOutputs(alg, parameters, context):
3535
# We need to add the initial vector layer to outputs:
3636
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
37-
grassName = '{}{}'.format('map', alg.uniqueSuffix)
37+
grassName = alg.exportedLayers['areas']
3838
dataType = 'auto'
3939
alg.exportVectorLayer(grassName, fileName, dataType)

‎python/plugins/processing/algs/grass7/ext/v_what_rast_points.py renamed to ‎python/plugins/processing/algs/grass7/ext/v_what_rast.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
"""
44
***************************************************************************
5-
v_what_rast_points.py
5+
v_what_rast.py
66
---------------------
7-
Date : January 2016
8-
Copyright : (C) 2016 by Médéric Ribreux
7+
Date : December 2017
8+
Copyright : (C) 2017 by Médéric Ribreux
99
Email : medspx at medspx dot fr
1010
***************************************************************************
1111
* *
@@ -18,8 +18,8 @@
1818
"""
1919

2020
__author__ = 'Médéric Ribreux'
21-
__date__ = 'January 2016'
22-
__copyright__ = '(C) 2016, Médéric Ribreux'
21+
__date__ = 'December 2017'
22+
__copyright__ = '(C) 2017, Médéric Ribreux'
2323

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

@@ -34,6 +34,6 @@ def processCommand(alg, parameters, context):
3434
def processOutputs(alg, parameters, context):
3535
# We need to add the initial vector layer to outputs:
3636
fileName = alg.parameterAsOutputLayer(parameters, 'output', context)
37-
grassName = '{}{}'.format('map', alg.uniqueSuffix)
37+
grassName = alg.exportedLayers['map']
3838
dataType = 'auto'
3939
alg.exportVectorLayer(grassName, fileName, dataType)

‎python/plugins/processing/algs/grass7/ext/v_what_rast_centroids.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.