QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsvectortilelayer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectortilelayer.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 QGSVECTORTILELAYER_H
17 #define QGSVECTORTILELAYER_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 
22 #include "qgsmaplayer.h"
23 
26 
27 class QgsTileXYZ;
28 
83 class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
84 {
85  Q_OBJECT
86 
87  public:
89  explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString() );
90  ~QgsVectorTileLayer() override;
91 
92  // implementation of virtual functions from QgsMapLayer
93 
94  QgsVectorTileLayer *clone() const override SIP_FACTORY;
95 
96  virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
97 
98  virtual bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
99 
100  virtual bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
101 
102  virtual bool readSymbology( const QDomNode &node, QString &errorMessage,
103  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
104 
105  virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
106  StyleCategories categories = AllStyleCategories ) const override;
107 
108  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
109 
110  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
111  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
112 
113  // new methods
114 
116  QString sourceType() const { return mSourceType; }
118  QString sourcePath() const { return mSourcePath; }
119 
121  int sourceMinZoom() const { return mSourceMinZoom; }
123  int sourceMaxZoom() const { return mSourceMaxZoom; }
124 
132  QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
133 
138  void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
140  QgsVectorTileRenderer *renderer() const;
141 
146  void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
148  QgsVectorTileLabeling *labeling() const;
149 
151  void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
153  bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
154 
155  private:
156  bool loadDataSource();
157 
158  private:
160  QString mSourceType;
162  QString mSourcePath;
164  int mSourceMinZoom = -1;
166  int mSourceMaxZoom = -1;
167 
169  std::unique_ptr<QgsVectorTileRenderer> mRenderer;
171  std::unique_ptr<QgsVectorTileLabeling> mLabeling;
173  bool mTileBorderRendering = false;
174 };
175 
176 
177 #endif // QGSVECTORTILELAYER_H
QgsVectorTileLayer
Definition: qgsvectortilelayer.h:83
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsMapLayer::writeXml
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by children to write state specific to them to project files.
Definition: qgsmaplayer.cpp:596
QgsVectorTileLayer::sourceType
QString sourceType() const
Returns type of the data source.
Definition: qgsvectortilelayer.h:116
QgsTileXYZ
Definition: qgstiles.h:32
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsRenderContext
Definition: qgsrendercontext.h:57
FINAL
#define FINAL
Definition: qgis_sip.h:223
QgsVectorTileLayer::isTileBorderRenderingEnabled
bool isTileBorderRenderingEnabled() const
Returns whether to render also borders of tiles (useful for debugging)
Definition: qgsvectortilelayer.h:153
QgsMapLayerRenderer
Definition: qgsmaplayerrenderer.h:50
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsVectorTileLayer::sourcePath
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type)
Definition: qgsvectortilelayer.h:118
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMapLayer::encodedSource
virtual QString encodedSource(const QString &source, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
Definition: qgsmaplayer.cpp:606
QgsVectorTileLayer::setTileBorderRenderingEnabled
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render also borders of tiles (useful for debugging)
Definition: qgsvectortilelayer.h:151
QgsVectorTileRenderer
Definition: qgsvectortilerenderer.h:88
qgsmaplayer.h
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsMapLayer::decodedSource
virtual QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
Definition: qgsmaplayer.cpp:612
QgsMapLayer::setTransformContext
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
QgsMapLayer::readSymbology
virtual bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)=0
Read the symbology for the current layer from the DOM node supplied.
QgsVectorTileLayer::sourceMaxZoom
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:123
QgsMapLayer::writeSymbology
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const =0
Write the style for the layer into the docment provided.
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsMapLayer::readXml
virtual bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context)
Called by readLayerXML(), used by children to read state specific to them from project files.
Definition: qgsmaplayer.cpp:381
QgsVectorTileLabeling
Definition: qgsvectortilelabeling.h:57
QgsVectorTileLayer::sourceMinZoom
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:121
QgsMapLayer::createMapRenderer
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.