QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
38 if ( !input.isValid() )
41 if ( input.type() != QVariant::List )
44 const QVariantList inputList = input.toList();
45 for (
const QVariant &inputItem : inputList )
47 if ( inputItem.type() != QVariant::Map )
49 QVariantMap inputItemMap = inputItem.toMap();
52 if ( !inputItemMap.contains(
"layer" ) )
55 QVariant inputItemLayer = inputItemMap[
"layer"];
57 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( inputItemLayer ) ) )
73 const QList<QgsVectorTileWriter::Layer> layers =
parameterAsLayers( value, context );
76 QStringList layerDefParts;
78 if ( !layer.filterExpression().isEmpty() )
80 if ( !layer.layerName().isEmpty() )
82 if ( layer.minZoom() >= 0 )
84 if ( layer.maxZoom() >= 0 )
87 QString layerDef = QStringLiteral(
"{ %1 }" ).arg( layerDefParts.join(
',' ) );
90 return parts.join(
',' ).prepend(
'[' ).append(
']' );
99 QString code = QStringLiteral(
"QgsProcessingParameterVectorTileWriterLayers('%1', '%2')" ).arg(
name(),
description() );
108 QList<QgsVectorTileWriter::Layer> layers;
109 const QVariantList layersVariantList = layersVariant.toList();
110 for (
const QVariant &layerItem : layersVariantList )
112 QVariantMap layerVariantMap = layerItem.toMap();
120 QVariant layerVariant = layerVariantMap[
"layer"];
123 if ( ( inputLayer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( layerVariant ) ) ) )
137 if ( layerVariantMap.contains(
"filterExpression" ) )
139 if ( layerVariantMap.contains(
"minZoom" ) )
140 writerLayer.
setMinZoom( layerVariantMap[
"minZoom"].toInt() );
141 if ( layerVariantMap.contains(
"maxZoom" ) )
142 writerLayer.
setMaxZoom( layerVariantMap[
"maxZoom"].toInt() );
143 if ( layerVariantMap.contains(
"layerName" ) )
144 writerLayer.
setLayerName( layerVariantMap[
"layerName"].toString() );
152 if ( !layer.
layer() )
155 vm[
"layer"] = layer.
layer()->
id();
156 vm[
"minZoom"] = layer.
minZoom();
157 vm[
"maxZoom"] = layer.
maxZoom();
int minZoom() const
Returns minimum zoom level at which this layer will be used. Negative value means no min....
QString type() const override
Unique parameter type name.
QString description() const
Returns the description for the parameter.
void setLayerName(const QString &name)
Sets layer name in the output. If not set, layer()->name() will be used.
void setMinZoom(int minzoom)
Sets minimum zoom level at which this layer will be used. Negative value means no min....
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QVariantMap layerAsVariantMap(const QgsVectorTileWriter::Layer &layer)
Converts a single input layer to QVariant representation (a QVariantMap)
Base class for the definition of processing parameters.
void setMaxZoom(int maxzoom)
Sets maximum zoom level at which this layer will be used. Negative value means no max....
QString filterExpression() const
Returns filter expression. If not empty, only features matching the expression will be used.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
void setFilterExpression(const QString &expr)
Sets filter expression. If not empty, only features matching the expression will be used.
int maxZoom() const
Returns maximum zoom level at which this layer will be used. Negative value means no max....
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Flags mFlags
Parameter flags.
Contains information about the context in which a processing algorithm is executed.
QString name() const
Returns the name of the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
static QList< QgsVectorTileWriter::Layer > parameterAsLayers(const QVariant &layersVariant, QgsProcessingContext &context)
Converts a QVariant value (a QVariantList) to a list of input layers.
static QString typeName()
Returns the type name for the parameter class.
QgsVectorLayer * layer() const
Returns vector layer of this entry.
QgsProcessingParameterVectorTileWriterLayers(const QString &name, const QString &description=QString())
Constructor for QgsProcessingParameterVectorTileWriterLayers.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsVectorTileWriter::Layer variantMapAsLayer(const QVariantMap &layerVariantMap, QgsProcessingContext &context)
Converts a QVariant value (a QVariantMap) to a single input layer.
Represents a vector layer which manages a vector based data sets.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
Configuration of a single input vector layer to be included in the output.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
@ FlagOptional
Parameter is optional.
PythonOutputType
Available Python output types.
QString layerName() const
Returns layer name in the output. If not set, layer()->name() will be used.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.