QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
29 : mStyleName( stName )
30 , mLayerName( laName )
31 , mGeometryType( geomType )
42 mStyleName = other.mStyleName;
43 mLayerName = other.mLayerName;
44 mGeometryType = other.mGeometryType;
45 mSymbol.reset( other.mSymbol ? other.mSymbol->clone() :
nullptr );
46 mEnabled = other.mEnabled;
47 mExpression = other.mExpression;
48 mMinZoomLevel = other.mMinZoomLevel;
49 mMaxZoomLevel = other.mMaxZoomLevel;
62 elem.setAttribute( QStringLiteral(
"name" ), mStyleName );
63 elem.setAttribute( QStringLiteral(
"layer" ), mLayerName );
64 elem.setAttribute( QStringLiteral(
"geometry" ), mGeometryType );
65 elem.setAttribute( QStringLiteral(
"enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
66 elem.setAttribute( QStringLiteral(
"expression" ), mExpression );
67 elem.setAttribute( QStringLiteral(
"min-zoom" ), mMinZoomLevel );
68 elem.setAttribute( QStringLiteral(
"max-zoom" ), mMaxZoomLevel );
70 QDomDocument doc = elem.ownerDocument();
72 symbols[QStringLiteral(
"0" )] = mSymbol.get();
74 elem.appendChild( symbolsElem );
79 mStyleName = elem.attribute( QStringLiteral(
"name" ) );
80 mLayerName = elem.attribute( QStringLiteral(
"layer" ) );
82 mEnabled = elem.attribute( QStringLiteral(
"enabled" ) ).toInt();
83 mExpression = elem.attribute( QStringLiteral(
"expression" ) );
84 mMinZoomLevel = elem.attribute( QStringLiteral(
"min-zoom" ) ).toInt();
85 mMaxZoomLevel = elem.attribute( QStringLiteral(
"max-zoom" ) ).toInt();
88 QDomElement symbolsElem = elem.firstChildElement( QStringLiteral(
"symbols" ) );
89 if ( !symbolsElem.isNull() )
92 if ( symbolMap.contains( QStringLiteral(
"0" ) ) )
94 mSymbol.reset( symbolMap.take( QStringLiteral(
"0" ) ) );
108 return QStringLiteral(
"basic" );
114 r->mStyles = mStyles;
122 Q_UNUSED( tileRange )
126 if ( layerStyle.isActive( tileZoom ) && !layerStyle.filterExpression().isEmpty() )
136 return mRequiredFields;
151 if ( !layerStyle.isActive( zoomLevel ) )
158 QgsExpression filterExpression( layerStyle.filterExpression() );
163 if ( layerStyle.layerName().isEmpty() )
166 for ( QString layerName : tileData.keys() )
168 for (
const QgsFeature &f : tileData[layerName] )
179 else if ( tileData.contains( layerStyle.layerName() ) )
182 for (
const QgsFeature &f : tileData[layerStyle.layerName()] )
198 QDomDocument doc = elem.ownerDocument();
199 QDomElement elemStyles = doc.createElement( QStringLiteral(
"styles" ) );
202 QDomElement elemStyle = doc.createElement( QStringLiteral(
"style" ) );
203 layerStyle.writeXml( elemStyle, context );
204 elemStyles.appendChild( elemStyle );
206 elem.appendChild( elemStyles );
213 QDomElement elemStyles = elem.firstChildElement( QStringLiteral(
"styles" ) );
214 QDomElement elemStyle = elemStyles.firstChildElement( QStringLiteral(
"style" ) );
215 while ( !elemStyle.isNull() )
218 layerStyle.
readXml( elemStyle, context );
219 mStyles.append( layerStyle );
220 elemStyle = elemStyle.nextSiblingElement( QStringLiteral(
"style" ) );
237 QColor polygonStrokeColor = polygonFillColor;
238 polygonFillColor.setAlpha( 100 );
245 QColor pointStrokeColor = pointFillColor;
246 pointFillColor.setAlpha( 100 );
249 return simpleStyle( polygonFillColor, polygonStrokeColor, polygonStrokeWidth,
250 lineStrokeColor, lineStrokeWidth,
251 pointFillColor, pointStrokeColor, pointSize );
255 const QColor &polygonFillColor,
const QColor &polygonStrokeColor,
double polygonStrokeWidth,
256 const QColor &lineStrokeColor,
double lineStrokeWidth,
257 const QColor &pointFillColor,
const QColor &pointStrokeColor,
double pointSize )
266 lineSymbolLayer->
setColor( lineStrokeColor );
267 lineSymbolLayer->
setWidth( lineStrokeWidth );
273 markerSymbolLayer->
setSize( pointSize );
285 QList<QgsVectorTileBasicRendererStyle> lst;
286 lst << st1 << st2 << st3;
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
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 ...
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.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
QMap< QString, QgsSymbol * > QgsSymbolMap
virtual void setColor(const QColor &color)
The fill color.
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.
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.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes renderer's properties to given XML element.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
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)
QMap< QString, QgsFields > fields() const
Returns per-layer fields.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
QgsVectorTileBasicRenderer()
Constructs renderer with no styles.
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.
const double DEFAULT_LINE_WIDTH
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
~QgsVectorTileBasicRendererStyle()
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
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.
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.
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.
QList< QgsSymbolLayer * > QgsSymbolLayerList
QString type() const override
Returns unique type name of the renderer implementation.
virtual void setSize(double size)
Sets the symbol size.
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.
QgsVectorTileBasicRendererStyle & operator=(const QgsVectorTileBasicRendererStyle &other)
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
void setFillColor(const QColor &color) override
Set fill color.
void setFillColor(const QColor &color) override
Set fill color.