QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 #include "qgsvectortilematrixset.h"
24 
27 
28 class QgsTileXYZ;
29 
84 class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
85 {
86  Q_OBJECT
87 
88  public:
89 
90 
96  struct LayerOptions
97  {
98 
103  : transformContext( transformContext )
104  {}
105 
108  };
109 
111  explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
113 
114 #ifdef SIP_RUN
115  SIP_PYOBJECT __repr__();
116  % MethodCode
117  QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
118  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
119  % End
120 #endif
121 
122  // implementation of virtual functions from QgsMapLayer
123 
124  QgsVectorTileLayer *clone() const override SIP_FACTORY;
125  QgsDataProvider *dataProvider() override;
126  const QgsDataProvider *dataProvider() const override SIP_SKIP;
127  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
128  bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
129  bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
130  bool readSymbology( const QDomNode &node, QString &errorMessage,
131  QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
132  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
133  StyleCategories categories = AllStyleCategories ) const override;
134  void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
135  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
136 
148  bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
149 
150  QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
151 
152  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
153  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
154  QString htmlMetadata() const override;
155 
156  // new methods
157 
163  QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
164 
166  QString sourceType() const { return mSourceType; }
168  QString sourcePath() const { return mSourcePath; }
169 
171  int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
173  int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
174 
182  QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
183 
188  void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
190  QgsVectorTileRenderer *renderer() const;
191 
196  void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
198  QgsVectorTileLabeling *labeling() const;
199 
201  void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
203  bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
204 
205  private:
206  bool loadDataSource();
207 
208  private:
210  QString mSourceType;
212  QString mSourcePath;
213 
214  QgsVectorTileMatrixSet mMatrixSet;
215 
217  std::unique_ptr<QgsVectorTileRenderer> mRenderer;
219  std::unique_ptr<QgsVectorTileLabeling> mLabeling;
221  bool mTileBorderRendering = false;
222 
223  QVariantMap mArcgisLayerConfiguration;
224 
225  QgsCoordinateTransformContext mTransformContext;
226 
227  std::unique_ptr< QgsDataProvider > mDataProvider;
228 
229  bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
230 
231  void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
232  const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags ) override;
233 
234 };
235 
236 #ifndef SIP_RUN
238 
244 class QgsVectorTileDataProvider : public QgsDataProvider
245 {
246  Q_OBJECT
247 
248  public:
249  QgsVectorTileDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
250  QgsDataProvider::ReadFlags flags );
251  QgsCoordinateReferenceSystem crs() const override;
252  QString name() const override;
253  QString description() const override;
254  QgsRectangle extent() const override;
255  bool isValid() const override;
256 
257 };
259 #endif
260 
261 
262 #endif // QGSVECTORTILELAYER_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
virtual QString name() const =0
Returns a provider name.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QString description() const =0
Returns description.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
Class for storing the component parts of a RDBMS data source URI (e.g.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
Stores coordinates of a tile in a tile matrix set.
Definition: qgstiles.h:38
Base class for labeling configuration classes for vector tile layers.
Implements a map layer that is dedicated to rendering of vector tiles.
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render also borders of tiles (useful for debugging)
QString sourceType() const
Returns type of the data source.
~QgsVectorTileLayer() override
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained)
bool isTileBorderRenderingEnabled() const
Returns whether to render also borders of tiles (useful for debugging)
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained)
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type)
Encapsulates properties of a vector tile matrix set, including tile origins and scaling information.
Abstract base class for all vector tile renderer implementations.
#define str(x)
Definition: qgis.cpp:37
#define SIP_SKIP
Definition: qgis_sip.h:126
#define FINAL
Definition: qgis_sip.h:228
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
Setting options for creating vector data providers.
Setting options for loading vector tile layers.
LayerOptions(const QgsCoordinateTransformContext &transformContext=QgsCoordinateTransformContext())
Constructor for LayerOptions with optional transformContext.
QgsCoordinateTransformContext transformContext
Coordinate transform context.