QGIS API Documentation  3.17.0-Master (a035f434f4)
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 #ifdef SIP_RUN
93  SIP_PYOBJECT __repr__();
94  % MethodCode
95  QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
96  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
97  % End
98 #endif
99 
100  // implementation of virtual functions from QgsMapLayer
101 
102  QgsVectorTileLayer *clone() const override SIP_FACTORY;
103 
105 
106  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
107 
108  bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
109 
110  bool readSymbology( const QDomNode &node, QString &errorMessage,
111  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
112 
113  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
114  StyleCategories categories = AllStyleCategories ) const override;
115 
116  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
117  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
118 
130  bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
131 
132  QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
133 
134  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
135  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
136  QString htmlMetadata() const override;
137 
138  // new methods
139 
141  QString sourceType() const { return mSourceType; }
143  QString sourcePath() const { return mSourcePath; }
144 
146  int sourceMinZoom() const { return mSourceMinZoom; }
148  int sourceMaxZoom() const { return mSourceMaxZoom; }
149 
157  QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
158 
163  void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
165  QgsVectorTileRenderer *renderer() const;
166 
171  void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
173  QgsVectorTileLabeling *labeling() const;
174 
176  void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
178  bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
179 
180  private:
181  bool loadDataSource();
182 
183  private:
185  QString mSourceType;
187  QString mSourcePath;
189  int mSourceMinZoom = -1;
191  int mSourceMaxZoom = -1;
192 
194  std::unique_ptr<QgsVectorTileRenderer> mRenderer;
196  std::unique_ptr<QgsVectorTileLabeling> mLabeling;
198  bool mTileBorderRendering = false;
199 
200  QVariantMap mArcgisLayerConfiguration;
201 
202  bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
203 };
204 
205 
206 #endif // QGSVECTORTILELAYER_H
The class is used as a container of context for various read/write operations on other objects...
Base class for all map layer types.
Definition: qgsmaplayer.h:83
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QString sourceType() const
Returns type of the data source.
Implements a map layer that is dedicated to rendering of vector tiles.
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...
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained) ...
virtual QString encodedSource(const QString &source, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by derived classes to encode provider&#39;s specific data source to proje...
bool isTileBorderRenderingEnabled() const
Returns whether to render also borders of tiles (useful for debugging)
virtual QString htmlMetadata() const
Obtain a formatted HTML string containing assorted metadata for this layer.
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type)
virtual QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const
Called by readLayerXML(), used by derived classes to decode provider&#39;s specific data source from proj...
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained) ...
Contains information about the context in which a coordinate transform is executed.
Abstract base class for all vector tile renderer implementations.
virtual bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context)
Called by readLayerXML(), used by children to read state specific to them from project files...
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
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.
Base class for labeling configuration classes for vector tile layers.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Contains information about the context of a rendering operation.
#define FINAL
Definition: qgis_sip.h:228
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.
#define SIP_OUT
Definition: qgis_sip.h:58
Base class for utility classes that encapsulate information necessary for rendering of map layers...
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
virtual QString loadDefaultMetadata(bool &resultFlag)
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a rec...
Class for storing the component parts of a RDBMS data source URI (e.g.
Stores coordinates of a tile in a tile matrix set.
Definition: qgstiles.h:32
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render also borders of tiles (useful for debugging)