28 : mStyleName( stName )
29 , mLayerName( laName )
30 , mGeometryType( geomType )
41 mStyleName = other.mStyleName;
42 mLayerName = other.mLayerName;
43 mGeometryType = other.mGeometryType;
44 mSymbol.reset( other.mSymbol ? other.mSymbol->clone() :
nullptr );
45 mEnabled = other.mEnabled;
46 mExpression = other.mExpression;
47 mMinZoomLevel = other.mMinZoomLevel;
48 mMaxZoomLevel = other.mMaxZoomLevel;
61 elem.setAttribute( QStringLiteral(
"name" ), mStyleName );
62 elem.setAttribute( QStringLiteral(
"layer" ), mLayerName );
63 elem.setAttribute( QStringLiteral(
"geometry" ), mGeometryType );
64 elem.setAttribute( QStringLiteral(
"enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
65 elem.setAttribute( QStringLiteral(
"expression" ), mExpression );
66 elem.setAttribute( QStringLiteral(
"min-zoom" ), mMinZoomLevel );
67 elem.setAttribute( QStringLiteral(
"max-zoom" ), mMaxZoomLevel );
69 QDomDocument doc = elem.ownerDocument();
71 symbols[QStringLiteral(
"0" )] = mSymbol.get();
73 elem.appendChild( symbolsElem );
78 mStyleName = elem.attribute( QStringLiteral(
"name" ) );
79 mLayerName = elem.attribute( QStringLiteral(
"layer" ) );
81 mEnabled = elem.attribute( QStringLiteral(
"enabled" ) ).toInt();
82 mExpression = elem.attribute( QStringLiteral(
"expression" ) );
83 mMinZoomLevel = elem.attribute( QStringLiteral(
"min-zoom" ) ).toInt();
84 mMaxZoomLevel = elem.attribute( QStringLiteral(
"max-zoom" ) ).toInt();
87 QDomElement symbolsElem = elem.firstChildElement( QStringLiteral(
"symbols" ) );
88 if ( !symbolsElem.isNull() )
91 if ( symbolMap.contains( QStringLiteral(
"0" ) ) )
93 mSymbol.reset( symbolMap.take( QStringLiteral(
"0" ) ) );
107 return QStringLiteral(
"basic" );
113 r->mStyles = mStyles;
121 Q_UNUSED( tileRange )
125 if ( layerStyle.isActive( tileZoom ) )
127 if ( !layerStyle.filterExpression().isEmpty() )
132 if (
auto *lSymbol = layerStyle.symbol() )
134 mRequiredFields[layerStyle.layerName()].unite( lSymbol->usedAttributes( context ) );
142 return mRequiredFields;
150 if ( layerStyle.isActive( tileZoom ) )
152 res.insert( layerStyle.layerName() );
170 if ( !layerStyle.isActive( zoomLevel ) )
177 QgsExpression filterExpression( layerStyle.filterExpression() );
182 if ( layerStyle.layerName().isEmpty() )
185 for ( QString layerName : tileData.keys() )
187 for (
const QgsFeature &f : tileData[layerName] )
194 if ( featureType == layerStyle.geometryType() )
209 else if ( tileData.contains( layerStyle.layerName() ) )
212 for (
const QgsFeature &f : tileData[layerStyle.layerName()] )
219 if ( featureType == layerStyle.geometryType() )
239 QDomDocument doc = elem.ownerDocument();
240 QDomElement elemStyles = doc.createElement( QStringLiteral(
"styles" ) );
243 QDomElement elemStyle = doc.createElement( QStringLiteral(
"style" ) );
244 layerStyle.writeXml( elemStyle, context );
245 elemStyles.appendChild( elemStyle );
247 elem.appendChild( elemStyles );
254 QDomElement elemStyles = elem.firstChildElement( QStringLiteral(
"styles" ) );
255 QDomElement elemStyle = elemStyles.firstChildElement( QStringLiteral(
"style" ) );
256 while ( !elemStyle.isNull() )
259 layerStyle.
readXml( elemStyle, context );
260 mStyles.append( layerStyle );
261 elemStyle = elemStyle.nextSiblingElement( QStringLiteral(
"style" ) );
278 QColor polygonStrokeColor = polygonFillColor;
279 polygonFillColor.setAlpha( 100 );
286 QColor pointStrokeColor = pointFillColor;
287 pointFillColor.setAlpha( 100 );
290 return simpleStyle( polygonFillColor, polygonStrokeColor, polygonStrokeWidth,
291 lineStrokeColor, lineStrokeWidth,
292 pointFillColor, pointStrokeColor, pointSize );
296 const QColor &polygonFillColor,
const QColor &polygonStrokeColor,
double polygonStrokeWidth,
297 const QColor &lineStrokeColor,
double lineStrokeWidth,
298 const QColor &pointFillColor,
const QColor &pointStrokeColor,
double pointSize )
307 lineSymbolLayer->
setColor( lineStrokeColor );
308 lineSymbolLayer->
setWidth( lineStrokeWidth );
314 markerSymbolLayer->
setSize( pointSize );
326 QList<QgsVectorTileBasicRendererStyle> lst;
327 lst << st1 << st2 << st3;
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
RAII class to pop scope from an expression context on destruction.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
QVariant evaluate()
Evaluate the feature and return the result.
bool isValid() const
Checks if this expression is valid.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Container of fields for a vector layer.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A geometry is the spatial representation of a feature.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
A line symbol type, for rendering LineString and MultiLineString geometries.
virtual void setSize(double size)
Sets the symbol size.
A marker symbol type, for rendering Point and MultiPoint geometries.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
void setStrokeWidth(double strokeWidth)
void setFillColor(const QColor &color) override
Set fill color.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
void setFillColor(const QColor &color) override
Set fill color.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
static QDomElement saveSymbols(QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a collection of symbols to XML with specified tagName for the top-level element.
virtual void setColor(const QColor &color)
The fill color.
Abstract base class for all rendered symbols.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
Render a feature.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
Range of tiles in a tile matrix to be rendered.
int zoomLevel() const
Returns tile's zoom level (Z)
Definition of map rendering of a subset of vector tile data.
~QgsVectorTileBasicRendererStyle()
void setSymbol(QgsSymbol *sym)
Sets symbol for rendering. Takes ownership of the symbol.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes object content to given DOM element.
QgsVectorTileBasicRendererStyle(const QString &stName=QString(), const QString &laName=QString(), QgsWkbTypes::GeometryType geomType=QgsWkbTypes::UnknownGeometry)
Constructs a style object.
QgsVectorTileBasicRendererStyle & operator=(const QgsVectorTileBasicRendererStyle &other)
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads object content from given DOM element.
The default vector tile renderer implementation.
void renderTile(const QgsVectorTileRendererData &tile, QgsRenderContext &context) override
Renders given vector tile. Must be called between startRender/stopRender.
QList< QgsVectorTileBasicRendererStyle > styles() const
Returns list of styles of the renderer.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads renderer's properties from given XML element.
QMap< QString, QSet< QString > > usedAttributes(const QgsRenderContext &) override
Returns field names of sub-layers that will be used for rendering. Must be called between startRender...
QgsVectorTileBasicRenderer()
Constructs renderer with no styles.
void setStyles(const QList< QgsVectorTileBasicRendererStyle > &styles)
Sets list of styles of the renderer.
void startRender(QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange) override
Initializes rendering. It should be paired with a stopRender() call.
QString type() const override
Returns unique type name of the renderer implementation.
static QList< QgsVectorTileBasicRendererStyle > simpleStyle(const QColor &polygonFillColor, const QColor &polygonStrokeColor, double polygonStrokeWidth, const QColor &lineStrokeColor, double lineStrokeWidth, const QColor &pointFillColor, const QColor &pointStrokeColor, double pointSize)
Returns a list of styles to render all layers with the given fill/stroke colors, stroke widths and ma...
QgsVectorTileBasicRenderer * clone() const override
Returns a clone of the renderer.
static QList< QgsVectorTileBasicRendererStyle > simpleStyleWithRandomColors()
Returns a list of styles to render all layers, using random colors.
QSet< QString > requiredLayers(QgsRenderContext &context, int tileZoom) const override
Returns a list of the layers required for rendering.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes renderer's properties to given XML element.
void stopRender(QgsRenderContext &context) override
Finishes rendering and cleans up any resources.
Contains decoded features of a single vector tile and any other data necessary for rendering of it.
QgsVectorTileFeatures features() const
Returns features of the tile grouped by sub-layer names.
QMap< QString, QgsFields > fields() const
Returns per-layer fields.
QgsTileXYZ id() const
Returns coordinates of the tile.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
const double DEFAULT_LINE_WIDTH
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbolLayer * > QgsSymbolLayerList
QMap< QString, QVector< QgsFeature > > QgsVectorTileFeatures
Features of a vector tile, grouped by sub-layer names (key of the map)