QGIS API Documentation  3.20.0-Odense (decaadbb31)
Classes | Public Member Functions | List of all members
QgsVectorTileWriter Class Reference

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...
 

Detailed Description

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".

Since
QGIS 3.14

Definition at line 72 of file qgsvectortilewriter.h.

Constructor & Destructor Documentation

◆ QgsVectorTileWriter()

QgsVectorTileWriter::QgsVectorTileWriter ( )

Definition at line 36 of file qgsvectortilewriter.cpp.

Member Function Documentation

◆ errorMessage()

QString QgsVectorTileWriter::errorMessage ( ) const
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.

◆ fullExtent()

QgsRectangle QgsVectorTileWriter::fullExtent ( ) const

Returns calculated extent that combines extent of all input layers.

Definition at line 216 of file qgsvectortilewriter.cpp.

◆ setDestinationUri()

void QgsVectorTileWriter::setDestinationUri ( const QString &  uri)
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.

◆ setExtent()

void QgsVectorTileWriter::setExtent ( const QgsRectangle extent)
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.

◆ setLayers()

void QgsVectorTileWriter::setLayers ( const QList< QgsVectorTileWriter::Layer > &  layers)
inline

Sets vector layers and their configuration for output of vector tiles.

Definition at line 142 of file qgsvectortilewriter.h.

◆ setMaxZoom()

void QgsVectorTileWriter::setMaxZoom ( int  maxZoom)
inline

Sets the maximum zoom level of tiles. Allowed values are in interval [0,24].

Definition at line 139 of file qgsvectortilewriter.h.

◆ setMetadata()

void QgsVectorTileWriter::setMetadata ( const QVariantMap &  metadata)
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.

◆ setMinZoom()

void QgsVectorTileWriter::setMinZoom ( int  minZoom)
inline

Sets the minimum zoom level of tiles. Allowed values are in interval [0,24].

Definition at line 137 of file qgsvectortilewriter.h.

◆ setTransformContext()

void QgsVectorTileWriter::setTransformContext ( const QgsCoordinateTransformContext transformContext)
inline

Sets coordinate transform context for transforms between layers and tile matrix CRS.

Definition at line 148 of file qgsvectortilewriter.h.

◆ writeTiles()

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.


The documentation for this class was generated from the following files: