Branch data Line data Source code
1 : : /*************************************************************************** 2 : : qgsvectortilelayerrenderer.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 QGSVECTORTILELAYERRENDERER_H 17 : : #define QGSVECTORTILELAYERRENDERER_H 18 : : 19 : : #define SIP_NO_FILE 20 : : 21 : : #include "qgsmaplayerrenderer.h" 22 : : 23 : : class QgsVectorTileLayer; 24 : : class QgsVectorTileRawData; 25 : : class QgsVectorTileLabelProvider; 26 : : 27 : : #include "qgsvectortilerenderer.h" 28 : : #include "qgsmapclippingregion.h" 29 : : 30 : : /** 31 : : * \ingroup core 32 : : * \brief This class provides map rendering functionality for vector tile layers. 33 : : * In render() function (assumed to be run in a worker thread) it will: 34 : : * 35 : : * # fetch vector tiles using QgsVectorTileLoader 36 : : * # decode raw tiles into QgsFeature objects using QgsVectorTileDecoder 37 : : * # render tiles using a class derived from QgsVectorTileRenderer 38 : : * 39 : : * \since QGIS 3.14 40 : : */ 41 : 0 : class QgsVectorTileLayerRenderer : public QgsMapLayerRenderer 42 : : { 43 : : public: 44 : : //! Creates the renderer. Always called from main thread, should copy whatever necessary from the layer 45 : : QgsVectorTileLayerRenderer( QgsVectorTileLayer *layer, QgsRenderContext &context ); 46 : : 47 : : virtual bool render() override; 48 : 0 : virtual QgsFeedback *feedback() const override { return mFeedback.get(); } 49 : : bool forceRasterRender() const override; 50 : : 51 : : private: 52 : : void decodeAndDrawTile( const QgsVectorTileRawData &rawTile ); 53 : : 54 : : // data coming from the vector tile layer 55 : : 56 : : //! Type of the source from which we will be loading tiles (e.g. "xyz" or "mbtiles") 57 : : QString mSourceType; 58 : : //! Path/URL of the source. Format depends on source type 59 : : QString mSourcePath; 60 : : 61 : : QString mAuthCfg; 62 : : QString mReferer; 63 : : 64 : : //! Minimum zoom level at which source has any valid tiles (negative = unconstrained) 65 : : int mSourceMinZoom = -1; 66 : : //! Maximum zoom level at which source has any valid tiles (negative = unconstrained) 67 : : int mSourceMaxZoom = -1; 68 : : //! Tile renderer object to do rendering of individual tiles 69 : : std::unique_ptr<QgsVectorTileRenderer> mRenderer; 70 : : 71 : : /** 72 : : * Label provider that handles registration of labels. 73 : : * No need to delete: if exists it is owned by labeling engine. 74 : : */ 75 : : QgsVectorTileLabelProvider *mLabelProvider = nullptr; 76 : : 77 : : //! Whether to draw boundaries of tiles (useful for debugging) 78 : : bool mDrawTileBoundaries = false; 79 : : 80 : : // temporary data used during rendering process 81 : : 82 : : //! Feedback object that may be used by the caller to cancel the rendering 83 : : std::unique_ptr<QgsFeedback> mFeedback; 84 : : //! Zoom level at which we will be rendering 85 : : int mTileZoom = 0; 86 : : //! Definition of the tile matrix for our zoom level 87 : : QgsTileMatrix mTileMatrix; 88 : : //!< Block of tiles we will be rendering in that zoom level 89 : : QgsTileRange mTileRange; 90 : : //! Cached QgsFields object for each sub-layer that will be rendered 91 : : QMap<QString, QgsFields> mPerLayerFields; 92 : : 93 : : //! Cached list of layers required for renderer and labeling 94 : : QSet< QString > mRequiredLayers; 95 : : 96 : : //! Counter of total elapsed time to decode tiles (ms) 97 : : int mTotalDecodeTime = 0; 98 : : //! Counter of total elapsed time to render tiles (ms) 99 : : int mTotalDrawTime = 0; 100 : : 101 : : QList< QgsMapClippingRegion > mClippingRegions; 102 : : double mLayerOpacity = 1.0; 103 : : }; 104 : : 105 : : 106 : : #endif // QGSVECTORTILELAYERRENDERER_H