QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
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(). More... | |
QgsRectangle | fullExtent () const |
Returns calculated extent that combines extent of all input layers. More... | |
void | setDestinationUri (const QString &uri) |
Sets where and how the vector tiles will be written. More... | |
void | setExtent (const QgsRectangle &extent) |
Sets extent of vector tile output. More... | |
void | setLayers (const QList< QgsVectorTileWriter::Layer > &layers) |
Sets vector layers and their configuration for output of vector tiles. More... | |
void | setMaxZoom (int maxZoom) |
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24]. More... | |
void | setMetadata (const QVariantMap &metadata) |
Sets that will be written to the output dataset. See class description for more on metadata support. More... | |
void | setMinZoom (int minZoom) |
Sets the minimum zoom level of tiles. Allowed values are in interval [0,24]. More... | |
void | setTransformContext (const QgsCoordinateTransformContext &transformContext) |
Sets coordinate transform context for transforms between layers and tile matrix CRS. More... | |
bool | writeTiles (QgsFeedback *feedback=nullptr) |
Writes vector tiles according to the configuration. More... | |
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 72 of file qgsvectortilewriter.h.
QgsVectorTileWriter::QgsVectorTileWriter | ( | ) |
Definition at line 36 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 163 of file qgsvectortilewriter.h.
QgsRectangle QgsVectorTileWriter::fullExtent | ( | ) | const |
Returns calculated extent that combines extent of all input layers.
Definition at line 216 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 128 of file qgsvectortilewriter.h.
|
inline |
Sets extent of vector tile output.
Currently always in EPSG:3857. If unset, it will use the full extent of all input layers combined
Definition at line 134 of file qgsvectortilewriter.h.
|
inline |
Sets vector layers and their configuration for output of vector tiles.
Definition at line 142 of file qgsvectortilewriter.h.
|
inline |
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24].
Definition at line 139 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 145 of file qgsvectortilewriter.h.
|
inline |
Sets the minimum zoom level of tiles. Allowed values are in interval [0,24].
Definition at line 137 of file qgsvectortilewriter.h.
|
inline |
Sets coordinate transform context for transforms between layers and tile matrix CRS.
Definition at line 148 of file qgsvectortilewriter.h.
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 41 of file qgsvectortilewriter.cpp.