QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
31 : mStyleName( stName )
32 , mLayerName( laName )
33 , mGeometryType( geomType )
44 mStyleName = other.mStyleName;
45 mLayerName = other.mLayerName;
46 mGeometryType = other.mGeometryType;
47 mSymbol.reset( other.mSymbol ? other.mSymbol->clone() :
nullptr );
48 mEnabled = other.mEnabled;
49 mExpression = other.mExpression;
50 mMinZoomLevel = other.mMinZoomLevel;
51 mMaxZoomLevel = other.mMaxZoomLevel;
64 elem.setAttribute( QStringLiteral(
"name" ), mStyleName );
65 elem.setAttribute( QStringLiteral(
"layer" ), mLayerName );
66 elem.setAttribute( QStringLiteral(
"geometry" ), mGeometryType );
67 elem.setAttribute( QStringLiteral(
"enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
68 elem.setAttribute( QStringLiteral(
"expression" ), mExpression );
69 elem.setAttribute( QStringLiteral(
"min-zoom" ), mMinZoomLevel );
70 elem.setAttribute( QStringLiteral(
"max-zoom" ), mMaxZoomLevel );
72 QDomDocument doc = elem.ownerDocument();
74 symbols[QStringLiteral(
"0" )] = mSymbol.get();
76 elem.appendChild( symbolsElem );
81 mStyleName = elem.attribute( QStringLiteral(
"name" ) );
82 mLayerName = elem.attribute( QStringLiteral(
"layer" ) );
84 mEnabled = elem.attribute( QStringLiteral(
"enabled" ) ).toInt();
85 mExpression = elem.attribute( QStringLiteral(
"expression" ) );
86 mMinZoomLevel = elem.attribute( QStringLiteral(
"min-zoom" ) ).toInt();
87 mMaxZoomLevel = elem.attribute( QStringLiteral(
"max-zoom" ) ).toInt();
90 QDomElement symbolsElem = elem.firstChildElement( QStringLiteral(
"symbols" ) );
91 if ( !symbolsElem.isNull() )
94 if ( symbolMap.contains( QStringLiteral(
"0" ) ) )
96 mSymbol.reset( symbolMap.take( QStringLiteral(
"0" ) ) );
110 return QStringLiteral(
"basic" );
116 r->mStyles = mStyles;
124 Q_UNUSED( tileRange )
128 if ( layerStyle.isActive( tileZoom ) )
130 if ( !layerStyle.filterExpression().isEmpty() )
135 if (
auto *lSymbol = layerStyle.symbol() )
137 mRequiredFields[layerStyle.layerName()].unite( lSymbol->usedAttributes( context ) );
145 return mRequiredFields;
153 if ( layerStyle.isActive( tileZoom ) )
155 res.insert( layerStyle.layerName() );
173 if ( !layerStyle.isActive( zoomLevel ) || !layerStyle.symbol() )
180 QgsExpression filterExpression( layerStyle.filterExpression() );
185 if ( layerStyle.layerName() == QLatin1String(
"background" ) )
191 else if ( layerStyle.layerName().isEmpty() )
194 for ( QString layerName : tileData.keys() )
196 for (
const QgsFeature &f : tileData[layerName] )
203 if ( featureType == layerStyle.geometryType() )
220 const QgsRectangle boundingBox = f.geometry().boundingBox();
221 centroid.setGeometry( f.geometry().poleOfInaccessibility( std::min( boundingBox.
width(), boundingBox.
height() ) / 20 ) );
227 else if ( tileData.contains( layerStyle.layerName() ) )
230 for (
const QgsFeature &f : tileData[layerStyle.layerName()] )
237 if ( featureType == layerStyle.geometryType() )
254 const QgsRectangle boundingBox = f.geometry().boundingBox();
255 centroid.setGeometry( f.geometry().poleOfInaccessibility( std::min( boundingBox.
width(), boundingBox.
height() ) / 20 ) );
266 QDomDocument doc = elem.ownerDocument();
267 QDomElement elemStyles = doc.createElement( QStringLiteral(
"styles" ) );
270 QDomElement elemStyle = doc.createElement( QStringLiteral(
"style" ) );
271 layerStyle.writeXml( elemStyle, context );
272 elemStyles.appendChild( elemStyle );
274 elem.appendChild( elemStyles );
281 QDomElement elemStyles = elem.firstChildElement( QStringLiteral(
"styles" ) );
282 QDomElement elemStyle = elemStyles.firstChildElement( QStringLiteral(
"style" ) );
283 while ( !elemStyle.isNull() )
286 layerStyle.
readXml( elemStyle, context );
287 mStyles.append( layerStyle );
288 elemStyle = elemStyle.nextSiblingElement( QStringLiteral(
"style" ) );
305 QColor polygonStrokeColor = polygonFillColor;
306 polygonFillColor.setAlpha( 100 );
313 QColor pointStrokeColor = pointFillColor;
314 pointFillColor.setAlpha( 100 );
317 return simpleStyle( polygonFillColor, polygonStrokeColor, polygonStrokeWidth,
318 lineStrokeColor, lineStrokeWidth,
319 pointFillColor, pointStrokeColor, pointSize );
323 const QColor &polygonFillColor,
const QColor &polygonStrokeColor,
double polygonStrokeWidth,
324 const QColor &lineStrokeColor,
double lineStrokeWidth,
325 const QColor &pointFillColor,
const QColor &pointStrokeColor,
double pointSize )
334 lineSymbolLayer->
setColor( lineStrokeColor );
335 lineSymbolLayer->
setWidth( lineStrokeWidth );
341 markerSymbolLayer->
setSize( pointSize );
356 QList<QgsVectorTileBasicRendererStyle> lst;
357 lst << st1 << st2 << st3;
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
RAII class to pop scope from an expression context on destruction.
void setStyles(const QList< QgsVectorTileBasicRendererStyle > &styles)
Sets list of styles of the renderer.
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 ...
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
QgsExpressionContext & expressionContext()
Gets the expression context.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const
Writes object content to given DOM element.
The class is used as a container of context for various read/write operations on other objects.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Range of tiles in a tile matrix to be rendered. The selection is rectangular, given by start/end row ...
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
QMap< QString, QgsSymbol * > QgsSymbolMap
virtual void setWidth(double width)
Sets the width of the line symbol layer.
void setSymbol(QgsSymbol *sym)
Sets symbol for rendering. Takes ownership of the symbol.
Container of fields for a vector layer.
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...
bool isValid() const
Checks if this expression is valid.
The default vector tile renderer implementation. It has an ordered list of "styles",...
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes renderer's properties to given XML element.
Contains information about the context of a rendering operation.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
Contains decoded features of a single vector tile and any other data necessary for rendering of it.
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
Abstract base class for all rendered symbols.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
A rectangle specified with double values.
QPolygon tilePolygon() const
Returns polygon (made out of four corners of the tile) in screen coordinates calculated from render c...
QgsTileXYZ id() const
Returns coordinates of the tile.
QgsVectorTileBasicRendererStyle(const QString &stName=QString(), const QString &laName=QString(), QgsWkbTypes::GeometryType geomType=QgsWkbTypes::UnknownGeometry)
Constructs a style object.
QgsVectorTileBasicRenderer * clone() const override
Returns a clone of the renderer.
void setStrokeWidth(double strokeWidth)
Definition of map rendering of a subset of vector tile data. The subset of data is defined by:
QMap< QString, QgsFields > fields() const
Returns per-layer fields.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QgsVectorTileBasicRenderer()
Constructs renderer with no styles.
A marker symbol type, for rendering Point and MultiPoint geometries.
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
const double DEFAULT_LINE_WIDTH
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
void setFilterExpression(const QString &expr)
Sets filter expression (empty filter means that all features match)
~QgsVectorTileBasicRendererStyle()
A line symbol type, for rendering LineString and MultiLineString geometries.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, Qgis::VertexMarkerType currentVertexMarkerType=Qgis::VertexMarkerType::SemiTransparentCircle, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
Render a feature.
void startRender(QgsRenderContext &context, int tileZoom, const QgsTileRange &tileRange) override
Initializes rendering. It should be paired with a stopRender() call.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
void renderPolygon(const QPolygonF &points, const QVector< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Renders the symbol using the given render context.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
int zoomLevel() const
Returns tile's zoom level (Z)
QVariant evaluate()
Evaluate the feature and return the result.
Single scope for storing variables and functions for use within a QgsExpressionContext....
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...
QList< QgsVectorTileBasicRendererStyle > styles() const
Returns list of styles of the renderer.
void stopRender(QgsRenderContext &context) override
Finishes rendering and cleans up any resources.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
A geometry is the spatial representation of a feature.
void renderTile(const QgsVectorTileRendererData &tile, QgsRenderContext &context) override
Renders given vector tile. Must be called between startRender/stopRender.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
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.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
QList< QgsSymbolLayer * > QgsSymbolLayerList
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QString type() const override
Returns unique type name of the renderer implementation.
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...
QSet< QString > requiredLayers(QgsRenderContext &context, int tileZoom) const override
Returns a list of the layers required for rendering.
virtual void setSize(double size)
Sets the symbol size.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
static QList< QgsVectorTileBasicRendererStyle > simpleStyleWithRandomColors()
Returns a list of styles to render all layers, using random colors.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads renderer's properties from given XML element.
QgsVectorTileFeatures features() const
Returns features of the tile grouped by sub-layer names.
QMap< QString, QVector< QgsFeature > > QgsVectorTileFeatures
Features of a vector tile, grouped by sub-layer names (key of the map)
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads object content from given DOM element.
Class for parsing and evaluation of expressions (formerly called "search strings")....
QgsVectorTileBasicRendererStyle & operator=(const QgsVectorTileBasicRendererStyle &other)
void setStrokeColor(const QColor &strokeColor) override
Sets the stroke color for the symbol layer.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.
void setFillColor(const QColor &color) override
Sets the fill color for the symbol layer.