QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
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
75{
76 Q_OBJECT
77
78 public:
80 static int DATA_COLUMN;
82 static int DATA_ROW;
84 static int DATA_ZOOM;
86 static int DATA_SOURCE_ID;
87
92
95
101
107
108 QgsRectangle extent() const override;
109 bool renderInPreview( const QgsDataProvider::PreviewContext &context ) override;
110
114 virtual QString sourcePath() const = 0;
115
116
121 virtual QgsStringMap sourcePaths() const { return { { QString(), sourcePath() } }; }
122
123
128
132 virtual const QgsVectorTileMatrixSet &tileMatrixSet() const = 0;
133
139 virtual bool supportsAsync() const;
140
144 virtual QgsVectorTileRawData readTile( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback = nullptr ) const = 0;
145
149 virtual QList<QgsVectorTileRawData> readTiles(
150 const QgsTileMatrixSet &tileMatrixSet, const QVector<QgsTileXYZ> &tiles, QgsFeedback *feedback = nullptr, Qgis::RendererUsage usage = Qgis::RendererUsage::Unknown
151 ) const
152 = 0;
153
159 virtual QList<QNetworkRequest> tileRequests( const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, Qgis::RendererUsage usage ) const;
160
167 virtual QVariantMap styleDefinition() const;
168
175 virtual QString styleUrl() const;
176
183 virtual QVariantMap spriteDefinition() const;
184
190 virtual QImage spriteImage() const;
191
192 protected:
193 std::shared_ptr<QgsVectorTileDataProviderSharedData> mShared;
194};
195
196
197#endif // QGSVECTORTILEDATAPROVIDER_H
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
QFlags< VectorTileProviderCapability > VectorTileProviderCapabilities
Vector tile data provider capabilities.
Definition qgis.h:5954
RendererUsage
Usage of the renderer.
Definition qgis.h:3559
@ Unknown
Renderer used for unknown usage.
Definition qgis.h:3562
QFlags< VectorTileProviderFlag > VectorTileProviderFlags
Vector tile data provider flags.
Definition qgis.h:5936
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:284
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:7475
#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.