QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsvectortiledataprovider.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortiledataprovider.cpp
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
17#include "qgsthreadingutils.h"
18#include "qgsreadwritelocker.h"
19#include "qgsvectortileloader.h"
20
21#include <QNetworkRequest>
22#include <QImage>
23
25 const QString &uri,
26 const ProviderOptions &options,
27 QgsDataProvider::ReadFlags flags )
28 : QgsDataProvider( uri, options, flags )
30{}
31
33 : QgsDataProvider( other.dataSourceUri( false ), ProviderOptions(), other.mReadFlags )
34 , mShared( other.mShared )
35{
37}
38
39Qgis::VectorTileProviderFlags QgsVectorTileDataProvider::providerFlags() const
40{
41 return Qgis::VectorTileProviderFlags();
42}
43
44Qgis::VectorTileProviderCapabilities QgsVectorTileDataProvider::providerCapabilities() const
45{
46 return Qgis::VectorTileProviderCapabilities();
47}
48
55
57{
59
60 // Vector tiles by design are very CPU light to render, so we are much more permissive here compared
61 // with other layer types. (Generally if a vector tile layer has taken more than a few milliseconds to render it's
62 // a result of network requests, and the tile manager class handles these gracefully for us)
63 return context.lastRenderingTimeMs <= 1000;
64}
65
72
74{
76
77 return QNetworkRequest();
78}
79
81{
83
84 return QVariantMap();
85}
86
88{
90
91 return QString();
92}
93
95{
97
98 return QVariantMap();
99}
100
102{
104
105 return QImage();
106}
107
109{
111
112 return QString();
113}
114
115
116
117
122
124{
125 QMutexLocker locker( &mMutex );
126 if ( QgsVectorTileRawData *cachedData = mTileCache.object( tile ) )
127 {
128 data = *cachedData;
129 return true;
130 }
131
132 return false;
133}
134
136{
137 QMutexLocker locker( &mMutex );
138 mTileCache.insert( data.id, new QgsVectorTileRawData( data ) );
139}
RendererUsage
Usage of the renderer.
Definition qgis.h:2548
Abstract base class for spatial data provider implementations.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
A rectangle specified with double values.
Defines a set of tile matrices for multiple zoom levels.
Definition qgstiles.h:250
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:38
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.
QgsRectangle extent() const override
Returns the extent of the layer.
virtual QString htmlMetadata() const
Returns metadata in a format suitable for feeding directly into a subset of the GUI properties "Metad...
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.
QgsVectorTileDataProvider(const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, QgsDataProvider::ReadFlags flags)
Constructor for QgsVectorTileDataProvider, with the specified uri.
virtual Qgis::VectorTileProviderFlags providerFlags() const
Returns flags reflecting the behavior of the data provider.
virtual QNetworkRequest tileRequest(const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, Qgis::RendererUsage usage) const
Returns a network request for a tile.
virtual bool supportsAsync() const
Returns true if the provider supports async tile reading.
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.
bool renderInPreview(const QgsDataProvider::PreviewContext &context) override
Returns whether the layer must be rendered in preview jobs.
virtual QImage spriteImage() const
Returns the sprite image for the provider, if available.
Keeps track of raw tile data that need to be decoded.
QgsTileXYZ id
Tile position in tile matrix set.
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Stores settings related to the context in which a preview job runs.
double lastRenderingTimeMs
Previous rendering time for the layer, in ms.
Setting options for creating vector data providers.