QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
115
117 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
119
120#ifdef SIP_RUN
121 // clang-format off
122 SIP_PYOBJECT __repr__();
123 % MethodCode
124 QString str = u"<QgsVectorTileLayer: '%1'>"_s.arg( sipCpp->name() );
125 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
126 % End
127// clang-format on
128#endif
129
130 // implementation of virtual functions from QgsMapLayer
131
132 QgsVectorTileLayer *clone() const override SIP_FACTORY;
133 QgsDataProvider *dataProvider() override;
134 const QgsDataProvider *dataProvider() const override SIP_SKIP;
136 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
137 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
138 bool readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
139 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) const override;
141 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
142 Qgis::MapLayerProperties properties() const override;
143
155 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
156
171 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
172
173 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
174
175 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const final;
176 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const final;
177 QString htmlMetadata() const override;
178
179 // new methods
180
186 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
187
189 QString sourceType() const { return mSourceType; }
191 QString sourcePath() const;
192
194 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
196 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
197
205 QgsVectorTileRawData getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
206
211 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
213 QgsVectorTileRenderer *renderer() const;
214
219 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
221 QgsVectorTileLabeling *labeling() const;
222
230 bool labelsEnabled() const;
231
242 void setLabelsEnabled( bool enabled );
243
245 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
247 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
248
258 QList< QgsFeature > selectedFeatures() const;
259
269 int selectedFeatureCount() const;
270
282 void selectByGeometry(
283 const QgsGeometry &geometry,
284 const QgsSelectionContext &context,
288 QgsRenderContext *renderContext = nullptr
289 );
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, const QgsDataProvider::ProviderOptions &options, Qgis::DataProviderReadFlags flags ) override;
336
337 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
338};
339
340#endif // QGSVECTORTILELAYER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
QFlags< SelectionFlag > SelectionFlags
Flags which control feature selection behavior.
Definition qgis.h:1886
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition qgis.h:1864
@ Intersect
Select where features intersect the reference geometry.
Definition qgis.h:1865
SelectBehavior
Specifies how a selection should be applied.
Definition qgis.h:1850
@ SetSelection
Set selection, removing any existing selection.
Definition qgis.h:1851
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:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47
#define SIP_FACTORY
Definition qgis_sip.h:83
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.