Class: QgsVectorTileUtils¶
Random utility functions for working with vector tiles
Added in version 3.14.
Static Methods
Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)  | 
|
Returns formatted tile URL string replacing {x}, {y}, {z} placeholders (or {-y} instead of {y} for TMS convention)  | 
|
Downloads the sprite image and sets it to the conversion context  | 
|
Returns   | 
|
Returns a temporary vector layer for given sub-layer of tile in vector tile layer  | 
|
Finds zoom level given map scale denominator.  | 
|
Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.  | 
|
Orders tile requests according to the distance from view center (given in tile matrix coords)  | 
|
Returns polygon (made by four corners of the tile) in screen coordinates  | 
|
Parses the style URL to update the source URLs in the uri.  | 
- class qgis.core.QgsVectorTileUtils[source]¶
 Bases:
object- static checkXYZUrlTemplate(url: str | None) bool[source]¶
 Checks whether the URL template string is correct (contains {x}, {y} / {-y}, {z} placeholders)
- Parameters:
 url (Optional[str])
- Return type:
 bool
- static formatXYZUrlTemplate(url: str | None, tile: QgsTileXYZ, tileMatrix: QgsTileMatrix) str[source]¶
 Returns formatted tile URL string replacing {x}, {y}, {z} placeholders (or {-y} instead of {y} for TMS convention)
- Parameters:
 url (Optional[str])
tile (QgsTileXYZ)
tileMatrix (QgsTileMatrix)
- Return type:
 str
- static loadSprites(styleDefinition: Dict[str, Any], context: QgsMapBoxGlStyleConversionContext, styleUrl: str | None = '')[source]¶
 Downloads the sprite image and sets it to the conversion context
- Parameters:
 styleDefinition (Dict[str, Any]) – the style definition map
context (QgsMapBoxGlStyleConversionContext) – the style conversion context
styleUrl (Optional[str] = '') – optional the style url
- static makeQgisFields(flds: Iterable[str | None]) QgsFields[source]¶
 Returns
QgsFieldsinstance based on the set of field names- Parameters:
 flds (Iterable[Optional[str]])
- Return type:
 
- static makeVectorLayerForTile(mvt: QgsVectorTileLayer | None, tileID: QgsTileXYZ, layerName: str | None) QgsVectorLayer | None[source]¶
 Returns a temporary vector layer for given sub-layer of tile in vector tile layer
- Parameters:
 mvt (Optional[QgsVectorTileLayer])
tileID (QgsTileXYZ)
layerName (Optional[str])
- Return type:
 Optional[QgsVectorLayer]
- static scaleToZoom(mapScale: float, z0Scale: float = 5.59082e+08) float[source]¶
 Finds zoom level given map scale denominator.
The
z0Scaleargument gives the scale denominator at zoom level 0, where the default value corresponds to GoogleCRS84Quad tile matrix setAdded in version 3.16.
- Parameters:
 mapScale (float)
z0Scale (float = 5.59082e+08)
- Return type:
 float
- static scaleToZoomLevel(mapScale: float, sourceMinZoom: int, sourceMaxZoom: int, z0Scale: float = 5.59082e+08) int[source]¶
 Finds the best fitting zoom level given a map scale denominator and allowed zoom level range.
The
z0Scaleargument gives the scale denominator at zoom level 0, where the default value corresponds to GoogleCRS84Quad tile matrix set.- Parameters:
 mapScale (float)
sourceMinZoom (int)
sourceMaxZoom (int)
z0Scale (float = 5.59082e+08)
- Return type:
 int
- static sortTilesByDistanceFromCenter(tiles: Iterable[QgsTileXYZ], center: QPointF | QPoint)[source]¶
 Orders tile requests according to the distance from view center (given in tile matrix coords)
- Parameters:
 tiles (Iterable[QgsTileXYZ])
center (Union[QPointF, QPoint])
- static tilePolygon(id: QgsTileXYZ, ct: QgsCoordinateTransform, tm: QgsTileMatrix, mtp: QgsMapToPixel) QPolygon[source]¶
 Returns polygon (made by four corners of the tile) in screen coordinates
- Raises:
 - Parameters:
 id (QgsTileXYZ)
tm (QgsTileMatrix)
mtp (QgsMapToPixel)
- Return type:
 QPolygon