Skip to content

Commit

Permalink
[processing][grass] Allow use of feature sources as vector inputs
Browse files Browse the repository at this point in the history
(cherry-picked from 92634a9)
  • Loading branch information
nyalldawson committed Apr 9, 2018
1 parent 865968d commit 5bb4b3e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/plugins/processing/algs/grass7/Grass7Algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
QgsProcessingParameterField,
QgsProcessingParameterPoint,
QgsProcessingParameterBoolean,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterMultipleLayers,
Expand Down Expand Up @@ -213,7 +214,7 @@ def defineCharacteristicsFromFile(self):
parameter = getParameterFromString(line)
if parameter is not None:
self.params.append(parameter)
if isinstance(parameter, QgsProcessingParameterVectorLayer):
if isinstance(parameter, (QgsProcessingParameterVectorLayer, QgsProcessingParameterFeatureSource)):
hasVectorInput = True
elif isinstance(parameter, QgsProcessingParameterRasterLayer):
hasRasterInput = True
Expand Down Expand Up @@ -404,6 +405,7 @@ def processInputs(self, parameters, context, feedback):
"""Prepare the GRASS import commands"""
inputs = [p for p in self.parameterDefinitions()
if isinstance(p, (QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterMultipleLayers))]
for param in inputs:
Expand All @@ -422,7 +424,7 @@ def processInputs(self, parameters, context, feedback):
self.loadRasterLayerFromParameter(
paramName, parameters, context)
# Vector inputs needs to be imported into temp GRASS DB
elif isinstance(param, QgsProcessingParameterVectorLayer):
elif isinstance(param, (QgsProcessingParameterFeatureSource, QgsProcessingParameterVectorLayer)):
if paramName not in self.exportedLayers:
# Attribute tables are also vector inputs
if QgsProcessing.TypeFile in param.dataTypes():
Expand Down Expand Up @@ -505,7 +507,8 @@ def processCommand(self, parameters, context, feedback, delOutputs=False):

# Raster and vector layers
if isinstance(param, (QgsProcessingParameterRasterLayer,
QgsProcessingParameterVectorLayer)):
QgsProcessingParameterVectorLayer,
QgsProcessingParameterFeatureSource)):
if paramName in self.exportedLayers:
value = self.exportedLayers[paramName]
else:
Expand Down

0 comments on commit 5bb4b3e

Please sign in to comment.