QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
87class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
88{
89 Q_OBJECT
90
91 public:
92
93
100 {
101
106 : transformContext( transformContext )
107 {}
108
111 };
112
114 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
116
117#ifdef SIP_RUN
118 SIP_PYOBJECT __repr__();
119 % MethodCode
120 QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
121 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
122 % End
123#endif
124
125 // implementation of virtual functions from QgsMapLayer
126
127 QgsVectorTileLayer *clone() const override SIP_FACTORY;
128 QgsDataProvider *dataProvider() override;
129 const QgsDataProvider *dataProvider() const override SIP_SKIP;
130 QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
131 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
132 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
133 bool readSymbology( const QDomNode &node, QString &errorMessage,
134 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
135 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
136 StyleCategories categories = AllStyleCategories ) const override;
137 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
138 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
139 Qgis::MapLayerProperties properties() const override;
140
152 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
153
168 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
169
170 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
171
172 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
173 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
174 QString htmlMetadata() const override;
175
176 // new methods
177
183 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
184
186 QString sourceType() const { return mSourceType; }
188 QString sourcePath() const;
189
191 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
193 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
194
202 QgsVectorTileRawData getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
203
208 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
210 QgsVectorTileRenderer *renderer() const;
211
216 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
218 QgsVectorTileLabeling *labeling() const;
219
227 bool labelsEnabled() const;
228
239 void setLabelsEnabled( bool enabled );
240
242 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
244 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
245
255 QList< QgsFeature > selectedFeatures() const;
256
266 int selectedFeatureCount() const;
267
279 void selectByGeometry( const QgsGeometry &geometry, const QgsSelectionContext &context,
283 QgsRenderContext *renderContext = nullptr );
284
285 public slots:
286
294 void removeSelection();
295
296 signals:
297
304
305 private:
306 bool loadDataSource();
307
308 private:
310 QString mSourceType;
311
312 QgsVectorTileMatrixSet mMatrixSet;
313
315 std::unique_ptr<QgsVectorTileRenderer> mRenderer;
317 std::unique_ptr<QgsVectorTileLabeling> mLabeling;
319 bool mLabelsEnabled = true;
321 bool mTileBorderRendering = false;
322
323 QgsCoordinateTransformContext mTransformContext;
324
325 std::unique_ptr< QgsDataProvider > mDataProvider;
326
327 QHash< QgsFeatureId, QgsFeature > mSelectedFeatures;
328
329 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
330 const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) override;
331
332 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
333
334};
335
336#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:1699
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition qgis.h:1677
@ Intersect
Select where features intersect the reference geometry.
SelectBehavior
Specifies how a selection should be applied.
Definition qgis.h:1663
@ 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.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition qgsmaplayer.h:76
QFlags< StyleCategory > StyleCategories
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:40
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 from one or more sources that need to be decoded.
Abstract base class for all vector tile renderer implementations.
#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.