QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
22#include "qgsmaplayer.h"
24#include "qgsfeatureid.h"
25
28
29class QgsTileXYZ;
30class QgsFeature;
31class QgsGeometry;
33
88class CORE_EXPORT QgsVectorTileLayer : public QgsMapLayer
89{
90 Q_OBJECT
91
92 public:
93
94
101 {
102
107 : transformContext( transformContext )
108 {}
109
112 };
113
115 explicit QgsVectorTileLayer( const QString &path = QString(), const QString &baseName = QString(), const QgsVectorTileLayer::LayerOptions &options = QgsVectorTileLayer::LayerOptions() );
117
118#ifdef SIP_RUN
119 SIP_PYOBJECT __repr__();
120 % MethodCode
121 QString str = QStringLiteral( "<QgsVectorTileLayer: '%1'>" ).arg( sipCpp->name() );
122 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
123 % End
124#endif
125
126 // implementation of virtual functions from QgsMapLayer
127
128 QgsVectorTileLayer *clone() const override SIP_FACTORY;
129 QgsDataProvider *dataProvider() override;
130 const QgsDataProvider *dataProvider() const override SIP_SKIP;
131 QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) override SIP_FACTORY;
132 bool readXml( const QDomNode &layerNode, QgsReadWriteContext &context ) override;
133 bool writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
134 bool readSymbology( const QDomNode &node, QString &errorMessage,
135 QgsReadWriteContext &context, StyleCategories categories = AllStyleCategories ) override;
136 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context,
137 StyleCategories categories = AllStyleCategories ) const override;
138 void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
139 QString loadDefaultStyle( bool &resultFlag SIP_OUT ) override;
140 Qgis::MapLayerProperties properties() const override;
141
153 bool loadDefaultStyle( QString &error, QStringList &warnings ) SIP_SKIP;
154
169 bool loadDefaultStyleAndSubLayers( QString &error, QStringList &warnings, QList< QgsMapLayer * > &subLayers SIP_OUT SIP_TRANSFERBACK );
170
171 QString loadDefaultMetadata( bool &resultFlag SIP_OUT ) override;
172
173 QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
174 QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
175 QString htmlMetadata() const override;
176
177 // new methods
178
184 QgsVectorTileMatrixSet &tileMatrixSet() { return mMatrixSet; }
185
187 QString sourceType() const { return mSourceType; }
189 QString sourcePath() const { return mSourcePath; }
190
192 int sourceMinZoom() const { return mMatrixSet.minimumZoom(); }
194 int sourceMaxZoom() const { return mMatrixSet.maximumZoom(); }
195
203 QByteArray getRawTile( QgsTileXYZ tileID ) SIP_SKIP;
204
209 void setRenderer( QgsVectorTileRenderer *r SIP_TRANSFER );
211 QgsVectorTileRenderer *renderer() const;
212
217 void setLabeling( QgsVectorTileLabeling *labeling SIP_TRANSFER );
219 QgsVectorTileLabeling *labeling() const;
220
222 void setTileBorderRenderingEnabled( bool enabled ) { mTileBorderRendering = enabled; }
224 bool isTileBorderRenderingEnabled() const { return mTileBorderRendering; }
225
235 QList< QgsFeature > selectedFeatures() const;
236
246 int selectedFeatureCount() const;
247
259 void selectByGeometry( const QgsGeometry &geometry, const QgsSelectionContext &context,
262 Qgis::SelectionFlags flags = Qgis::SelectionFlags(),
263 QgsRenderContext *renderContext = nullptr );
264
265 public slots:
266
274 void removeSelection();
275
276 signals:
277
284
285 private:
286 bool loadDataSource();
287
288 private:
290 QString mSourceType;
292 QString mSourcePath;
293
294 QgsVectorTileMatrixSet mMatrixSet;
295
297 std::unique_ptr<QgsVectorTileRenderer> mRenderer;
299 std::unique_ptr<QgsVectorTileLabeling> mLabeling;
301 bool mTileBorderRendering = false;
302
303 QVariantMap mArcgisLayerConfiguration;
304 QVariantMap mArcgisStyleConfiguration;
305
306 QgsCoordinateTransformContext mTransformContext;
307
308 std::unique_ptr< QgsDataProvider > mDataProvider;
309
310 QHash< QgsFeatureId, QgsFeature > mSelectedFeatures;
311
312 bool setupArcgisVectorTileServiceConnection( const QString &uri, const QgsDataSourceUri &dataSourceUri );
313
314 void setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
315 const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags ) override;
316
317 bool loadDefaultStyleAndSubLayersPrivate( QString &error, QStringList &warnings, QList< QgsMapLayer * > *subLayers );
318
319
320};
321
322#ifndef SIP_RUN
324
330class QgsVectorTileDataProvider : public QgsDataProvider
331{
332 Q_OBJECT
333
334 public:
335 QgsVectorTileDataProvider( const QgsDataProvider::ProviderOptions &providerOptions,
336 QgsDataProvider::ReadFlags flags );
337 QgsCoordinateReferenceSystem crs() const override;
338 QString name() const override;
339 QString description() const override;
340 QgsRectangle extent() const override;
341 bool isValid() const override;
342 bool renderInPreview( const QgsDataProvider::PreviewContext &context ) override;
343
344};
346#endif
347
348
349#endif // QGSVECTORTILELAYER_H
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:72
SelectGeometryRelationship
Geometry relationship test to apply for selecting features.
Definition: qgis.h:812
@ Intersect
Select where features intersect the reference geometry.
SelectBehavior
Specifies how a selection should be applied.
Definition: qgis.h:798
@ SetSelection
Set selection, removing any existing selection.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Abstract base class for spatial data provider implementations.
virtual QString name() const =0
Returns a provider name.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QString description() const =0
Returns description.
virtual bool renderInPreview(const QgsDataProvider::PreviewContext &context)
Returns whether the layer must be rendered in preview jobs.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
Class for storing the component parts of a RDBMS data source URI (e.g.
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:164
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
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.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
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)
QString sourcePath() const
Returns URL/path of the data source (syntax different to each data source type)
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.
Abstract base class for all vector tile renderer implementations.
#define str(x)
Definition: qgis.cpp:37
#define SIP_SKIP
Definition: qgis_sip.h:126
#define FINAL
Definition: qgis_sip.h:237
#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
Stores settings related to the context in which a preview job runs.
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.