QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsvectortiledataprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortiledataprovider.h
3 --------------------------------------
4 Date : March 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 QGSVECTORTILEDATAPROVIDER_H
17#define QGSVECTORTILEDATAPROVIDER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsdataprovider.h"
22#include "qgstiles.h"
23
24#include <QCache>
25#include <QReadWriteLock>
26
28class QgsTileXYZ;
31
32#define SIP_NO_FILE
33
43{
44 public:
45
47
54
58 void storeCachedTileData( const QgsVectorTileRawData &data );
59
60 QCache< QgsTileXYZ, QgsVectorTileRawData > mTileCache;
61
62 // cannot use a read/write lock here -- see https://bugreports.qt.io/browse/QTBUG-19794
63 QMutex mMutex;
64
65};
66
76{
77 Q_OBJECT
78
79 public:
80
82 static int DATA_COLUMN;
84 static int DATA_ROW;
86 static int DATA_ZOOM;
88 static int DATA_SOURCE_ID;
89
93 QgsVectorTileDataProvider( const QString &uri,
94 const QgsDataProvider::ProviderOptions &providerOptions,
96
99
104 virtual Qgis::VectorTileProviderFlags providerFlags() const;
105
110 virtual Qgis::VectorTileProviderCapabilities providerCapabilities() const;
111
112 QgsRectangle extent() const override;
113 bool renderInPreview( const QgsDataProvider::PreviewContext &context ) override;
114
118 virtual QString sourcePath() const = 0;
119
120
125 virtual QgsStringMap sourcePaths() const
126 {
127 return { { QString(), sourcePath() } };
128 }
129
130
135
139 virtual const QgsVectorTileMatrixSet &tileMatrixSet() const = 0;
140
146 virtual bool supportsAsync() const;
147
151 virtual QgsVectorTileRawData readTile( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback = nullptr ) const = 0;
152
156 virtual QList<QgsVectorTileRawData> readTiles( const QgsTileMatrixSet &tileMatrixSet, const QVector<QgsTileXYZ> &tiles, QgsFeedback *feedback = nullptr, Qgis::RendererUsage usage = Qgis::RendererUsage::Unknown ) const = 0;
157
163 virtual QList<QNetworkRequest> tileRequests( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, Qgis::RendererUsage usage ) const;
164
171 virtual QVariantMap styleDefinition() const;
172
179 virtual QString styleUrl() const;
180
187 virtual QVariantMap spriteDefinition() const;
188
194 virtual QImage spriteImage() const;
195
196 protected:
197
198 std::shared_ptr<QgsVectorTileDataProviderSharedData> mShared;
199
200};
201
202
203
204#endif // QGSVECTORTILEDATAPROVIDER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
QFlags< VectorTileProviderCapability > VectorTileProviderCapabilities
Vector tile data provider capabilities.
Definition qgis.h:5188
RendererUsage
Usage of the renderer.
Definition qgis.h:3188
@ Unknown
Renderer used for unknown usage.
QFlags< VectorTileProviderFlag > VectorTileProviderFlags
Vector tile data provider flags.
Definition qgis.h:5170
Abstract base class for spatial data provider implementations.
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
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 set of tile matrices for multiple zoom levels.
Definition qgstiles.h:252
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:40
Shared data class for vector tile layer data providers.
void storeCachedTileData(const QgsVectorTileRawData &data)
Stores raw tile data in the shared cache.
QCache< QgsTileXYZ, QgsVectorTileRawData > mTileCache
bool getCachedTileData(QgsVectorTileRawData &data, QgsTileXYZ id)
Retrieves previously cached raw tile data for a tile with matching id.
QMutex mMutex
Access to all data members is guarded by the mutex.
Base class for vector tile layer data providers.
virtual QString sourcePath() const =0
Returns the source path for the data.
virtual QgsVectorTileDataProvider * clone() const =0
Returns a clone of the data provider.
virtual QList< QgsVectorTileRawData > readTiles(const QgsTileMatrixSet &tileMatrixSet, const QVector< QgsTileXYZ > &tiles, QgsFeedback *feedback=nullptr, Qgis::RendererUsage usage=Qgis::RendererUsage::Unknown) const =0
Returns raw tile data for a range of tiles.
QgsVectorTileDataProvider & operator=(const QgsVectorTileDataProvider &other)=delete
static int DATA_ZOOM
Role to set zoom attribute in the request so it can be retrieved later.
virtual const QgsVectorTileMatrixSet & tileMatrixSet() const =0
Returns the tile matrix set associated with the provider.
static int DATA_ROW
Role to set row attribute in the request so it can be retrieved later.
virtual QgsStringMap sourcePaths() const
Returns the list of source paths for the data.
static int DATA_SOURCE_ID
Role to set source ID attribute in the request so it can be retrieved later.
virtual QgsVectorTileRawData readTile(const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback=nullptr) const =0
Returns raw tile data for a single tile.
static int DATA_COLUMN
Role to set column attribute in the request so it can be retrieved later.
std::shared_ptr< QgsVectorTileDataProviderSharedData > mShared
Mutable data shared between provider instances.
Encapsulates properties of a vector tile matrix set, including tile origins and scaling information.
Keeps track of raw tile data from one or more sources that need to be decoded.
QMap< QString, QString > QgsStringMap
Definition qgis.h:6455
#define SIP_FACTORY
Definition qgis_sip.h:76
Stores settings related to the context in which a preview job runs.
Setting options for creating vector data providers.