QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsxyzvectortiledataprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsxyzvectortiledataprovider.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 QGSXYZVECTORTILEDATAPROVIDER_H
17#define QGSXYZVECTORTILEDATAPROVIDER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
22#include "qgsprovidermetadata.h"
24
25#define SIP_NO_FILE
26
28
29class CORE_EXPORT QgsXyzVectorTileDataProviderBase : public QgsVectorTileDataProvider
30{
31 Q_OBJECT
32
33 public:
34 QgsXyzVectorTileDataProviderBase( const QString &uri,
35 const QgsDataProvider::ProviderOptions &providerOptions,
37 QgsXyzVectorTileDataProviderBase( const QgsXyzVectorTileDataProviderBase &other );
38
39 QgsXyzVectorTileDataProviderBase &operator=( const QgsXyzVectorTileDataProviderBase &other ) = delete;
40
41 bool supportsAsync() const override;
42 QgsVectorTileRawData readTile( const QgsTileMatrixSet &tileMatrix, const QgsTileXYZ &id, QgsFeedback *feedback = nullptr ) const override;
43 QList<QgsVectorTileRawData> readTiles( const QgsTileMatrixSet &, const QVector<QgsTileXYZ> &tiles, QgsFeedback *feedback = nullptr, Qgis::RendererUsage usage = Qgis::RendererUsage::Unknown ) const override;
44 QList<QNetworkRequest> tileRequests( const QgsTileMatrixSet &tileMatrix, const QgsTileXYZ &id, Qgis::RendererUsage usage ) const override;
45
46 protected:
47
48 QString mAuthCfg;
49 QgsHttpHeaders mHeaders;
50
51 private:
52
54 static QByteArray loadFromNetwork( const QgsTileXYZ &id,
55 const QgsTileMatrix &tileMatrix,
56 const QString &requestUrl,
57 const QString &authid,
58 const QgsHttpHeaders &headers,
59 QgsFeedback *feedback = nullptr,
61
62};
63
64class CORE_EXPORT QgsXyzVectorTileDataProvider : public QgsXyzVectorTileDataProviderBase
65{
66 Q_OBJECT
67
68 public:
69 QgsXyzVectorTileDataProvider( const QString &uri,
70 const QgsDataProvider::ProviderOptions &providerOptions,
72 QgsXyzVectorTileDataProvider( const QgsXyzVectorTileDataProvider &other );
73
74 QgsXyzVectorTileDataProvider &operator=( const QgsXyzVectorTileDataProvider &other ) = delete;
75
76 Qgis::DataProviderFlags flags() const override;
77 QString name() const override;
78 QString description() const override;
79 QgsVectorTileDataProvider *clone() const override;
80 QString sourcePath() const override;
81 QgsStringMap sourcePaths() const override;
82 bool isValid() const override;
83 QgsRectangle extent() const override;
84 QgsCoordinateReferenceSystem crs() const override;
85 const QgsVectorTileMatrixSet &tileMatrixSet() const override;
86
87 static QString XYZ_DATA_PROVIDER_KEY;
88 static QString XYZ_DATA_PROVIDER_DESCRIPTION;
89 protected:
90
91 bool mIsValid = false;
92 QgsRectangle mExtent;
93 QgsVectorTileMatrixSet mMatrixSet;
94
95 private:
96
98 static QByteArray loadFromNetwork( const QgsTileXYZ &id,
99 const QgsTileMatrix &tileMatrix,
100 const QString &requestUrl,
101 const QString &authid,
102 const QgsHttpHeaders &headers,
103 QgsFeedback *feedback = nullptr );
104
105};
106
107
108class QgsXyzVectorTileDataProviderMetadata : public QgsProviderMetadata
109{
110 Q_OBJECT
111 public:
112 QgsXyzVectorTileDataProviderMetadata();
113 QgsXyzVectorTileDataProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags = Qgis::DataProviderReadFlags() ) override;
114 QIcon icon() const override;
115 ProviderCapabilities providerCapabilities() const override;
116 QVariantMap decodeUri( const QString &uri ) const override;
117 QString encodeUri( const QVariantMap &parts ) const override;
118 QString absoluteToRelativeUri( const QString &uri, const QgsReadWriteContext &context ) const override;
119 QString relativeToAbsoluteUri( const QString &uri, const QgsReadWriteContext &context ) const override;
120 QList< Qgis::LayerType > supportedLayerTypes() const override;
121};
122
123
125
126#endif // QGSXYZVECTORTILEDATAPROVIDER_H
QFlags< DataProviderFlag > DataProviderFlags
Data provider flags.
Definition qgis.h:2147
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
RendererUsage
Usage of the renderer.
Definition qgis.h:3188
@ Unknown
Renderer used for unknown usage.
This class represents a coordinate reference system (CRS).
virtual QString name() const =0
Returns a provider name.
virtual Qgis::DataProviderFlags flags() const
Returns the generic data provider flags.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QString description() const =0
Returns description.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
This class implements simple http header management.
Holds data provider key, description, and associated shared library file or function pointer informat...
virtual QgsProviderMetadata::ProviderCapabilities providerCapabilities() const
Returns the provider's capabilities.
virtual QgsDataProvider * createProvider(const QString &uri, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Class factory to return a pointer to a newly created QgsDataProvider object.
virtual QIcon icon() const
Returns an icon representing the provider.
virtual QString encodeUri(const QVariantMap &parts) const
Reassembles a provider data source URI from its component paths (e.g.
virtual QString absoluteToRelativeUri(const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
virtual QList< Qgis::LayerType > supportedLayerTypes() const
Returns a list of the map layer types supported by the provider.
virtual QString relativeToAbsoluteUri(const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
virtual QVariantMap decodeUri(const QString &uri) const
Breaks a provider data source URI into its component paths (e.g.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Defines a set of tile matrices for multiple zoom levels.
Definition qgstiles.h:252
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition qgstiles.h:136
Stores coordinates of a tile in a tile matrix set.
Definition qgstiles.h:40
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.
QgsRectangle extent() const override
Returns the extent of the layer.
QgsVectorTileDataProvider & operator=(const QgsVectorTileDataProvider &other)=delete
virtual const QgsVectorTileMatrixSet & tileMatrixSet() const =0
Returns the tile matrix set associated with the provider.
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.
virtual QgsVectorTileRawData readTile(const QgsTileMatrixSet &tileMatrixSet, const QgsTileXYZ &id, QgsFeedback *feedback=nullptr) const =0
Returns raw tile data for a single tile.
virtual bool supportsAsync() const
Returns true if the provider supports async tile reading.
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
Setting options for creating vector data providers.