QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
QgsMapBoxGlStyleConverter Class Reference

Handles conversion of MapBox GL styles to QGIS vector tile renderers and labeling settings. More...

#include <qgsmapboxglstyleconverter.h>

Public Types

enum class  PropertyType {
  Color , Numeric , Opacity , Point ,
  NumericArray
}
 Property types, for interpolated value conversion. More...
 
enum  Result { Success = 0 , NoLayerList = 1 }
 Result of conversion. More...
 

Public Member Functions

 QgsMapBoxGlStyleConverter ()
 Constructor for QgsMapBoxGlStyleConverter.
 
 QgsMapBoxGlStyleConverter (const QgsMapBoxGlStyleConverter &other)=delete
 
 ~QgsMapBoxGlStyleConverter ()
 
Result convert (const QString &style, QgsMapBoxGlStyleConversionContext *context=nullptr)
 Converts a JSON style string, and returns the resultant status of the conversion.
 
Result convert (const QVariantMap &style, QgsMapBoxGlStyleConversionContext *context=nullptr)
 Converts a JSON style map, and returns the resultant status of the conversion.
 
QList< QgsMapLayer * > createSubLayers () const
 Returns a list of new map layers corresponding to sublayers of the style, e.g.
 
QString errorMessage () const
 Returns a descriptive error message if an error was encountered during the style conversion, or an empty string if no error was encountered.
 
QgsVectorTileLabelinglabeling () const
 Returns a new instance of a vector tile labeling representing the converted style, or nullptr if the style could not be converted successfully.
 
QgsMapBoxGlStyleConverteroperator= (const QgsMapBoxGlStyleConverter &other)=delete
 
QList< QgsMapBoxGlStyleRasterSubLayerrasterSubLayers () const
 Returns a list of raster sub layers contained in the style.
 
QgsVectorTileRendererrenderer () const
 Returns a new instance of a vector tile renderer representing the converted style, or nullptr if the style could not be converted successfully.
 
QList< QgsMapBoxGlStyleAbstractSource * > sources ()
 Returns the list of converted sources.
 
QStringList warnings () const
 Returns a list of user-friendly warnings generated during the conversion, e.g.
 

Protected Member Functions

void parseLayers (const QVariantList &layers, QgsMapBoxGlStyleConversionContext *context=nullptr)
 Parse list of layers from JSON.
 
void parseRasterSource (const QVariantMap &source, const QString &name, QgsMapBoxGlStyleConversionContext *context=nullptr)
 Parse a raster source from JSON.
 
void parseSources (const QVariantMap &sources, QgsMapBoxGlStyleConversionContext *context=nullptr)
 Parse list of sources from JSON.
 

Static Protected Member Functions

static void colorAsHslaComponents (const QColor &color, int &hue, int &saturation, int &lightness, int &alpha)
 Takes a QColor object and returns HSLA components in required format for QGIS color_hsla() expression function.
 
static QString interpolateExpression (double zoomMin, double zoomMax, QVariant valueMin, QVariant valueMax, double base, double multiplier=1, QgsMapBoxGlStyleConversionContext *contextPtr=0)
 Generates an interpolation for values between valueMin and valueMax, scaled between the ranges zoomMin to zoomMax.
 
static QString parseArrayStops (const QVariantList &stops, QgsMapBoxGlStyleConversionContext &context, double multiplier=1)
 Takes numerical arrays from stops.
 
static Qt::PenCapStyle parseCapStyle (const QString &style)
 Converts a value to Qt::PenCapStyle enum from JSON value.
 
static bool parseCircleLayer (const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context)
 Parses a circle layer.
 
static QColor parseColor (const QVariant &color, QgsMapBoxGlStyleConversionContext &context)
 Parses a color in one of these supported formats:
 
static QString parseColorExpression (const QVariant &colorExpression, QgsMapBoxGlStyleConversionContext &context)
 Converts an expression representing a color to a string (can be color string or an expression where a color is expected)
 
static QString parseExpression (const QVariantList &expression, QgsMapBoxGlStyleConversionContext &context, bool colorExpected=false)
 Converts a MapBox GL expression to a QGIS expression.
 
static bool parseFillLayer (const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context, bool isBackgroundStyle=false)
 Parses a fill layer.
 
static QgsProperty parseInterpolateByZoom (const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, double *defaultNumber=nullptr)
 Parses a numeric value which is interpolated by zoom range.
 
static QgsProperty parseInterpolateColorByZoom (const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, QColor *defaultColor=nullptr)
 Parses a color value which is interpolated by zoom range.
 
static QgsProperty parseInterpolateListByZoom (const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, int maxOpacity=255, QColor *defaultColor=nullptr, double *defaultNumber=nullptr)
 Interpolates a list which starts with the interpolate function.
 
static QgsProperty parseInterpolateOpacityByZoom (const QVariantMap &json, int maxOpacity, QgsMapBoxGlStyleConversionContext *contextPtr=0)
 Interpolates opacity with either scale_linear() or scale_exp() (depending on base value).
 
static QgsProperty parseInterpolatePointByZoom (const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, QPointF *defaultPoint=nullptr)
 Interpolates a point/offset with either scale_linear() or scale_exp() (depending on base value).
 
static QgsProperty parseInterpolateStringByZoom (const QVariantMap &json, QgsMapBoxGlStyleConversionContext &context, const QVariantMap &conversionMap, QString *defaultString=nullptr)
 Interpolates a string by zoom.
 
static Qt::PenJoinStyle parseJoinStyle (const QString &style)
 Converts a value to Qt::PenJoinStyle enum from JSON value.
 
static QString parseLabelStops (const QVariantList &stops, QgsMapBoxGlStyleConversionContext &context)
 Parses a list of interpolation stops containing label values.
 
static bool parseLineLayer (const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &style, QgsMapBoxGlStyleConversionContext &context)
 Parses a line layer.
 
static QgsProperty parseMatchList (const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, int maxOpacity=255, QColor *defaultColor=nullptr, double *defaultNumber=nullptr)
 Parses and converts a match function value list.
 
static QString parseOpacityStops (double base, const QVariantList &stops, int maxOpacity, QgsMapBoxGlStyleConversionContext &context)
 Takes values from stops and uses either scale_linear() or scale_exp() functions to interpolate alpha component of color.
 
static QString parsePointStops (double base, const QVariantList &stops, QgsMapBoxGlStyleConversionContext &context, double multiplier=1)
 Takes values from stops and uses either scale_linear() or scale_exp() functions to interpolate point/offset values.
 
static QgsProperty parseStepList (const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, int maxOpacity=255, QColor *defaultColor=nullptr, double *defaultNumber=nullptr)
 Parses and converts a match function value list.
 
static QString parseStops (double base, const QVariantList &stops, double multiplier, QgsMapBoxGlStyleConversionContext &context)
 Parses a list of interpolation stops.
 
static QString parseStringStops (const QVariantList &stops, QgsMapBoxGlStyleConversionContext &context, const QVariantMap &conversionMap, QString *defaultString=nullptr)
 Parses a list of interpolation stops containing string values.
 
static void parseSymbolLayer (const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &rendererStyle, bool &hasRenderer, QgsVectorTileBasicLabelingStyle &labelingStyle, bool &hasLabeling, QgsMapBoxGlStyleConversionContext &context)
 Parses a symbol layer as renderer or labeling.
 
static bool parseSymbolLayerAsRenderer (const QVariantMap &jsonLayer, QgsVectorTileBasicRendererStyle &rendererStyle, QgsMapBoxGlStyleConversionContext &context)
 Parses a symbol layer as a renderer.
 
static QgsProperty parseValueList (const QVariantList &json, PropertyType type, QgsMapBoxGlStyleConversionContext &context, double multiplier=1, int maxOpacity=255, QColor *defaultColor=nullptr, double *defaultNumber=nullptr)
 Parses and converts a value list (e.g.
 
static QImage retrieveSprite (const QString &name, QgsMapBoxGlStyleConversionContext &context, QSize &spriteSize)
 Retrieves the sprite image with the specified name, taken from the specified context.
 
static QString retrieveSpriteAsBase64 (const QVariant &value, QgsMapBoxGlStyleConversionContext &context)
 Retrieves the sprite image with the specified name, taken from the specified context as a base64 encoded value.
 
static QString retrieveSpriteAsBase64WithProperties (const QVariant &value, QgsMapBoxGlStyleConversionContext &context, QSize &spriteSize, QString &spriteProperty, QString &spriteSizeProperty)
 Retrieves the sprite image with the specified name, taken from the specified context as a base64 encoded value.
 

Detailed Description

Handles conversion of MapBox GL styles to QGIS vector tile renderers and labeling settings.

Conversions are performed by calling convert() with either a JSON map or JSON string value, and then retrieving the results by calling renderer() or labeling() respectively.

Since
QGIS 3.16

Definition at line 341 of file qgsmapboxglstyleconverter.h.

Member Enumeration Documentation

◆ PropertyType

Property types, for interpolated value conversion.

Warning
This is private API only, and may change in future QGIS versions
Enumerator
Color 

Color property.

Numeric 

Numeric property (e.g. line width, text size)

Opacity 

Opacity property.

Point 

Point/offset property.

NumericArray 

Numeric array for dash arrays or such.

Definition at line 368 of file qgsmapboxglstyleconverter.h.

◆ Result

Result of conversion.

Enumerator
Success 

Conversion was successful.

NoLayerList 

No layer list was found in JSON input.

Definition at line 358 of file qgsmapboxglstyleconverter.h.

Constructor & Destructor Documentation

◆ QgsMapBoxGlStyleConverter() [1/2]

QgsMapBoxGlStyleConverter::QgsMapBoxGlStyleConverter ( )

Constructor for QgsMapBoxGlStyleConverter.

Definition at line 50 of file qgsmapboxglstyleconverter.cpp.

◆ QgsMapBoxGlStyleConverter() [2/2]

QgsMapBoxGlStyleConverter::QgsMapBoxGlStyleConverter ( const QgsMapBoxGlStyleConverter other)
delete

◆ ~QgsMapBoxGlStyleConverter()

QgsMapBoxGlStyleConverter::~QgsMapBoxGlStyleConverter ( )

Definition at line 81 of file qgsmapboxglstyleconverter.cpp.

Member Function Documentation

◆ colorAsHslaComponents()

void QgsMapBoxGlStyleConverter::colorAsHslaComponents ( const QColor &  color,
int &  hue,
int &  saturation,
int &  lightness,
int &  alpha 
)
staticprotected

Takes a QColor object and returns HSLA components in required format for QGIS color_hsla() expression function.

Parameters
colorinput color
huean integer value from 0 to 360
saturationan integer value from 0 to 100
lightnessan integer value from 0 to 100
alphaan integer value from 0 (completely transparent) to 255 (opaque).
Warning
This is private API only, and may change in future QGIS versions

Definition at line 3174 of file qgsmapboxglstyleconverter.cpp.

◆ convert() [1/2]

QgsMapBoxGlStyleConverter::Result QgsMapBoxGlStyleConverter::convert ( const QString &  style,
QgsMapBoxGlStyleConversionContext context = nullptr 
)

Converts a JSON style string, and returns the resultant status of the conversion.

If an error occurs during conversion then a descriptive error message can be retrieved by calling errorMessage().

After conversion, the resultant labeling and style rules can be retrieved by calling renderer() or labeling() respectively.

The optional context argument can be set to use a specific context during the conversion.

Definition at line 76 of file qgsmapboxglstyleconverter.cpp.

◆ convert() [2/2]

QgsMapBoxGlStyleConverter::Result QgsMapBoxGlStyleConverter::convert ( const QVariantMap &  style,
QgsMapBoxGlStyleConversionContext context = nullptr 
)

Converts a JSON style map, and returns the resultant status of the conversion.

If an error occurs during conversion then a descriptive error message can be retrieved by calling errorMessage().

After conversion, the resultant labeling and style rules can be retrieved by calling renderer() or labeling() respectively.

The optional context argument can be set to use a specific context during the conversion.

Definition at line 54 of file qgsmapboxglstyleconverter.cpp.

◆ createSubLayers()

QList< QgsMapLayer * > QgsMapBoxGlStyleConverter::createSubLayers ( ) const

Returns a list of new map layers corresponding to sublayers of the style, e.g.

raster layers.

The caller takes ownership of the returned layers.

Since
QGIS 3.28

Definition at line 3936 of file qgsmapboxglstyleconverter.cpp.

◆ errorMessage()

QString QgsMapBoxGlStyleConverter::errorMessage ( ) const
inline

Returns a descriptive error message if an error was encountered during the style conversion, or an empty string if no error was encountered.

See also
warnings()

Definition at line 410 of file qgsmapboxglstyleconverter.h.

◆ interpolateExpression()

QString QgsMapBoxGlStyleConverter::interpolateExpression ( double  zoomMin,
double  zoomMax,
QVariant  valueMin,
QVariant  valueMax,
double  base,
double  multiplier = 1,
QgsMapBoxGlStyleConversionContext contextPtr = 0 
)
staticprotected

Generates an interpolation for values between valueMin and valueMax, scaled between the ranges zoomMin to zoomMax.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3182 of file qgsmapboxglstyleconverter.cpp.

◆ labeling()

QgsVectorTileLabeling * QgsMapBoxGlStyleConverter::labeling ( ) const

Returns a new instance of a vector tile labeling representing the converted style, or nullptr if the style could not be converted successfully.

Definition at line 3921 of file qgsmapboxglstyleconverter.cpp.

◆ operator=()

QgsMapBoxGlStyleConverter & QgsMapBoxGlStyleConverter::operator= ( const QgsMapBoxGlStyleConverter other)
delete

◆ parseArrayStops()

QString QgsMapBoxGlStyleConverter::parseArrayStops ( const QVariantList &  stops,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1 
)
staticprotected

Takes numerical arrays from stops.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2631 of file qgsmapboxglstyleconverter.cpp.

◆ parseCapStyle()

Qt::PenCapStyle QgsMapBoxGlStyleConverter::parseCapStyle ( const QString &  style)
staticprotected

Converts a value to Qt::PenCapStyle enum from JSON value.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3237 of file qgsmapboxglstyleconverter.cpp.

◆ parseCircleLayer()

bool QgsMapBoxGlStyleConverter::parseCircleLayer ( const QVariantMap &  jsonLayer,
QgsVectorTileBasicRendererStyle style,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a circle layer.

Warning
This is private API only, and may change in future QGIS versions
Parameters
jsonLayercircle layer to parse
stylegenerated QGIS vector tile style
contextconversion context
Returns
true if the layer was successfully parsed.

Definition at line 857 of file qgsmapboxglstyleconverter.cpp.

◆ parseColor()

QColor QgsMapBoxGlStyleConverter::parseColor ( const QVariant &  color,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a color in one of these supported formats:

  • #fff or #ffffff
  • hsl(30, 19%, 90%) or hsla(30, 19%, 90%, 0.4)
  • rgb(10, 20, 30) or rgba(10, 20, 30, 0.5)

Returns an invalid color if the color could not be parsed.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3163 of file qgsmapboxglstyleconverter.cpp.

◆ parseColorExpression()

QString QgsMapBoxGlStyleConverter::parseColorExpression ( const QVariant &  colorExpression,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Converts an expression representing a color to a string (can be color string or an expression where a color is expected)

Parameters
colorExpressionthe color expression
contextthe style conversion context
Returns
the QGIS expression string
Since
QGIS 3.22

Definition at line 3154 of file qgsmapboxglstyleconverter.cpp.

◆ parseExpression()

QString QgsMapBoxGlStyleConverter::parseExpression ( const QVariantList &  expression,
QgsMapBoxGlStyleConversionContext context,
bool  colorExpected = false 
)
staticprotected

Converts a MapBox GL expression to a QGIS expression.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3257 of file qgsmapboxglstyleconverter.cpp.

◆ parseFillLayer()

bool QgsMapBoxGlStyleConverter::parseFillLayer ( const QVariantMap &  jsonLayer,
QgsVectorTileBasicRendererStyle style,
QgsMapBoxGlStyleConversionContext context,
bool  isBackgroundStyle = false 
)
staticprotected

Parses a fill layer.

Warning
This is private API only, and may change in future QGIS versions
Parameters
jsonLayerfill layer to parse
stylegenerated QGIS vector tile style
contextconversion context
isBackgroundStyleset to true if the layer should be parsed as background layer
Returns
true if the layer was successfully parsed.

Definition at line 226 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolateByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateByZoom ( const QVariantMap &  json,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
double *  defaultNumber = nullptr 
)
staticprotected

Parses a numeric value which is interpolated by zoom range.

Parameters
jsondefinition of interpolation
contextconversion context
multiplieroptional multiplication factor
defaultNumberoptional storage for a reasonable "default" number representing the overall property.
Returns
QgsProperty representing interpolation settings

Definition at line 2452 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolateColorByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateColorByZoom ( const QVariantMap &  json,
QgsMapBoxGlStyleConversionContext context,
QColor *  defaultColor = nullptr 
)
staticprotected

Parses a color value which is interpolated by zoom range.

Parameters
jsondefinition of color interpolation
contextconversion context
defaultColoroptional storage for a reasonable "default" color representing the overall property.
Returns
QgsProperty representing interpolation settings

Definition at line 2352 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolateListByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateListByZoom ( const QVariantList &  json,
PropertyType  type,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
int  maxOpacity = 255,
QColor *  defaultColor = nullptr,
double *  defaultNumber = nullptr 
)
staticprotected

Interpolates a list which starts with the interpolate function.

Warning
This is private API only, and may change in future QGIS versions
Since
QGIS 3.40

Definition at line 3091 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolateOpacityByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateOpacityByZoom ( const QVariantMap &  json,
int  maxOpacity,
QgsMapBoxGlStyleConversionContext contextPtr = 0 
)
staticprotected

Interpolates opacity with either scale_linear() or scale_exp() (depending on base value).

For json with intermediate stops it uses parseOpacityStops() function. It uses QGIS set_color_part() function to set alpha component of color.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2480 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolatePointByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolatePointByZoom ( const QVariantMap &  json,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
QPointF *  defaultPoint = nullptr 
)
staticprotected

Interpolates a point/offset with either scale_linear() or scale_exp() (depending on base value).

For json with intermediate stops it uses parsePointStops() function.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2553 of file qgsmapboxglstyleconverter.cpp.

◆ parseInterpolateStringByZoom()

QgsProperty QgsMapBoxGlStyleConverter::parseInterpolateStringByZoom ( const QVariantMap &  json,
QgsMapBoxGlStyleConversionContext context,
const QVariantMap &  conversionMap,
QString *  defaultString = nullptr 
)
staticprotected

Interpolates a string by zoom.

For json with intermediate stops it uses parseStringStops() function.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2585 of file qgsmapboxglstyleconverter.cpp.

◆ parseJoinStyle()

Qt::PenJoinStyle QgsMapBoxGlStyleConverter::parseJoinStyle ( const QString &  style)
staticprotected

Converts a value to Qt::PenJoinStyle enum from JSON value.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3247 of file qgsmapboxglstyleconverter.cpp.

◆ parseLabelStops()

QString QgsMapBoxGlStyleConverter::parseLabelStops ( const QVariantList &  stops,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a list of interpolation stops containing label values.

Parameters
stopsdefinition of interpolation stops
contextconversion context
Returns
converted expression

Definition at line 2759 of file qgsmapboxglstyleconverter.cpp.

◆ parseLayers()

void QgsMapBoxGlStyleConverter::parseLayers ( const QVariantList &  layers,
QgsMapBoxGlStyleConversionContext context = nullptr 
)
protected

Parse list of layers from JSON.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 86 of file qgsmapboxglstyleconverter.cpp.

◆ parseLineLayer()

bool QgsMapBoxGlStyleConverter::parseLineLayer ( const QVariantMap &  jsonLayer,
QgsVectorTileBasicRendererStyle style,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a line layer.

Warning
This is private API only, and may change in future QGIS versions
Parameters
jsonLayerline layer to parse
stylegenerated QGIS vector tile style
contextconversion context
Returns
true if the layer was successfully parsed.

Definition at line 478 of file qgsmapboxglstyleconverter.cpp.

◆ parseMatchList()

QgsProperty QgsMapBoxGlStyleConverter::parseMatchList ( const QVariantList &  json,
QgsMapBoxGlStyleConverter::PropertyType  type,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
int  maxOpacity = 255,
QColor *  defaultColor = nullptr,
double *  defaultNumber = nullptr 
)
staticprotected

Parses and converts a match function value list.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2844 of file qgsmapboxglstyleconverter.cpp.

◆ parseOpacityStops()

QString QgsMapBoxGlStyleConverter::parseOpacityStops ( double  base,
const QVariantList &  stops,
int  maxOpacity,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Takes values from stops and uses either scale_linear() or scale_exp() functions to interpolate alpha component of color.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2514 of file qgsmapboxglstyleconverter.cpp.

◆ parsePointStops()

QString QgsMapBoxGlStyleConverter::parsePointStops ( double  base,
const QVariantList &  stops,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1 
)
staticprotected

Takes values from stops and uses either scale_linear() or scale_exp() functions to interpolate point/offset values.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2597 of file qgsmapboxglstyleconverter.cpp.

◆ parseRasterSource()

void QgsMapBoxGlStyleConverter::parseRasterSource ( const QVariantMap &  source,
const QString &  name,
QgsMapBoxGlStyleConversionContext context = nullptr 
)
protected

Parse a raster source from JSON.

Warning
This is private API only, and may change in future QGIS versions
Since
QGIS 3.28

Definition at line 4015 of file qgsmapboxglstyleconverter.cpp.

◆ parseSources()

void QgsMapBoxGlStyleConverter::parseSources ( const QVariantMap &  sources,
QgsMapBoxGlStyleConversionContext context = nullptr 
)
protected

Parse list of sources from JSON.

Warning
This is private API only, and may change in future QGIS versions
Since
QGIS 3.28

Definition at line 3963 of file qgsmapboxglstyleconverter.cpp.

◆ parseStepList()

QgsProperty QgsMapBoxGlStyleConverter::parseStepList ( const QVariantList &  json,
PropertyType  type,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
int  maxOpacity = 255,
QColor *  defaultColor = nullptr,
double *  defaultNumber = nullptr 
)
staticprotected

Parses and converts a match function value list.

Warning
This is private API only, and may change in future QGIS versions

Definition at line 3006 of file qgsmapboxglstyleconverter.cpp.

◆ parseStops()

QString QgsMapBoxGlStyleConverter::parseStops ( double  base,
const QVariantList &  stops,
double  multiplier,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a list of interpolation stops.

Parameters
baseinterpolation exponent base
stopsdefinition of interpolation stops
multiplieroptional multiplication factor
contextconversion context

Definition at line 2673 of file qgsmapboxglstyleconverter.cpp.

◆ parseStringStops()

QString QgsMapBoxGlStyleConverter::parseStringStops ( const QVariantList &  stops,
QgsMapBoxGlStyleConversionContext context,
const QVariantMap &  conversionMap,
QString *  defaultString = nullptr 
)
staticprotected

Parses a list of interpolation stops containing string values.

Parameters
stopsdefinition of interpolation stops
contextconversion context
conversionMapmap of input string to output expression value
defaultStringreasonable default value taken from stops
Returns
converted expression

Definition at line 2724 of file qgsmapboxglstyleconverter.cpp.

◆ parseSymbolLayer()

void QgsMapBoxGlStyleConverter::parseSymbolLayer ( const QVariantMap &  jsonLayer,
QgsVectorTileBasicRendererStyle rendererStyle,
bool &  hasRenderer,
QgsVectorTileBasicLabelingStyle labelingStyle,
bool &  hasLabeling,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a symbol layer as renderer or labeling.

Warning
This is private API only, and may change in future QGIS versions
Parameters
jsonLayersymbol layer to parse
rendererStylegenerated QGIS vector tile style
hasRendererwill be set to true if symbol layer generated a renderer style
labelingStylegenerated QGIS vector tile labeling
hasLabelingwill be set to true if symbol layer generated a labeling style
contextconversion context

Definition at line 1107 of file qgsmapboxglstyleconverter.cpp.

◆ parseSymbolLayerAsRenderer()

bool QgsMapBoxGlStyleConverter::parseSymbolLayerAsRenderer ( const QVariantMap &  jsonLayer,
QgsVectorTileBasicRendererStyle rendererStyle,
QgsMapBoxGlStyleConversionContext context 
)
staticprotected

Parses a symbol layer as a renderer.

Warning
This is private API only, and may change in future QGIS versions
Parameters
jsonLayerfill layer to parse
rendererStylegenerated QGIS vector tile style
contextconversion context
Returns
true if symbol layer was converted to renderer

Definition at line 2039 of file qgsmapboxglstyleconverter.cpp.

◆ parseValueList()

QgsProperty QgsMapBoxGlStyleConverter::parseValueList ( const QVariantList &  json,
QgsMapBoxGlStyleConverter::PropertyType  type,
QgsMapBoxGlStyleConversionContext context,
double  multiplier = 1,
int  maxOpacity = 255,
QColor *  defaultColor = nullptr,
double *  defaultNumber = nullptr 
)
staticprotected

Parses and converts a value list (e.g.

an interpolate list).

Warning
This is private API only, and may change in future QGIS versions

Definition at line 2823 of file qgsmapboxglstyleconverter.cpp.

◆ rasterSubLayers()

QList< QgsMapBoxGlStyleRasterSubLayer > QgsMapBoxGlStyleConverter::rasterSubLayers ( ) const

Returns a list of raster sub layers contained in the style.

Since
QGIS 3.28

Definition at line 3931 of file qgsmapboxglstyleconverter.cpp.

◆ renderer()

QgsVectorTileRenderer * QgsMapBoxGlStyleConverter::renderer ( ) const

Returns a new instance of a vector tile renderer representing the converted style, or nullptr if the style could not be converted successfully.

Definition at line 3916 of file qgsmapboxglstyleconverter.cpp.

◆ retrieveSprite()

QImage QgsMapBoxGlStyleConverter::retrieveSprite ( const QString &  name,
QgsMapBoxGlStyleConversionContext context,
QSize &  spriteSize 
)
staticprotected

Retrieves the sprite image with the specified name, taken from the specified context.

The context must have valid sprite definitions and images set via QgsMapBoxGlStyleConversionContext::setSprites() prior to conversion.

Definition at line 3501 of file qgsmapboxglstyleconverter.cpp.

◆ retrieveSpriteAsBase64()

static QString QgsMapBoxGlStyleConverter::retrieveSpriteAsBase64 ( const QVariant &  value,
QgsMapBoxGlStyleConversionContext context 
)
inlinestaticprotected

Retrieves the sprite image with the specified name, taken from the specified context as a base64 encoded value.

The context must have valid sprite definitions and images set via QgsMapBoxGlStyleConversionContext::setSprites() prior to conversion.

Definition at line 768 of file qgsmapboxglstyleconverter.h.

◆ retrieveSpriteAsBase64WithProperties()

QString QgsMapBoxGlStyleConverter::retrieveSpriteAsBase64WithProperties ( const QVariant &  value,
QgsMapBoxGlStyleConversionContext context,
QSize &  spriteSize,
QString &  spriteProperty,
QString &  spriteSizeProperty 
)
staticprotected

Retrieves the sprite image with the specified name, taken from the specified context as a base64 encoded value.

The context must have valid sprite definitions and images set via QgsMapBoxGlStyleConversionContext::setSprites() prior to conversion.

Since
QGIS 3.40

Definition at line 3530 of file qgsmapboxglstyleconverter.cpp.

◆ sources()

QList< QgsMapBoxGlStyleAbstractSource * > QgsMapBoxGlStyleConverter::sources ( )

Returns the list of converted sources.

Since
QGIS 3.28

Definition at line 3926 of file qgsmapboxglstyleconverter.cpp.

◆ warnings()

QStringList QgsMapBoxGlStyleConverter::warnings ( ) const
inline

Returns a list of user-friendly warnings generated during the conversion, e.g.

as a result of MapBox GL style settings which cannot be translated to QGIS styles.

See also
errorMessage()

Definition at line 418 of file qgsmapboxglstyleconverter.h.


The documentation for this class was generated from the following files: