QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
32 {
33  public:
35  QgsVectorTileRawData( QgsTileXYZ tileID = QgsTileXYZ(), const QByteArray &raw = QByteArray() )
36  : id( tileID ), data( raw ) {}
37 
41  QByteArray data;
42 };
43 
44 
45 class QNetworkReply;
46 class QEventLoop;
47 
48 class QgsMbTiles;
49 
56 class QgsVectorTileLoader : public QObject
57 {
58  Q_OBJECT
59  public:
60 
62  static QList<QgsVectorTileRawData> blockingFetchTileRawData( const QString &sourceType,
63  const QString &sourcePath,
64  const QgsTileMatrix &tileMatrix,
65  const QPointF &viewCenter,
66  const QgsTileRange &range,
67  const QString &authid,
68  const QString &referer );
69 
71  static QByteArray loadFromNetwork( const QgsTileXYZ &id,
72  const QgsTileMatrix &tileMatrix,
73  const QString &requestUrl,
74  const QString &authid,
75  const QString &referer );
77  static QByteArray loadFromMBTiles( const QgsTileXYZ &id, QgsMbTiles &mbTileReader );
78 
79  //
80  // non-static stuff
81  //
82 
84  QgsVectorTileLoader( const QString &uri, const QgsTileMatrix &tileMatrix, const QgsTileRange &range, const QPointF &viewCenter,
85  const QString &authid, const QString &referer, QgsFeedback *feedback );
87 
89  void downloadBlocking();
90 
91  private:
92  void loadFromNetworkAsync( const QgsTileXYZ &id, const QgsTileMatrix &tileMatrix, const QString &requestUrl );
93 
94  private slots:
95  void tileReplyFinished();
96  void canceled();
97 
98  signals:
101 
102  private:
104  std::unique_ptr<QEventLoop> mEventLoop;
106  QgsFeedback *mFeedback;
107 
108  QString mAuthCfg;
109  QString mReferer;
110 
112  QList<QNetworkReply *> mReplies;
113 
114 };
115 
116 #endif // QGSVECTORTILELOADER_H
qgsvectortilerenderer.h
QgsVectorTileLoader::~QgsVectorTileLoader
~QgsVectorTileLoader()
Definition: qgsvectortileloader.cpp:54
QgsTileXYZ
Stores coordinates of a tile in a tile matrix set.
Definition: qgstiles.h:33
QgsTileRange
Range of tiles in a tile matrix to be rendered.
Definition: qgstiles.h:66
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 QString &referer)
Returns raw tile data for the specified range of tiles. Blocks the caller until all tiles are fetched...
Definition: qgsvectortileloader.cpp:159
QgsVectorTileLoader::downloadBlocking
void downloadBlocking()
Blocks the caller until all asynchronous requests are finished (with a success or a failure)
Definition: qgsvectortileloader.cpp:66
QgsTileMatrix
Defines a matrix of tiles for a single zoom level: it is defined by its size (width * height) and map...
Definition: qgstiles.h:103
QgsMbTiles
Utility class for reading and writing MBTiles files (which are SQLite3 databases).
Definition: qgsmbtiles.h:39
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::loadFromNetwork
static QByteArray loadFromNetwork(const QgsTileXYZ &id, const QgsTileMatrix &tileMatrix, const QString &requestUrl, const QString &authid, const QString &referer)
Returns raw tile data for a single tile, doing a HTTP request. Block the caller until tile data are d...
Definition: qgsvectortileloader.cpp:185
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:35
QgsVectorTileLoader
The loader class takes care of loading raw vector tile data from a tile source.
Definition: qgsvectortileloader.h:57
QgsVectorTileLoader::loadFromMBTiles
static QByteArray loadFromMBTiles(const QgsTileXYZ &id, QgsMbTiles &mbTileReader)
Returns raw tile data for a single tile loaded from MBTiles file.
Definition: qgsvectortileloader.cpp:209
QgsVectorTileLoader::QgsVectorTileLoader
QgsVectorTileLoader(const QString &uri, const QgsTileMatrix &tileMatrix, const QgsTileRange &range, const QPointF &viewCenter, const QString &authid, const QString &referer, QgsFeedback *feedback)
Constructs tile loader for doing asynchronous requests and starts network requests.
Definition: qgsvectortileloader.cpp:29
QgsVectorTileRawData
Keeps track of raw tile data that need to be decoded.
Definition: qgsvectortileloader.h:32
QgsVectorTileRawData::id
QgsTileXYZ id
Tile position in tile matrix set.
Definition: qgsvectortileloader.h:39
QgsVectorTileRawData::data
QByteArray data
Raw tile data.
Definition: qgsvectortileloader.h:41