QGIS API Documentation 3.99.0-Master (26c88405ac0)
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 "qgsfeatureid.h"
22#include "qgsmaplayer.h"
24
27class QgsFeature;
28class QgsGeometry;
31
89class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
90{
91 Q_OBJECT
92
93 public:
94
95
114
116 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
118
119#ifdef SIP_RUN
120 SIP_PYOBJECT __repr__();
121 % MethodCode
122 QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
123 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
124 % End
125#endif
126
127 // implementation of virtual functions from QgsMapLayer
128
129 QgsVectorTileLayer *clone() const override SIP_FACTORY;
130 QgsDataProvider *dataProvider() override;
131 const QgsDataProvider *dataProvider() const override SIP_SKIP;
133 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
134 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
135 bool readSymbology( const QDomNode &node, QString &errorMessage,
136 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
137 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
138 StyleCategories categories = AllStyleCategories ) const override;
140 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
141 Qgis::MapLayerProperties properties() const override;
142
154 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
155
170 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
171
172 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
173
174 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const final;
175 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const final;
176 QString htmlMetadata() const override;
177
178 // new methods
179
185 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
186
188 QString sourceType() const { return mSourceType; }
190 QString sourcePath() const;
191
193 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
195 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
196
204 QgsVectorTileRawData getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
205
210 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
212 QgsVectorTileRenderer *renderer() const;
213
218 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
220 QgsVectorTileLabeling *labeling() const;
221
229 bool labelsEnabled() const;
230
241 void setLabelsEnabled( bool enabled );
242
244 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
246 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
247
257 QList< QgsFeature > selectedFeatures() const;
258
268 int selectedFeatureCount() const;
269
281 void selectByGeometry( const QgsGeometry &geometry, const QgsSelectionContext &context,
285 QgsRenderContext *renderContext = nullptr );
286
287 public slots:
288
296 void removeSelection();
297
298 signals:
299
306
307 private:
308 bool loadDataSource();
309
310 private:
312 QString mSourceType;
313
314 QgsVectorTileMatrixSet mMatrixSet;
315
317 std::unique_ptr<QgsVectorTileRenderer> mRenderer;
319 std::unique_ptr<QgsVectorTileLabeling> mLabeling;
321 bool mLabelsEnabled = true;
323 bool mTileBorderRendering = false;
324
325 QgsCoordinateTransformContext mTransformContext;
326
327 std::unique_ptr< QgsDataProvider > mDataProvider;
328
329 QHash< QgsFeatureId, QgsFeature > mSelectedFeatures;
330
331 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
333
334 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
335
336};
337
338#endif // QGSVECTORTILELAYER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
QFlags< SelectionFlag > SelectionFlags
Flags which control feature selection behavior.
Definition qgis.h:1807
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:486
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition qgis.h:1785
@ Intersect
Select where features intersect the reference geometry.
Definition qgis.h:1786
SelectBehavior
Specifies how a selection should be applied.
Definition qgis.h:1771
@ SetSelection
Set selection, removing any existing selection.
Definition qgis.h:1772
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.
QString source() const
Returns the source for the layer.
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QFlags< StyleCategory > StyleCategories
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
virtual QgsError error() const
Gets current status error.
QgsMapLayer::LayerFlags flags
Definition qgsmaplayer.h:96
virtual QStringList subLayers() const
Returns the sublayers of this layer.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
A container for the context for various read/write operations on 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:39
Base class for labeling configuration classes for vector tile layers.
void setTileBorderRenderingEnabled(bool enabled)
Sets whether to render also borders of tiles (useful for debugging).
QgsVectorTileLayer(const QString &path=QString(), const QString &baseName=QString(), const QgsVectorTileLayer::LayerOptions &options=QgsVectorTileLayer::LayerOptions())
Constructs a new vector tile layer.
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const override
Write the style for the layer into the document provided.
bool loadDefaultStyleAndSubLayers(QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers)
Loads the default style for the layer, and returns true if the style was successfully loaded.
QString sourceType() const
Returns type of the data source.
bool writeXml(QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const final
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
~QgsVectorTileLayer() override
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
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).
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QString loadDefaultStyle(bool &resultFlag) override
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const final
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
Qgis::MapLayerProperties properties() const override
Returns the map layer properties of this layer.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained).
QgsDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
QString loadDefaultMetadata(bool &resultFlag) override
Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a rec...
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
QgsVectorTileMatrixSet & tileMatrixSet()
Returns the vector tile matrix set.
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:134
#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:84
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.