Class: QgsMapBoxGlStyleConversionContext

Context for a MapBox GL style conversion operation.

Warning

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

Added in version 3.16.

Methods

clearWarnings

Clears the list of warning messages.

layerId

Returns the layer ID of the layer currently being converted.

pixelSizeConversionFactor

Returns the pixel size conversion factor, used to scale the original pixel sizes when converting styles.

pushWarning

Pushes a warning message generated during the conversion.

setLayerId

Sets the layer ID of the layer currently being converted.

setPixelSizeConversionFactor

Sets the pixel size conversion factor, used to scale the original pixel sizes when converting styles.

setSprites

Sets the sprite image and definitions JSON for a given category to use during conversion.

setTargetUnit

Sets the target unit type.

spriteCategories

Returns the list of sprite categories to use during conversion, or an empty list of none is set.

spriteDefinitions

Returns the sprite definitions for a given category to use during conversion.

spriteImage

Returns the sprite image for a given category to use during conversion, or an invalid image if this is not set.

targetUnit

Returns the target unit type.

warnings

Returns a list of warning messages generated during the conversion.

class qgis.core.QgsMapBoxGlStyleConversionContext[source]

Bases: object

clearWarnings(self)[source]

Clears the list of warning messages.

layerId(self) str[source]

Returns the layer ID of the layer currently being converted.

See also

setLayerId()

Return type:

str

pixelSizeConversionFactor(self) float[source]

Returns the pixel size conversion factor, used to scale the original pixel sizes when converting styles.

Return type:

float

pushWarning(self, warning: str | None)[source]

Pushes a warning message generated during the conversion.

Parameters:

warning (Optional[str])

setLayerId(self, value: str | None)[source]

Sets the layer ID of the layer currently being converted.

See also

layerId()

Parameters:

value (Optional[str])

setPixelSizeConversionFactor(self, sizeConversionFactor: float)[source]

Sets the pixel size conversion factor, used to scale the original pixel sizes when converting styles.

Parameters:

sizeConversionFactor (float)

setSprites(self, image: QImage, definitions: Dict[str, Any], category: str | None = '')[source]

Sets the sprite image and definitions JSON for a given category to use during conversion.

See also

spriteImage()

Parameters:
  • image (QImage)

  • definitions (Dict[str, Any])

  • category (Optional[str] = '')

setSprites(self, image: QImage, definitions: str | None, category: str | None = '')[source]

Sets the sprite image and definitions JSON string for a given category to use during conversion.

See also

spriteImage()

Parameters:
  • image (QImage)

  • definitions (Optional[str])

  • category (Optional[str] = '')

setTargetUnit(self, targetUnit: Qgis.RenderUnit)[source]

Sets the target unit type.

By default this is QgsUnitTypes.RenderPixels in order to exactly match the original style rendering. But rendering in pixels can cause issues on hidpi displays or with print layouts, so setting a target unit of QgsUnitTypes.Millimeters or another real-world unit type is often more appropriate.

If setting to a non-pixel unit, be sure to call setPixelSizeConversionFactor() in order to setup an appropriate pixel-to-unit conversion factor to scale converted sizes using. E.g. if the target unit is millimeters, the size conversion factor should be set to a pixel-to-millimeter value.

See also

targetUnit()

Parameters:

targetUnit (Qgis.RenderUnit)

spriteCategories(self) List[str][source]

Returns the list of sprite categories to use during conversion, or an empty list of none is set.

See also

spriteImage()

Added in version 3.44.

Return type:

List[str]

spriteDefinitions(self, category: str | None = '') Dict[str, Any][source]

Returns the sprite definitions for a given category to use during conversion.

See also

spriteImage()

See also

setSprites()

Parameters:

category (Optional[str] = '')

Return type:

Dict[str, Any]

spriteImage(self, category: str | None = '') QImage[source]

Returns the sprite image for a given category to use during conversion, or an invalid image if this is not set.

See also

setSprites()

Parameters:

category (Optional[str] = '')

Return type:

QImage

targetUnit(self) Qgis.RenderUnit[source]

Returns the target unit type.

By default this is QgsUnitTypes.RenderPixels in order to exactly match the original style rendering. But rendering in pixels can cause issues on hidpi displays or with print layouts, so setting a target unit of QgsUnitTypes.Millimeters or another real-world unit type is often more appropriate.

See also

setTargetUnit()

Return type:

Qgis.RenderUnit

warnings(self) List[str][source]

Returns a list of warning messages generated during the conversion.

Return type:

List[str]