QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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#include "qgsmaplayer.h"
23#include "qgsfeatureid.h"
24
27class QgsFeature;
28class QgsGeometry;
31
86class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
87{
88 Q_OBJECT
89
90 public:
91
92
99 {
100
105 : transformContext( transformContext )
106 {}
107
110 };
111
113 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
115
116#ifdef SIP_RUN
117 SIP_PYOBJECT __repr__();
118 % MethodCode
119 QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
120 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
121 % End
122#endif
123
124 // implementation of virtual functions from QgsMapLayer
125
126 QgsVectorTileLayer *clone() const override SIP_FACTORY;
127 QgsDataProvider *dataProvider() override;
128 const QgsDataProvider *dataProvider() const override SIP_SKIP;
129 QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
130 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
131 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
132 bool readSymbology( const QDomNode &node, QString &errorMessage,
133 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
134 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
135 StyleCategories categories = AllStyleCategories ) const override;
136 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
137 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
138 Qgis::MapLayerProperties properties() const override;
139
151 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
152
167 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
168
169 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
170
171 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
172 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
173 QString htmlMetadata() const override;
174
175 // new methods
176
182 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
183
185 QString sourceType() const { return mSourceType; }
187 QString sourcePath() const;
188
190 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
192 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
193
201 QgsVectorTileRawData getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
202
207 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
209 QgsVectorTileRenderer *renderer() const;
210
215 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
217 QgsVectorTileLabeling *labeling() const;
218
226 bool labelsEnabled() const;
227
238 void setLabelsEnabled( bool enabled );
239
241 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
243 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
244
254 QList< QgsFeature > selectedFeatures() const;
255
265 int selectedFeatureCount() const;
266
278 void selectByGeometry( const QgsGeometry &geometry, const QgsSelectionContext &context,
282 QgsRenderContext *renderContext = nullptr );
283
284 public slots:
285
293 void removeSelection();
294
295 signals:
296
303
304 private:
305 bool loadDataSource();
306
307 private:
309 QString mSourceType;
310
311 QgsVectorTileMatrixSet mMatrixSet;
312
314 std::unique_ptr<QgsVectorTileRenderer> mRenderer;
316 std::unique_ptr<QgsVectorTileLabeling> mLabeling;
318 bool mLabelsEnabled = true;
320 bool mTileBorderRendering = false;
321
322 QgsCoordinateTransformContext mTransformContext;
323
324 std::unique_ptr< QgsDataProvider > mDataProvider;
325
326 QHash< QgsFeatureId, QgsFeature > mSelectedFeatures;
327
328 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
329 const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags ) override;
330
331 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
332
333};
334
335#endif // QGSVECTORTILELAYER_H
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:54
QFlags< SelectionFlag > SelectionFlags
Flags which control feature selection behavior.
Definition: qgis.h:1394
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition: qgis.h:1372
@ Intersect
Select where features intersect the reference geometry.
SelectBehavior
Specifies how a selection should be applied.
Definition: qgis.h:1358
@ SetSelection
Set selection, removing any existing selection.
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
QFlags< ReadFlag > ReadFlags
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:75
QFlags< StyleCategory > StyleCategories
Definition: qgsmaplayer.h:188
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.
Contains information about the context of a rendering operation.
Encapsulates the context of a layer selection 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)
void selectionChanged()
Emitted whenever the selected features in the layer are changed.
Encapsulates properties of a vector tile matrix set, including tile origins and scaling information.
Keeps track of raw tile data that need to be decoded.
Abstract base class for all vector tile renderer implementations.
#define str(x)
Definition: qgis.cpp:38
#define SIP_SKIP
Definition: qgis_sip.h:126
#define FINAL
Definition: qgis_sip.h:242
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_TRANSFERBACK
Definition: qgis_sip.h:48
#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.