QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsvectortileloader.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectortileloader.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 QGSVECTORTILELOADER_H
17 #define QGSVECTORTILELOADER_H
18 
19 #define SIP_NO_FILE
20 
21 class QByteArray;
22 
23 #include "qgsvectortilerenderer.h"
24 #include "qgshttpheaders.h"
25 
33 {
34  public:
36  QgsVectorTileRawData( QgsTileXYZ tileID = QgsTileXYZ(), const QByteArray &raw = QByteArray() )
37  : id( tileID ), data( raw ) {}
38 
42  QByteArray data;
43 };
44 
45 
46 class QNetworkReply;
47 class QEventLoop;
48 
49 class QgsMbTiles;
50 class QgsVtpkTiles;
51 
53 
60 class QgsVectorTileLoader : public QObject
61 {
62  Q_OBJECT
63  public:
64 
66  static QList<QgsVectorTileRawData> blockingFetchTileRawData( const QString &sourceType,
67  const QString &sourcePath,
68  const QgsTileMatrix &tileMatrix,
69  const QPointF &viewCenter,
70  const QgsTileRange &range,
71  const QString &authid,
72  const QgsHttpHeaders &headers,
73  QgsFeedback *feedback = nullptr );
74 
76  static QByteArray loadFromNetwork( const QgsTileXYZ &id,
77  const QgsTileMatrix &tileMatrix,
78  const QString &requestUrl,
79  const QString &authid,
80  const QgsHttpHeaders &headers,
81  QgsFeedback *feedback = nullptr );
83  static QByteArray loadFromMBTiles( const QgsTileXYZ &id, QgsMbTiles &mbTileReader, QgsFeedback *feedback = nullptr );
84 
86  static QByteArray loadFromVtpk( const QgsTileXYZ &id, QgsVtpkTiles &vtpkTileReader );
87 
88  //
89  // non-static stuff
90  //
91 
93  QgsVectorTileLoader( const QString &uri, const QgsTileMatrix &tileMatrix, const QgsTileRange &range, const QPointF &viewCenter,
94  const QString &authid, const QgsHttpHeaders &headers, QgsFeedback *feedback );
96 
98  void downloadBlocking();
99 
101  QString error() const;
102 
103  private:
104  void loadFromNetworkAsync( const QgsTileXYZ &id, const QgsTileMatrix &tileMatrix, const QString &requestUrl );
105 
106  private slots:
107  void tileReplyFinished();
108  void canceled();
109 
110  signals:
112  void tileRequestFinished( const QgsVectorTileRawData &rawTile );
113 
114  private:
116  std::unique_ptr<QEventLoop> mEventLoop;
118  QgsFeedback *mFeedback;
119 
120  QString mAuthCfg;
121  QgsHttpHeaders mHeaders;
122 
124  QList<QgsTileDownloadManagerReply *> mReplies;
125 
126  QString mError;
127 
128 };
129 
130 #endif // QGSVECTORTILELOADER_H
qgsvectortilerenderer.h
QgsVectorTileLoader::~QgsVectorTileLoader
~QgsVectorTileLoader()
Definition: qgsvectortileloader.cpp:58
QgsTileXYZ
Stores coordinates of a tile in a tile matrix set. Tile matrix is identified by the zoomLevel(),...
Definition: qgstiles.h:37
QgsTileRange
Range of tiles in a tile matrix to be rendered. The selection is rectangular, given by start/end row ...
Definition: qgstiles.h:70
QgsVtpkTiles
Utility class for reading and writing ESRI VTPK files.
Definition: qgsvtpktiles.h:37
QgsVectorTileLoader::downloadBlocking
void downloadBlocking()
Blocks the caller until all asynchronous requests are finished (with a success or a failure)
Definition: qgsvectortileloader.cpp:70
qgshttpheaders.h
QgsTileMatrix
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition: qgstiles.h:107
QgsMbTiles
Utility class for reading and writing MBTiles files (which are SQLite3 databases).
Definition: qgsmbtiles.h:38
QgsVectorTileLoader::tileRequestFinished
void tileRequestFinished(const QgsVectorTileRawData &rawTile)
Emitted when a tile request has finished. If a tile request has failed, the returned raw tile byte ar...
QgsVectorTileLoader::loadFromMBTiles
static QByteArray loadFromMBTiles(const QgsTileXYZ &id, QgsMbTiles &mbTileReader, QgsFeedback *feedback=nullptr)
Returns raw tile data for a single tile loaded from MBTiles file.
Definition: qgsvectortileloader.cpp:243
QgsVectorTileLoader::blockingFetchTileRawData
static QList< QgsVectorTileRawData > blockingFetchTileRawData(const QString &sourceType, const QString &sourcePath, const QgsTileMatrix &tileMatrix, const QPointF &viewCenter, const QgsTileRange &range, const QString &authid, const QgsHttpHeaders &headers, QgsFeedback *feedback=nullptr)
Returns raw tile data for the specified range of tiles. Blocks the caller until all tiles are fetched...
Definition: qgsvectortileloader.cpp:175
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsVectorTileRawData::QgsVectorTileRawData
QgsVectorTileRawData(QgsTileXYZ tileID=QgsTileXYZ(), const QByteArray &raw=QByteArray())
Constructs a raw tile object.
Definition: qgsvectortileloader.h:36
QgsVectorTileLoader::error
QString error() const
Returns a eventual error that occurred during loading, void if no error.
Definition: qgsvectortileloader.cpp:168
QgsVectorTileLoader
The loader class takes care of loading raw vector tile data from a tile source.
Definition: qgsvectortileloader.h:60
QgsHttpHeaders
This class implements simple http header management.
Definition: qgshttpheaders.h:38
QgsVectorTileRawData
Keeps track of raw tile data that need to be decoded.
Definition: qgsvectortileloader.h:32
QgsVectorTileLoader::loadFromNetwork
static QByteArray loadFromNetwork(const QgsTileXYZ &id, const QgsTileMatrix &tileMatrix, const QString &requestUrl, const QString &authid, const QgsHttpHeaders &headers, QgsFeedback *feedback=nullptr)
Returns raw tile data for a single tile, doing a HTTP request. Block the caller until tile data are d...
Definition: qgsvectortileloader.cpp:220
QgsVectorTileRawData::id
QgsTileXYZ id
Tile position in tile matrix set.
Definition: qgsvectortileloader.h:40
QgsVectorTileLoader::loadFromVtpk
static QByteArray loadFromVtpk(const QgsTileXYZ &id, QgsVtpkTiles &vtpkTileReader)
Returns raw tile data for a single tile loaded from VTPK file.
Definition: qgsvectortileloader.cpp:267
QgsVectorTileLoader::QgsVectorTileLoader
QgsVectorTileLoader(const QString &uri, const QgsTileMatrix &tileMatrix, const QgsTileRange &range, const QPointF &viewCenter, const QString &authid, const QgsHttpHeaders &headers, QgsFeedback *feedback)
Constructs tile loader for doing asynchronous requests and starts network requests.
Definition: qgsvectortileloader.cpp:33
QgsTileDownloadManagerReply
Reply object for tile download manager requests returned from calls to QgsTileDownloadManager::get().
Definition: qgstiledownloadmanager.h:47
QgsVectorTileRawData::data
QByteArray data
Raw tile data.
Definition: qgsvectortileloader.h:42