QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
97 
98  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
99 
100  bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
101 
102  bool readSymbology( const QDomNode &node, QString &errorMessage,
103  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
104 
105  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
106  StyleCategories categories = AllStyleCategories ) const override;
107 
108  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
109  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
110 
122  bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
123 
124  QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
125 
126  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
127  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
128  QString htmlMetadata() const override;
129 
130  // new methods
131 
133  QString sourceType() const { return mSourceType; }
135  QString sourcePath() const { return mSourcePath; }
136 
138  int sourceMinZoom() const { return mSourceMinZoom; }
140  int sourceMaxZoom() const { return mSourceMaxZoom; }
141 
149  QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
150 
155  void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
157  QgsVectorTileRenderer *renderer() const;
158 
163  void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
165  QgsVectorTileLabeling *labeling() const;
166 
168  void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
170  bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
171 
172  private:
173  bool loadDataSource();
174 
175  private:
177  QString mSourceType;
179  QString mSourcePath;
181  int mSourceMinZoom = -1;
183  int mSourceMaxZoom = -1;
184 
186  std::unique_ptr<QgsVectorTileRenderer> mRenderer;
188  std::unique_ptr<QgsVectorTileLabeling> mLabeling;
190  bool mTileBorderRendering = false;
191 
192  QVariantMap mArcgisLayerConfiguration;
193 
194  bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
195 };
196 
197 
198 #endif // QGSVECTORTILELAYER_H
QgsDataSourceUri
Class for storing the component parts of a RDBMS data source URI (e.g.
Definition: qgsdatasourceuri.h:36
QgsVectorTileLayer
Implements a map layer that is dedicated to rendering of vector tiles.
Definition: qgsvectortilelayer.h:84
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
QgsTileXYZ
Stores coordinates of a tile in a tile matrix set.
Definition: qgstiles.h:33
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsVectorTileLayer::~QgsVectorTileLayer
~QgsVectorTileLayer() override
FINAL
#define FINAL
Definition: qgis_sip.h:228
QgsVectorTileLayer::isTileBorderRenderingEnabled
bool isTileBorderRenderingEnabled() const
Returns whether to render also borders of tiles (useful for debugging)
Definition: qgsvectortilelayer.h:170
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:51
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:135
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsVectorTileLayer::setTileBorderRenderingEnabled
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render also borders of tiles (useful for debugging)
Definition: qgsvectortilelayer.h:168
QgsVectorTileRenderer
Abstract base class for all vector tile renderer implementations.
Definition: qgsvectortilerenderer.h:89
qgsmaplayer.h
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsVectorTileLayer::sourceMaxZoom
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:140
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsVectorTileLabeling
Base class for labeling configuration classes for vector tile layers.
Definition: qgsvectortilelabeling.h:71
QgsVectorTileLayer::sourceMinZoom
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:138