QGIS API Documentation 3.99.0-Master (d270888f95f)
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
25#include <QString>
26
27using namespace Qt::StringLiterals;
28
31class QgsFeature;
32class QgsGeometry;
35
93class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
94{
95 Q_OBJECT
96
97 public:
98
99
118
120 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
122
123#ifdef SIP_RUN
124 SIP_PYOBJECT __repr__();
125 % MethodCode
126 QString str = u"<QgsVectorTileLayer: '%1'>"_s.arg( sipCpp->name() );
127 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
128 % End
129#endif
130
131 // implementation of virtual functions from QgsMapLayer
132
133 QgsVectorTileLayer *clone() const override SIP_FACTORY;
134 QgsDataProvider *dataProvider() override;
135 const QgsDataProvider *dataProvider() const override SIP_SKIP;
137 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
138 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
139 bool readSymbology( const QDomNode &node, QString &errorMessage,
140 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
141 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
142 StyleCategories categories = AllStyleCategories ) const override;
144 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
145 Qgis::MapLayerProperties properties() const override;
146
158 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
159
174 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
175
176 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
177
178 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const final;
179 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const final;
180 QString htmlMetadata() const override;
181
182 // new methods
183
189 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
190
192 QString sourceType() const { return mSourceType; }
194 QString sourcePath() const;
195
197 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
199 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
200
208 QgsVectorTileRawData getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
209
214 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
216 QgsVectorTileRenderer *renderer() const;
217
222 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
224 QgsVectorTileLabeling *labeling() const;
225
233 bool labelsEnabled() const;
234
245 void setLabelsEnabled( bool enabled );
246
248 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
250 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
251
261 QList< QgsFeature > selectedFeatures() const;
262
272 int selectedFeatureCount() const;
273
285 void selectByGeometry( const QgsGeometry &geometry, const QgsSelectionContext &context,
289 QgsRenderContext *renderContext = nullptr );
290
291 public slots:
292
300 void removeSelection();
301
302 signals:
303
310
311 private:
312 bool loadDataSource();
313
314 private:
316 QString mSourceType;
317
318 QgsVectorTileMatrixSet mMatrixSet;
319
321 std::unique_ptr<QgsVectorTileRenderer> mRenderer;
323 std::unique_ptr<QgsVectorTileLabeling> mLabeling;
325 bool mLabelsEnabled = true;
327 bool mTileBorderRendering = false;
328
329 QgsCoordinateTransformContext mTransformContext;
330
331 std::unique_ptr< QgsDataProvider > mDataProvider;
332
333 QHash< QgsFeatureId, QgsFeature > mSelectedFeatures;
334
335 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
337
338 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
339
340};
341
342#endif // QGSVECTORTILELAYER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
QFlags< SelectionFlag > SelectionFlags
Flags which control feature selection behavior.
Definition qgis.h:1865
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:505
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition qgis.h:1843
@ Intersect
Select where features intersect the reference geometry.
Definition qgis.h:1844
SelectBehavior
Specifies how a selection should be applied.
Definition qgis.h:1829
@ SetSelection
Set selection, removing any existing selection.
Definition qgis.h:1830
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:60
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:99
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:43
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.