27using namespace Qt::StringLiterals;
41 return QObject::tr(
"MapBox GL Style" );
51 if ( variant.isNull() )
54 QVariantMap jsonLayer;
55 if ( variant.userType() == QMetaType::Type::QVariantMap )
57 jsonLayer = variant.toMap();
59 else if ( variant.canConvert<QString>() )
64 if ( jsonLayer.isEmpty() || !jsonLayer.contains( u
"type"_s ) )
66 context.
pushError( QObject::tr(
"Invalid MapBox GL JSON: Missing 'type' property." ) );
70 const QString layerType = jsonLayer.value( u
"type"_s ).toString();
76 if ( layerType ==
"fill"_L1 )
80 else if ( layerType ==
"line"_L1 )
84 else if ( layerType ==
"circle"_L1 )
88 else if ( layerType ==
"symbol"_L1 )
92 else if ( layerType ==
"background"_L1 )
98 context.
pushError( QObject::tr(
"Unsupported MapBox GL layer type: %1" ).arg( layerType ) );
102 const QStringList warnings = mbContext.
warnings();
103 for (
const QString &warning : warnings )
108 if ( success && style.
symbol() )
110 return std::unique_ptr< QgsSymbol >( style.
symbol()->
clone() );
QFlags< SymbolConverterCapability > SymbolConverterCapabilities
Symbol converter capabilities.
@ ReadSymbol
Allows reading symbols from variants.
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...
Context for a MapBox GL style conversion operation.
QStringList warnings() const
Returns a list of warning messages generated during the conversion.
static bool parseCircleLayer(const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context)
Parses a circle layer.
static bool parseSymbolLayerAsRenderer(const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &rendererStyle, QgsMapBoxGlStyleConversionContext &context)
Parses a symbol layer as a renderer.
static bool parseFillLayer(const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context, bool isBackgroundStyle=false)
Parses a fill layer.
static bool parseLineLayer(const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context)
Parses a line layer.
Custom exception class which is raised when an operation is not supported.
Represents the context in which a QgsSymbolConverter conversion occurs.
void pushWarning(const QString &warning)
Pushes a warning message generated during the conversion.
void pushError(const QString &error)
Pushes a error message generated during the conversion.
QString formatName() const override
Returns a translated, user-friendly name for the converter's data format.
Qgis::SymbolConverterCapabilities capabilities() const override
Returns the capabilities of the converter.
QVariant toVariant(const QgsSymbol *symbol, QgsSymbolConverterContext &context) const override
Converts a symbol into a QVariant representation.
QString name() const override
Returns the unique name for the converter.
std::unique_ptr< QgsSymbol > createSymbol(const QVariant &variant, QgsSymbolConverterContext &context) const override
Creates a new QgsSymbol from a QVariant representation.
Abstract base class for all rendered symbols.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
Definition of map rendering of a subset of vector tile data.
QgsSymbol * symbol() const
Returns symbol for rendering.