Class: QgsVectorTileUtils¶
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
QgsFields
instance 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
z0Scale
argument 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
z0Scale
argument 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
- static updateUriSources(uri: str | None, forceUpdate: bool = False) str [source]¶
Parses the style URL to update the source URLs in the
uri
. IfforceUpdate
isTrue
, any existing source will be updated.Added in version 3.40.
- Parameters:
uri (Optional[str])
forceUpdate (bool = False)
- Return type:
str