QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
Takes care of writing vector tiles. More...
#include <qgsvectortilewriter.h>
Classes | |
class | Layer |
Configuration of a single input vector layer to be included in the output. More... | |
Public Member Functions | |
QgsVectorTileWriter () | |
QString | errorMessage () const |
Returns error message related to the previous call to writeTiles(). | |
QgsRectangle | fullExtent () const |
Returns calculated extent that combines extent of all input layers. | |
void | setDestinationUri (const QString &uri) |
Sets where and how the vector tiles will be written. | |
void | setExtent (const QgsRectangle &extent) |
Sets extent of vector tile output. | |
void | setLayers (const QList< QgsVectorTileWriter::Layer > &layers) |
Sets vector layers and their configuration for output of vector tiles. | |
void | setMaxZoom (int maxZoom) |
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24]. | |
void | setMetadata (const QVariantMap &metadata) |
Sets that will be written to the output dataset. See class description for more on metadata support. | |
void | setMinZoom (int minZoom) |
Sets the minimum zoom level of tiles. Allowed values are in interval [0,24]. | |
bool | setRootTileMatrix (const QgsTileMatrix &tileMatrix) |
Sets zoom level 0 tile matrix. | |
void | setTransformContext (const QgsCoordinateTransformContext &transformContext) |
Sets coordinate transform context for transforms between layers and tile matrix CRS. | |
QByteArray | writeSingleTile (QgsTileXYZ tileID, QgsFeedback *feedback=nullptr, int buffer=256, int resolution=4096) const |
Encodes single MVT tile. | |
bool | writeTiles (QgsFeedback *feedback=nullptr) |
Writes vector tiles according to the configuration. | |
Takes care of writing vector tiles.
The intended use is to set up the class by setting the destination URI, extent, zoom level range and input vector layers. Then with a call to writeTiles() the data gets written. In case of a failure, errorMessage() returns the cause of the problem during writing.
The syntax of destination URIs is the same like the data source string used by vector tile layers: parameters are encoded as a HTTP query string, where "type" key determines the type of the destination container, the "url" key is normally the path. Currently supported types:
Currently the writer only support MVT encoding of data.
Metadata support: it is possible to pass a QVariantMap with metadata. This is backend dependent. Currently only "mbtiles" source type supports writing of metadata. The key-value pairs will be written to the "metadata" table in the MBTiles file. Some useful metadata keys listed here, but see MBTiles spec for more details:
Vector tile writer always writes "format" and "json" metadata. If not specified in metadata by the client, tile writer also writes "name", "bounds", "minzoom" and "maxzoom".
Definition at line 76 of file qgsvectortilewriter.h.
QgsVectorTileWriter::QgsVectorTileWriter | ( | ) |
Definition at line 37 of file qgsvectortilewriter.cpp.
|
inline |
Returns error message related to the previous call to writeTiles().
Will return an empty string if writing was successful.
Definition at line 172 of file qgsvectortilewriter.h.
QgsRectangle QgsVectorTileWriter::fullExtent | ( | ) | const |
Returns calculated extent that combines extent of all input layers.
Definition at line 232 of file qgsvectortilewriter.cpp.
|
inline |
Sets where and how the vector tiles will be written.
See the class description about the syntax of destination URIs.
Definition at line 132 of file qgsvectortilewriter.h.
|
inline |
Sets extent of vector tile output.
If unset, it will use the full extent of all input layers combined
Definition at line 138 of file qgsvectortilewriter.h.
|
inline |
Sets vector layers and their configuration for output of vector tiles.
Definition at line 146 of file qgsvectortilewriter.h.
|
inline |
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24].
Definition at line 143 of file qgsvectortilewriter.h.
|
inline |
Sets that will be written to the output dataset. See class description for more on metadata support.
Definition at line 149 of file qgsvectortilewriter.h.
|
inline |
Sets the minimum zoom level of tiles. Allowed values are in interval [0,24].
Definition at line 141 of file qgsvectortilewriter.h.
bool QgsVectorTileWriter::setRootTileMatrix | ( | const QgsTileMatrix & | tileMatrix | ) |
Sets zoom level 0 tile matrix.
Definition at line 43 of file qgsvectortilewriter.cpp.
|
inline |
Sets coordinate transform context for transforms between layers and tile matrix CRS.
Definition at line 152 of file qgsvectortilewriter.h.
QByteArray QgsVectorTileWriter::writeSingleTile | ( | QgsTileXYZ | tileID, |
QgsFeedback * | feedback = nullptr , |
||
int | buffer = 256 , |
||
int | resolution = 4096 |
||
) | const |
Encodes single MVT tile.
tileID | Tile identifier |
feedback | optional, provide cancellation functionality |
resolution | the resolution of coordinates of geometries within the tile. The default is 4096 |
buffer | size of the buffer zone around tile edges in integer tile coordinates. The default is 256 (~6%) |
Returns a QByteArray with the encoded data
Definition at line 317 of file qgsvectortilewriter.cpp.
bool QgsVectorTileWriter::writeTiles | ( | QgsFeedback * | feedback = nullptr | ) |
Writes vector tiles according to the configuration.
Returns true
on success (upon failure one can get error cause using errorMessage())
If a pointer to a feedback object is provided, it can be used to track progress or provide cancellation functionality.
Definition at line 54 of file qgsvectortilewriter.cpp.