QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | List of all members
QgsVectorTileMVTEncoder Class Reference

Handles conversion of vector features to Mapbox vector tiles encoding. More...

#include <qgsvectortilemvtencoder.h>

Public Member Functions

 QgsVectorTileMVTEncoder (QgsTileXYZ tileID)
 Creates MVT encoder for the given tile coordinates for Web Mercator. More...
 
 QgsVectorTileMVTEncoder (QgsTileXYZ tileID, const QgsTileMatrix &tileMatrix)
 Creates MVT encoder for the given tile coordinates and tile matrix. More...
 
void addLayer (QgsVectorLayer *layer, QgsFeedback *feedback=nullptr, QString filterExpression=QString(), QString layerName=QString())
 Fetches data from vector layer for the given tile, does reprojection and clipping. More...
 
QByteArray encode () const
 Encodes MVT using data stored previously with addLayer() calls. More...
 
int resolution () const
 Returns resolution of coordinates of geometries within the tile. The default is 4096. More...
 
void setResolution (int extent)
 Sets the resolution of coordinates of geometries within the tile. More...
 
void setTileBuffer (int buffer)
 Sets size of the buffer zone around tile edges in integer tile coordinates. More...
 
void setTransformContext (const QgsCoordinateTransformContext &transformContext)
 Sets coordinate transform context for transforms between layers and tile matrix CRS. More...
 
int tileBuffer () const
 Returns size of the buffer zone around tile edges in integer tile coordinates. The default is 256 (~6%) More...
 

Detailed Description

Handles conversion of vector features to Mapbox vector tiles encoding.

Geometries are stored as a series of MoveTo / LineTo / ClosePath commands with coordinates in integer values (see resolution(), called "extent" in the spec). Attributes are stored as key-value pairs of tags: keys are always strings, values can be integers, floating point numbers, booleans or strings.

See the specification for details: https://github.com/mapbox/vector-tile-spec/blob/master/2.1/README.md

Since
QGIS 3.14

Definition at line 40 of file qgsvectortilemvtencoder.h.

Constructor & Destructor Documentation

◆ QgsVectorTileMVTEncoder() [1/2]

QgsVectorTileMVTEncoder::QgsVectorTileMVTEncoder ( QgsTileXYZ  tileID)
explicit

Creates MVT encoder for the given tile coordinates for Web Mercator.

Definition at line 145 of file qgsvectortilemvtencoder.cpp.

◆ QgsVectorTileMVTEncoder() [2/2]

QgsVectorTileMVTEncoder::QgsVectorTileMVTEncoder ( QgsTileXYZ  tileID,
const QgsTileMatrix tileMatrix 
)
explicit

Creates MVT encoder for the given tile coordinates and tile matrix.

Definition at line 153 of file qgsvectortilemvtencoder.cpp.

Member Function Documentation

◆ addLayer()

void QgsVectorTileMVTEncoder::addLayer ( QgsVectorLayer layer,
QgsFeedback feedback = nullptr,
QString  filterExpression = QString(),
QString  layerName = QString() 
)

Fetches data from vector layer for the given tile, does reprojection and clipping.

Optional feedback object may be provided to support cancellation.

Definition at line 160 of file qgsvectortilemvtencoder.cpp.

◆ encode()

QByteArray QgsVectorTileMVTEncoder::encode ( ) const

Encodes MVT using data stored previously with addLayer() calls.

Definition at line 381 of file qgsvectortilemvtencoder.cpp.

◆ resolution()

int QgsVectorTileMVTEncoder::resolution ( ) const
inline

Returns resolution of coordinates of geometries within the tile. The default is 4096.

Definition at line 50 of file qgsvectortilemvtencoder.h.

◆ setResolution()

void QgsVectorTileMVTEncoder::setResolution ( int  extent)
inline

Sets the resolution of coordinates of geometries within the tile.

Definition at line 52 of file qgsvectortilemvtencoder.h.

◆ setTileBuffer()

void QgsVectorTileMVTEncoder::setTileBuffer ( int  buffer)
inline

Sets size of the buffer zone around tile edges in integer tile coordinates.

Definition at line 57 of file qgsvectortilemvtencoder.h.

◆ setTransformContext()

void QgsVectorTileMVTEncoder::setTransformContext ( const QgsCoordinateTransformContext transformContext)
inline

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

Definition at line 60 of file qgsvectortilemvtencoder.h.

◆ tileBuffer()

int QgsVectorTileMVTEncoder::tileBuffer ( ) const
inline

Returns size of the buffer zone around tile edges in integer tile coordinates. The default is 256 (~6%)

Definition at line 55 of file qgsvectortilemvtencoder.h.


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