QGIS API Documentation 3.99.0-Master (c22de0620c0)
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
27#define SIP_NO_FILE
28
30class QgsTileXYZ;
33
34
44{
45 public:
46
48
55
59 void storeCachedTileData( const QgsVectorTileRawData &data );
60
61 QCache< QgsTileXYZ, QgsVectorTileRawData > mTileCache;
62
63 // cannot use a read/write lock here -- see https://bugreports.qt.io/browse/QTBUG-19794
64 QMutex mMutex;
65
66};
67
77{
78 Q_OBJECT
79
80 public:
81
83 static int DATA_COLUMN;
85 static int DATA_ROW;
87 static int DATA_ZOOM;
89 static int DATA_SOURCE_ID;
90
94 QgsVectorTileDataProvider( const QString &uri,
95 const QgsDataProvider::ProviderOptions &providerOptions,
97
100
106
112
113 QgsRectangle extent() const override;
114 bool renderInPreview( const QgsDataProvider::PreviewContext &context ) override;
115
119 virtual QString sourcePath() const = 0;
120
121
126 virtual QgsStringMap sourcePaths() const
127 {
128 return { { QString(), sourcePath() } };
129 }
130
131
136
140 virtual const QgsVectorTileMatrixSet &tileMatrixSet() const = 0;
141
147 virtual bool supportsAsync() const;
148
152 virtual QgsVectorTileRawData readTile( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback = nullptr ) const = 0;
153
157 virtual QList<QgsVectorTileRawData> readTiles( const QgsTileMatrixSet &tileMatrixSet, const QVector<QgsTileXYZ> &tiles, QgsFeedback *feedback = nullptr, Qgis::RendererUsage usage = Qgis::RendererUsage::Unknown ) const = 0;
158
164 virtual QList<QNetworkRequest> tileRequests( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, Qgis::RendererUsage usage ) const;
165
172 virtual QVariantMap styleDefinition() const;
173
180 virtual QString styleUrl() const;
181
188 virtual QVariantMap spriteDefinition() const;
189
195 virtual QImage spriteImage() const;
196
197 protected:
198
199 std::shared_ptr<QgsVectorTileDataProviderSharedData> mShared;
200
201};
202
203
204
205#endif // QGSVECTORTILEDATAPROVIDER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:507
QFlags< VectorTileProviderCapability > VectorTileProviderCapabilities
Vector tile data provider capabilities.
Definition qgis.h:5914
RendererUsage
Usage of the renderer.
Definition qgis.h:3531
@ Unknown
Renderer used for unknown usage.
Definition qgis.h:3534
QFlags< VectorTileProviderFlag > VectorTileProviderFlags
Vector tile data provider flags.
Definition qgis.h:5896
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:278
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:43
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:7463
#define SIP_FACTORY
Definition qgis_sip.h:83
Stores settings related to the context in which a preview job runs.
Setting options for creating vector data providers.