QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
105
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:486
QFlags< VectorTileProviderCapability > VectorTileProviderCapabilities
Vector tile data provider capabilities.
Definition qgis.h:5598
RendererUsage
Usage of the renderer.
Definition qgis.h:3445
@ Unknown
Renderer used for unknown usage.
Definition qgis.h:3448
QFlags< VectorTileProviderFlag > VectorTileProviderFlags
Vector tile data provider flags.
Definition qgis.h:5580
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Create a new dataprovider with the specified in the uri.
QgsDataSourceUri uri() const
Gets the data source specification.
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:274
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:39
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.
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 Qgis::VectorTileProviderCapabilities providerCapabilities() const
Returns flags containing the supported capabilities of the data provider.
virtual QString styleUrl() const
Returns the URL for the provider style, if available.
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.
virtual QList< QNetworkRequest > tileRequests(const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, Qgis::RendererUsage usage) const
Returns a network request for a tile.
static int DATA_SOURCE_ID
Role to set source ID attribute in the request so it can be retrieved later.
QgsVectorTileDataProvider(const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags)
Constructor for QgsVectorTileDataProvider, with the specified uri.
virtual QgsVectorTileRawData readTile(const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback=nullptr) const =0
Returns raw tile data for a single tile.
virtual Qgis::VectorTileProviderFlags providerFlags() const
Returns flags reflecting the behavior of the data provider.
static int DATA_COLUMN
Role to set column attribute in the request so it can be retrieved later.
virtual bool supportsAsync() const
Returns true if the provider supports async tile reading.
std::shared_ptr< QgsVectorTileDataProviderSharedData > mShared
Mutable data shared between provider instances.
virtual QVariantMap spriteDefinition() const
Returns the sprite definition for the provider, if available.
virtual QVariantMap styleDefinition() const
Returns the style definition for the provider, if available.
virtual QImage spriteImage() const
Returns the sprite image for the provider, if available.
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:7132
#define SIP_FACTORY
Definition qgis_sip.h:84
Stores settings related to the context in which a preview job runs.
Setting options for creating vector data providers.