Skip to content
Permalink
Browse files

map layer data type support in modeler

  • Loading branch information
alexbruy committed Mar 13, 2020
1 parent 56971a9 commit 70c5018b74702a9827d428708207c98a508fef36
@@ -78,7 +78,7 @@
PARAMETER_MULTIPLE = 'multilayer'
PARAMETER_BAND = 'band'
PARAMETER_LAYOUTITEM = 'layoutitem'
PARAMETER_MAP_LAYER = 'Map Layer'
PARAMETER_MAP_LAYER = 'layer'
PARAMETER_RANGE = 'range'
PARAMETER_ENUM = 'enum'
PARAMETER_MATRIX = 'matrix'
@@ -91,7 +91,8 @@ def use_legacy_dialog(param=None, paramType=None):
parameters.PARAMETER_POINT,
parameters.PARAMETER_CRS,
parameters.PARAMETER_ENUM,
parameters.PARAMETER_MATRIX):
parameters.PARAMETER_MATRIX,
parameters.PARAMETER_MAP_LAYER):
return True
elif isinstance(param, (QgsProcessingParameterField,
QgsProcessingParameterBand,
@@ -106,6 +107,7 @@ def use_legacy_dialog(param=None, paramType=None):
QgsProcessingParameterCrs,
QgsProcessingParameterEnum,
QgsProcessingParameterMatrix,
QgsProcessingParameterMapLayer,
QgsProcessingDestinationParameter)):
return True

@@ -241,6 +243,20 @@ def setupUi(self):
if self.param is not None:
self.datatypeCombo.setCurrentIndex(self.datatypeCombo.findData(self.param.layerType()))
self.verticalLayout.addWidget(self.datatypeCombo)
elif (self.paramType == parameters.PARAMETER_MAP_LAYER or
isinstance(self.param, QgsProcessingParameterMapLayer)):
self.verticalLayout.addWidget(QLabel(self.tr('Data type')))
self.datatypeCombo = QComboBox()
self.datatypeCombo.addItem(self.tr('Any Map Layer'), QgsProcessing.TypeMapLayer)
self.datatypeCombo.addItem(self.tr('Vector (Point)'), QgsProcessing.TypeVectorPoint)
self.datatypeCombo.addItem(self.tr('Vector (Line)'), QgsProcessing.TypeVectorLine)
self.datatypeCombo.addItem(self.tr('Vector (Polygon)'), QgsProcessing.TypeVectorPolygon)
self.datatypeCombo.addItem(self.tr('Vector (Any Geometry Type)'), QgsProcessing.TypeVectorAnyGeometry)
self.datatypeCombo.addItem(self.tr('Raster'), QgsProcessing.TypeRaster)
self.datatypeCombo.addItem(self.tr('Mesh'), QgsProcessing.TypeMesh)
if self.param is not None:
self.datatypeCombo.setCurrentIndex(self.datatypeCombo.findData(self.param.dataTypes()[0]))
self.verticalLayout.addWidget(self.datatypeCombo)
elif (self.paramType in (parameters.PARAMETER_NUMBER, parameters.PARAMETER_DISTANCE, parameters.PARAMETER_SCALE)
or isinstance(self.param, (QgsProcessingParameterNumber, QgsProcessingParameterDistance, QgsProcessingParameterScale))):

@@ -453,7 +469,7 @@ def accept(self):
elif (self.paramType == parameters.PARAMETER_MAP_LAYER
or isinstance(self.param, QgsProcessingParameterMapLayer)):
self.param = QgsProcessingParameterMapLayer(
name, description)
name, description, types=[self.datatypeCombo.currentData()])
elif (self.paramType == parameters.PARAMETER_RASTER
or isinstance(self.param, QgsProcessingParameterRasterLayer)):
self.param = QgsProcessingParameterRasterLayer(

0 comments on commit 70c5018

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