Class: QgsTileMatrixSet

Defines a set of tile matrices for multiple zoom levels.

Added in version 3.22.6.

Class Hierarchy

Inheritance diagram of qgis.core.QgsTileMatrixSet

Subclasses

QgsVectorTileMatrixSet

Encapsulates properties of a vector tile matrix set, including tile origins and scaling information.

Methods

addGoogleCrs84QuadTiles

Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.

addMatrix

Adds a matrix to the set.

calculateTileScaleForMap

Calculates the correct scale to use for the tiles when rendered using the specified map properties.

crs

Returns the coordinate reference system associated with the tiles.

dropMatricesOutsideZoomRange

Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZoom, inclusive.

isEmpty

Returns True if the matrix set is empty.

maximumZoom

Returns the maximum zoom level for tiles present in the set.

minimumZoom

Returns the minimum zoom level for tiles present in the set.

rootMatrix

Returns the root tile matrix (usually corresponding to zoom level 0).

scaleForRenderContext

Calculates the correct scale to use for the tiles when rendered using the specified render context.

scaleToTileZoomMethod

Returns the scale to tile zoom method.

scaleToZoom

Calculates a fractional zoom level given a map scale denominator.

scaleToZoomLevel

Finds the best fitting (integer) zoom level given a map scale denominator.

setRootMatrix

Sets the root tile matrix (usually corresponding to zoom level 0).

setScaleToTileZoomMethod

Sets the scale to tile zoom method.

tileAvailability

Returns the availability of the given tile in this matrix.

tileMatrix

Returns the tile matrix corresponding to the specified zoom.

tilesInRange

Returns a list of tiles in the given tile range.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsTileMatrixSet. See the FAQ for more details.

readXml

Reads the set from an XML element.

writeXml

Writes the set to an XML element.

class qgis.core.QgsTileMatrixSet[source]

Bases: object

addGoogleCrs84QuadTiles(self, minimumZoom: int = 0, maximumZoom: int = 14)[source]

Adds tile matrices corresponding to the standard web mercator/GoogleCRS84Quad setup.

Parameters:
  • minimumZoom (int = 0)

  • maximumZoom (int = 14)

addMatrix(self, matrix: QgsTileMatrix)[source]

Adds a matrix to the set.

Any existing matrix with the same QgsTileMatrix.zoomLevel() will be replaced.

Parameters:

matrix (QgsTileMatrix)

calculateTileScaleForMap(self, actualMapScale: float, mapCrs: QgsCoordinateReferenceSystem, mapExtent: QgsRectangle, mapSize: QSize, mapDpi: float) float[source]

Calculates the correct scale to use for the tiles when rendered using the specified map properties.

Added in version 3.26.

Parameters:
Return type:

float

crs(self) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with the tiles.

In the case of a tile set containing mixed CRS at different zoom levels this method will return the crs of the minimum zoom tile matrix.

Return type:

QgsCoordinateReferenceSystem

dropMatricesOutsideZoomRange(self, minimumZoom: int, maximumZoom: int)[source]

Deletes any existing matrices which fall outside the zoom range specified by minimumZoom to maximumZoom, inclusive.

Parameters:
  • minimumZoom (int)

  • maximumZoom (int)

isEmpty(self) bool[source]

Returns True if the matrix set is empty.

Return type:

bool

maximumZoom(self) int[source]

Returns the maximum zoom level for tiles present in the set.

See also

minimumZoom()

Return type:

int

minimumZoom(self) int[source]

Returns the minimum zoom level for tiles present in the set.

See also

maximumZoom()

Return type:

int

virtual readXml(self, element: QDomElement, context: QgsReadWriteContext) bool[source]

Reads the set from an XML element.

See also

writeXml()

Parameters:
Return type:

bool

rootMatrix(self) QgsTileMatrix[source]

Returns the root tile matrix (usually corresponding to zoom level 0).

Added in version 3.28.

Return type:

QgsTileMatrix

scaleForRenderContext(self, context: QgsRenderContext) float[source]

Calculates the correct scale to use for the tiles when rendered using the specified render context.

Added in version 3.26.

Parameters:

context (QgsRenderContext)

Return type:

float

scaleToTileZoomMethod(self) Qgis.ScaleToTileZoomLevelMethod[source]

Returns the scale to tile zoom method.

Return type:

Qgis.ScaleToTileZoomLevelMethod

scaleToZoom(self, scale: float) float[source]

Calculates a fractional zoom level given a map scale denominator.

The zoom level will be linearly interpolated between zoom levels present in the set.

Parameters:

scale (float)

Return type:

float

scaleToZoomLevel(self, scale: float, clamp: bool = True) int[source]

Finds the best fitting (integer) zoom level given a map scale denominator. An optional clamp parameter can be set to False to disable clamping zoom level to the tile matrix set’s minimum and maximum zoom level.

Values are constrained to the zoom levels between minimumZoom() and maximumZoom().

Parameters:
  • scale (float)

  • clamp (bool = True)

Return type:

int

setRootMatrix(self, matrix: QgsTileMatrix)[source]

Sets the root tile matrix (usually corresponding to zoom level 0).

Added in version 3.28.

Parameters:

matrix (QgsTileMatrix)

setScaleToTileZoomMethod(self, method: Qgis.ScaleToTileZoomLevelMethod)[source]

Sets the scale to tile zoom method.

Parameters:

method (Qgis.ScaleToTileZoomLevelMethod)

tileAvailability(self, id: QgsTileXYZ) Qgis.TileAvailability[source]

Returns the availability of the given tile in this matrix.

This method can be used to determine whether a particular tile actually exists within the matrix, or is not available (e.g. due to holes within the matrix).

This method returns Qgis.TileAvailability.Available by default, unless specific tile availability is known for the given id.

Added in version 3.32.

Parameters:

id (QgsTileXYZ)

Return type:

Qgis.TileAvailability

tileMatrix(self, zoom: int) QgsTileMatrix[source]

Returns the tile matrix corresponding to the specified zoom.

Parameters:

zoom (int)

Return type:

QgsTileMatrix

tilesInRange(self, range: QgsTileRange, zoomLevel: int) List[QgsTileXYZ]

Returns a list of tiles in the given tile range.

Added in version 3.32.

Parameters:
Return type:

List[QgsTileXYZ]

virtual writeXml(self, document: QDomDocument, context: QgsReadWriteContext) QDomElement[source]

Writes the set to an XML element.

Parameters:
Return type:

QDomElement