QGIS API Documentation 3.43.0-Master (b60ef06885e)
qgsvectortilebasicrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilebasicrenderer.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 QGSVECTORTILEBASICRENDERER_H
17#define QGSVECTORTILEBASICRENDERER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
23
24class QgsLineSymbol;
25class QgsFillSymbol;
26class QgsMarkerSymbol;
27
28class QgsSymbol;
29
50{
51 public:
53 QgsVectorTileBasicRendererStyle( const QString &stName = QString(), const QString &laName = QString(), Qgis::GeometryType geomType = Qgis::GeometryType::Unknown );
54
58
60 void setStyleName( const QString &name ) { mStyleName = name; }
62 QString styleName() const { return mStyleName; }
63
65 void setLayerName( const QString &name ) { mLayerName = name; }
67 QString layerName() const { return mLayerName; }
68
70 void setGeometryType( Qgis::GeometryType geomType ) { mGeometryType = geomType; }
72 Qgis::GeometryType geometryType() const { return mGeometryType; }
73
75 void setFilterExpression( const QString &expr ) { mExpression = expr; }
77 QString filterExpression() const { return mExpression; }
78
80 void setSymbol( QgsSymbol *sym SIP_TRANSFER );
82 QgsSymbol *symbol() const { return mSymbol.get(); }
83
85 void setEnabled( bool enabled ) { mEnabled = enabled; }
87 bool isEnabled() const { return mEnabled; }
88
98 void setMinZoomLevel( int minZoom ) { mMinZoomLevel = minZoom; }
99
109 int minZoomLevel() const { return mMinZoomLevel; }
110
124 void setMaxZoomLevel( int maxZoom ) { mMaxZoomLevel = maxZoom; }
125
139 int maxZoomLevel() const { return mMaxZoomLevel; }
140
142 bool isActive( int zoomLevel ) const
143 {
144 return mEnabled && ( mMinZoomLevel == -1 || zoomLevel >= mMinZoomLevel ) && ( mMaxZoomLevel == -1 || zoomLevel <= mMaxZoomLevel );
145 }
146
148 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;
150 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
151
152 private:
153 QString mStyleName;
154 QString mLayerName;
155 Qgis::GeometryType mGeometryType;
156 std::unique_ptr<QgsSymbol> mSymbol;
157 bool mEnabled = true;
158 QString mExpression;
159 int mMinZoomLevel = -1;
160 int mMaxZoomLevel = -1;
161};
162
163
173{
174 public:
177
178 QString type() const override;
179 QgsVectorTileBasicRenderer *clone() const override SIP_FACTORY;
180 void startRender( QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange ) override;
181 QMap<QString, QSet<QString> > usedAttributes( const QgsRenderContext & ) override SIP_SKIP;
182 QSet< QString > requiredLayers( QgsRenderContext &context, int tileZoom ) const override;
183 void stopRender( QgsRenderContext &context ) override;
184 void renderBackground( QgsRenderContext &context ) override;
185 void renderTile( const QgsVectorTileRendererData &tile, QgsRenderContext &context ) override;
186 void renderSelectedFeatures( const QList< QgsFeature > &selection, QgsRenderContext &context ) override;
187 bool willRenderFeature( const QgsFeature &feature, int tileZoom, const QString &layerName, QgsRenderContext &context ) override;
188 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
189 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
190
192 void setStyles( const QList<QgsVectorTileBasicRendererStyle> &styles );
194 QList<QgsVectorTileBasicRendererStyle> styles() const;
196 void setStyle( int index, const QgsVectorTileBasicRendererStyle &style ) { mStyles[index] = style; }
198 QgsVectorTileBasicRendererStyle style( int index ) const { return mStyles[index]; }
199
201 static QList<QgsVectorTileBasicRendererStyle> simpleStyle(
202 const QColor &polygonFillColor, const QColor &polygonStrokeColor, double polygonStrokeWidth,
203 const QColor &lineStrokeColor, double lineStrokeWidth,
204 const QColor &pointFillColor, const QColor &pointStrokeColor, double pointSize );
205
207 static QList<QgsVectorTileBasicRendererStyle> simpleStyleWithRandomColors();
208
209 private:
210 void setDefaultStyle();
211
212 private:
214 QList<QgsVectorTileBasicRendererStyle> mStyles;
215
216 // temporary bits
217
219 QMap<QString, QSet<QString> > mRequiredFields;
220
221};
222
223#endif // QGSVECTORTILEBASICRENDERER_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
@ Unknown
Unknown types.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
A range of tiles in a tile matrix.
Definition qgstiles.h:98
Definition of map rendering of a subset of vector tile data.
void setEnabled(bool enabled)
Sets whether this style is enabled (used for rendering)
void setMinZoomLevel(int minZoom)
Sets minimum zoom level index (negative number means no limit).
void setLayerName(const QString &name)
Sets name of the sub-layer to render (empty layer means that all layers match)
Qgis::GeometryType geometryType() const
Returns type of the geometry that will be used (point / line / polygon)
QgsSymbol * symbol() const
Returns symbol for rendering.
QString filterExpression() const
Returns filter expression (empty filter means that all features match)
QString styleName() const
Returns human readable name of this style.
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match)
void setStyleName(const QString &name)
Sets human readable name of this style.
bool isEnabled() const
Returns whether this style is enabled (used for rendering)
void setMaxZoomLevel(int maxZoom)
Sets maximum zoom level index (negative number means no limit).
int minZoomLevel() const
Returns the minimum zoom level index (negative number means no limit).
int maxZoomLevel() const
Returns the maximum zoom level index (negative number means no limit).
QString layerName() const
Returns name of the sub-layer to render (empty layer means that all layers match)
bool isActive(int zoomLevel) const
Returns whether the style is active at given zoom level (also checks "enabled" flag)
void setGeometryType(Qgis::GeometryType geomType)
Sets type of the geometry that will be used (point / line / polygon)
The default vector tile renderer implementation.
void setStyle(int index, const QgsVectorTileBasicRendererStyle &style)
Updates style definition at the paricular index of the list (the index must be in interval [0,...
QgsVectorTileBasicRendererStyle style(int index) const
Returns style definition at the particular index.
Contains decoded features of a single vector tile and any other data necessary for rendering of it.
Abstract base class for all vector tile renderer implementations.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76