QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsvectortilewriter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilewriter.h
3 --------------------------------------
4 Date : April 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVECTORTILEWRITER_H
17#define QGSVECTORTILEWRITER_H
18
21#include "qgsrectangle.h"
22#include "qgstiles.h"
23
24#include <QCoreApplication>
25
26class QgsFeedback;
27class QgsTileMatrix;
28class QgsTileXYZ;
29class QgsVectorLayer;
30
31
77class CORE_EXPORT QgsVectorTileWriter
78{
79 Q_DECLARE_TR_FUNCTIONS( QgsVectorTileWriter )
80
81 public:
83
89 class Layer
90 {
91 public:
94 : mLayer( layer )
95 {
96 }
97
99 QgsVectorLayer *layer() const { return mLayer; }
100
102 QString filterExpression() const { return mFilterExpression; }
104 void setFilterExpression( const QString &expr ) { mFilterExpression = expr; }
105
107 QString layerName() const { return mLayerName; }
109 void setLayerName( const QString &name ) { mLayerName = name; }
110
112 int minZoom() const { return mMinZoom; }
114 void setMinZoom( int minzoom ) { mMinZoom = minzoom; }
115
117 int maxZoom() const { return mMaxZoom; }
119 void setMaxZoom( int maxzoom ) { mMaxZoom = maxzoom; }
120
121 private:
122 QgsVectorLayer *mLayer;
123 QString mFilterExpression;
124 QString mLayerName;
125 int mMinZoom = -1;
126 int mMaxZoom = -1;
127 };
128
133 void setDestinationUri( const QString &uri ) { mDestinationUri = uri; }
134
139 void setExtent( const QgsRectangle &extent ) { mExtent = extent; }
140
142 void setMinZoom( int minZoom ) { mMinZoom = minZoom; }
144 void setMaxZoom( int maxZoom ) { mMaxZoom = maxZoom; }
145
147 void setLayers( const QList<QgsVectorTileWriter::Layer> &layers ) { mLayers = layers; }
148
150 void setMetadata( const QVariantMap &metadata ) { mMetadata = metadata; }
151
153 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) { mTransformContext = transformContext; }
154
158 bool setRootTileMatrix( const QgsTileMatrix &tileMatrix );
159
167 bool writeTiles( QgsFeedback *feedback = nullptr );
168
173 QString errorMessage() const { return mErrorMessage; }
174
176 QgsRectangle fullExtent() const;
177
190 QByteArray writeSingleTile( QgsTileXYZ tileID, QgsFeedback *feedback = nullptr, int buffer = 256, int resolution = 4096 ) const;
191
192 private:
193 bool writeTileFileXYZ( const QString &sourcePath, QgsTileXYZ tileID, const QgsTileMatrix &tileMatrix, const QByteArray &tileData );
194 QString mbtilesJsonSchema() const;
195
196 private:
197 QgsTileMatrix mRootTileMatrix;
198 QgsRectangle mExtent;
199 int mMinZoom = 0;
200 int mMaxZoom = 4;
201 QList<Layer> mLayers;
202 QString mDestinationUri;
203 QVariantMap mMetadata;
204 QgsCoordinateTransformContext mTransformContext;
205
206 QString mErrorMessage;
207};
208
209#endif // QGSVECTORTILEWRITER_H
Contains information about the context in which a coordinate transform is executed.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A rectangle specified with double values.
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition qgstiles.h:158
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:39
Represents a vector layer which manages a vector based dataset.
QString layerName() const
Returns layer name in the output. If not set, layer()->name() will be used.
Layer(QgsVectorLayer *layer)
Constructs an entry for a vector layer.
void setLayerName(const QString &name)
Sets layer name in the output. If not set, layer()->name() will be used.
QgsVectorLayer * layer() const
Returns vector layer of this entry.
void setMaxZoom(int maxzoom)
Sets maximum zoom level at which this layer will be used. Negative value means no max....
void setFilterExpression(const QString &expr)
Sets filter expression. If not empty, only features matching the expression will be used.
void setMinZoom(int minzoom)
Sets minimum zoom level at which this layer will be used. Negative value means no min....
QString filterExpression() const
Returns filter expression. If not empty, only features matching the expression will be used.
int maxZoom() const
Returns maximum zoom level at which this layer will be used. Negative value means no max....
int minZoom() const
Returns minimum zoom level at which this layer will be used. Negative value means no min....
QString errorMessage() const
Returns error message related to the previous call to writeTiles().
void setMaxZoom(int maxZoom)
Sets the maximum zoom level of tiles. Allowed values are in interval [0,24].
void setDestinationUri(const QString &uri)
Sets where and how the vector tiles will be written.
void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets coordinate transform context for transforms between layers and tile matrix CRS.
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 setMinZoom(int minZoom)
Sets the minimum 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.