QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
51 
58 class QgsVectorTileLoader : public QObject
59 {
60  Q_OBJECT
61  public:
62 
64  static QList<QgsVectorTileRawData> blockingFetchTileRawData( const QString &sourceType,
65  const QString &sourcePath,
66  const QgsTileMatrix &tileMatrix,
67  const QPointF &viewCenter,
68  const QgsTileRange &range,
69  const QString &authid,
70  const QString &referer );
71 
73  static QByteArray loadFromNetwork( const QgsTileXYZ &id,
74  const QgsTileMatrix &tileMatrix,
75  const QString &requestUrl,
76  const QString &authid,
77  const QString &referer );
79  static QByteArray loadFromMBTiles( const QgsTileXYZ &id, QgsMbTiles &mbTileReader );
80 
81  //
82  // non-static stuff
83  //
84 
86  QgsVectorTileLoader( const QString &uri, const QgsTileMatrix &tileMatrix, const QgsTileRange &range, const QPointF &viewCenter,
87  const QString &authid, const QString &referer, QgsFeedback *feedback );
89 
91  void downloadBlocking();
92 
93  private:
94  void loadFromNetworkAsync( const QgsTileXYZ &id, const QgsTileMatrix &tileMatrix, const QString &requestUrl );
95 
96  private slots:
97  void tileReplyFinished();
98  void canceled();
99 
100  signals:
103 
104  private:
106  std::unique_ptr<QEventLoop> mEventLoop;
108  QgsFeedback *mFeedback;
109 
110  QString mAuthCfg;
111  QString mReferer;
112 
114  QList<QgsTileDownloadManagerReply *> mReplies;
115 
116 };
117 
118 #endif // QGSVECTORTILELOADER_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Utility class for reading and writing MBTiles files (which are SQLite3 databases).
Definition: qgsmbtiles.h:39
Reply object for tile download manager requests returned from calls to QgsTileDownloadManager::get().
Defines a matrix of tiles for a single zoom level: it is defined by its size (width *.
Definition: qgstiles.h:103
Range of tiles in a tile matrix to be rendered.
Definition: qgstiles.h:66
Stores coordinates of a tile in a tile matrix set.
Definition: qgstiles.h:33
The loader class takes care of loading raw vector tile data from a tile source.
void tileRequestFinished(const QgsVectorTileRawData &rawTile)
Emitted when a tile request has finished. If a tile request has failed, the returned raw tile byte ar...
static QByteArray loadFromMBTiles(const QgsTileXYZ &id, QgsMbTiles &mbTileReader)
Returns raw tile data for a single tile loaded from MBTiles file.
void downloadBlocking()
Blocks the caller until all asynchronous requests are finished (with a success or a failure)
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...
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...
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.
Keeps track of raw tile data that need to be decoded.
QgsVectorTileRawData(QgsTileXYZ tileID=QgsTileXYZ(), const QByteArray &raw=QByteArray())
Constructs a raw tile object.
QByteArray data
Raw tile data.
QgsTileXYZ id
Tile position in tile matrix set.