QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | Public Attributes | List of all members
QgsVectorTileBasicLabelProvider Class Reference

Implementation class for QgsVectorTileBasicLabeling. More...

#include <qgsvectortilebasiclabeling.h>

Inheritance diagram for QgsVectorTileBasicLabelProvider:
Inheritance graph
[legend]

Public Member Functions

 QgsVectorTileBasicLabelProvider (QgsVectorTileLayer *layer, const QList< QgsVectorTileBasicLabelingStyle > &styles)
 Constructs a label provider for the given vector tile layer and using styling from QgsVectorTileBasicLabeling. More...
 
bool prepare (QgsRenderContext &context, QSet< QString > &attributeNames) override
 Prepare for registration of features. More...
 
void registerTileFeatures (const QgsVectorTileRendererData &tile, QgsRenderContext &context) override
 Registers label features for given tile to the labeling engine. More...
 
QSet< QString > requiredLayers (QgsRenderContext &context, int tileZoom) const override
 Returns a list of the layers required for labeling. More...
 
void setFields (const QMap< QString, QgsFields > &perLayerFields) override
 Sets fields for each sub-layer. More...
 
QList< QgsAbstractLabelProvider * > subProviders () override
 Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration. More...
 
QMap< QString, QSet< QString > > usedAttributes (const QgsRenderContext &context, int tileZoom) const override
 Returns field names for each sub-layer that are required for labeling. More...
 
- Public Member Functions inherited from QgsVectorTileLabelProvider
 QgsVectorTileLabelProvider (QgsVectorTileLayer *layer)
 Constructs base label provider class for the given vector tile layer. More...
 
virtual void registerTileFeatures (const QgsVectorTileRendererData &tile, QgsRenderContext &context)=0
 Registers label features for given tile to the labeling engine. More...
 
virtual QSet< QString > requiredLayers (QgsRenderContext &context, int tileZoom) const
 Returns a list of the layers required for labeling. More...
 
virtual void setFields (const QMap< QString, QgsFields > &perLayerFields)=0
 Sets fields for each sub-layer. More...
 
virtual QMap< QString, QSet< QString > > usedAttributes (const QgsRenderContext &context, int tileZoom) const =0
 Returns field names for each sub-layer that are required for labeling. More...
 
- Public Member Functions inherited from QgsVectorLayerLabelProvider
 QgsVectorLayerLabelProvider (Qgis::GeometryType geometryType, const QgsFields &fields, const QgsCoordinateReferenceSystem &crs, const QString &providerId, const QgsPalLayerSettings *settings, QgsMapLayer *layer, const QString &layerName=QString())
 Constructor to initialize the provider from any map layer (e.g. vector tile layer) More...
 
 QgsVectorLayerLabelProvider (QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings, const QString &layerName=QString())
 Convenience constructor to initialize the provider from given vector layer. More...
 
 ~QgsVectorLayerLabelProvider () override
 
void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw this label at the position determined by the labeling engine. More...
 
void drawLabelBackground (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw the background for the specified label. More...
 
void drawUnplacedLabel (QgsRenderContext &context, pal::LabelPosition *label) const override
 Draw an unplaced label. More...
 
QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &context) override
 Returns list of label features (they are owned by the provider and thus deleted on its destruction) More...
 
virtual bool prepare (QgsRenderContext &context, QSet< QString > &attributeNames)
 Prepare for registration of features. More...
 
virtual QList< QgsLabelFeature * > registerFeature (const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
 Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels. More...
 
void setFields (const QgsFields &fields)
 Sets fields of this label provider. More...
 
const QgsPalLayerSettingssettings () const
 Returns the layer's settings. More...
 
void startRender (QgsRenderContext &context) override
 To be called before rendering of labels begins. More...
 
void stopRender (QgsRenderContext &context) override
 To be called after rendering is complete. More...
 
- Public Member Functions inherited from QgsAbstractLabelProvider
 QgsAbstractLabelProvider (QgsMapLayer *layer, const QString &providerId=QString())
 Construct the provider with default values. More...
 
virtual ~QgsAbstractLabelProvider ()=default
 
virtual void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const =0
 Draw this label at the position determined by the labeling engine. More...
 
virtual void drawLabelBackground (QgsRenderContext &context, pal::LabelPosition *label) const
 Draw the background for the specified label. More...
 
virtual void drawUnplacedLabel (QgsRenderContext &context, pal::LabelPosition *label) const
 Draw an unplaced label. More...
 
Flags flags () const
 Flags associated with the provider. More...
 
virtual QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &context)=0
 Returns list of label features (they are owned by the provider and thus deleted on its destruction) More...
 
QgsMapLayerlayer () const
 Returns the associated layer, or nullptr if no layer is associated with the provider. More...
 
QgsExpressionContextScopelayerExpressionContextScope () const
 Returns the expression context scope created from the layer associated with this provider. More...
 
QString layerId () const
 Returns ID of associated layer, or empty string if no layer is associated with the provider. More...
 
double layerReferenceScale () const
 Returns the symbology reference scale of the layer associated with this provider. More...
 
QString name () const
 Name of the layer (for statistics, debugging etc.) - does not need to be unique. More...
 
QgsLabelObstacleSettings::ObstacleType obstacleType () const
 How the feature geometries will work as obstacles. More...
 
Qgis::LabelPlacement placement () const
 What placement strategy to use for the labels. More...
 
double priority () const
 Default priority of labels (may be overridden by individual labels) More...
 
QString providerId () const
 Returns provider ID - useful in case there is more than one label provider within a layer (e.g. More...
 
void setEngine (const QgsLabelingEngine *engine)
 Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) More...
 
virtual void startRender (QgsRenderContext &context)
 To be called before rendering of labels begins. More...
 
virtual void stopRender (QgsRenderContext &context)
 To be called after rendering is complete. More...
 
virtual QList< QgsAbstractLabelProvider * > subProviders ()
 Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration. More...
 
Qgis::UpsideDownLabelHandling upsidedownLabels () const
 How to handle labels that would be upside down. More...
 

Public Attributes

QMap< QString, QgsFieldsmPerLayerFields
 Names of required fields for each sub-layer (only valid between startRender/stopRender calls) More...
 

Additional Inherited Members

- Public Types inherited from QgsAbstractLabelProvider
enum  Flag { DrawLabels = 1 << 1 , MergeConnectedLines = 1 << 3 , CentroidMustBeInside = 1 << 4 }
 
typedef QFlags< FlagFlags
 
- Static Public Member Functions inherited from QgsVectorLayerLabelProvider
static QgsGeometry getPointObstacleGeometry (QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols)
 Returns the geometry for a point feature which should be used as an obstacle for labels. More...
 
- Protected Member Functions inherited from QgsVectorLayerLabelProvider
void drawLabelPrivate (pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, Qgis::TextComponent drawType, double dpiRatio=1.0) const
 Internal label drawing method. More...
 
void init ()
 initialization method - called from constructors More...
 
- Protected Attributes inherited from QgsVectorLayerLabelProvider
QgsCoordinateReferenceSystem mCrs
 Layer's CRS. More...
 
QgsFields mFields
 Layer's fields. More...
 
QList< QgsLabelFeature * > mLabels
 List of generated. More...
 
Qgis::GeometryType mLayerGeometryType
 Geometry type of layer. More...
 
QgsFeatureRenderermRenderer = nullptr
 
QgsPalLayerSettings mSettings
 Layer's labeling configuration. More...
 
std::unique_ptr< QgsAbstractFeatureSourcemSource
 Layer's feature source. More...
 
- Protected Attributes inherited from QgsAbstractLabelProvider
const QgsLabelingEnginemEngine = nullptr
 Associated labeling engine. More...
 
Flags mFlags = DrawLabels
 Flags altering drawing and registration of features. More...
 
QgsWeakMapLayerPointer mLayer
 Weak pointer to source layer. More...
 
QString mLayerId
 Associated layer's ID, if applicable. More...
 
QString mName
 Name of the layer. More...
 
QgsLabelObstacleSettings::ObstacleType mObstacleType = QgsLabelObstacleSettings::ObstacleType::PolygonBoundary
 Type of the obstacle of feature geometries. More...
 
Qgis::LabelPlacement mPlacement = Qgis::LabelPlacement::AroundPoint
 Placement strategy. More...
 
double mPriority = 0.5
 Default priority of labels. More...
 
QString mProviderId
 Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling) More...
 
Qgis::UpsideDownLabelHandling mUpsidedownLabels = Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels
 How to handle labels that would be upside down. More...
 

Detailed Description

Implementation class for QgsVectorTileBasicLabeling.

Since
QGIS 3.14

Definition at line 184 of file qgsvectortilebasiclabeling.h.

Constructor & Destructor Documentation

◆ QgsVectorTileBasicLabelProvider()

QgsVectorTileBasicLabelProvider::QgsVectorTileBasicLabelProvider ( QgsVectorTileLayer layer,
const QList< QgsVectorTileBasicLabelingStyle > &  styles 
)

Constructs a label provider for the given vector tile layer and using styling from QgsVectorTileBasicLabeling.

Definition at line 111 of file qgsvectortilebasiclabeling.cpp.

Member Function Documentation

◆ prepare()

bool QgsVectorTileBasicLabelProvider::prepare ( QgsRenderContext context,
QSet< QString > &  attributeNames 
)
overridevirtual

Prepare for registration of features.

Must be called after provider has been added to engine (uses its map settings)

Parameters
contextrender context.
attributeNameslist of attribute names to which additional required attributes shall be added
Returns
Whether the preparation was successful - if not, the provider shall not be used

Reimplemented from QgsVectorLayerLabelProvider.

Definition at line 174 of file qgsvectortilebasiclabeling.cpp.

◆ registerTileFeatures()

void QgsVectorTileBasicLabelProvider::registerTileFeatures ( const QgsVectorTileRendererData tile,
QgsRenderContext context 
)
overridevirtual

Registers label features for given tile to the labeling engine.

Implements QgsVectorTileLabelProvider.

Definition at line 200 of file qgsvectortilebasiclabeling.cpp.

◆ requiredLayers()

QSet< QString > QgsVectorTileBasicLabelProvider::requiredLayers ( QgsRenderContext context,
int  tileZoom 
) const
overridevirtual

Returns a list of the layers required for labeling.

Only layers which are labeled at the specified tileZoom should be included in this list.

An empty string present in the list indicates that all layer in the tiles are required.

Since
QGIS 3.16

Reimplemented from QgsVectorTileLabelProvider.

Definition at line 145 of file qgsvectortilebasiclabeling.cpp.

◆ setFields()

void QgsVectorTileBasicLabelProvider::setFields ( const QMap< QString, QgsFields > &  perLayerFields)
overridevirtual

Sets fields for each sub-layer.

Implements QgsVectorTileLabelProvider.

Definition at line 158 of file qgsvectortilebasiclabeling.cpp.

◆ subProviders()

QList< QgsAbstractLabelProvider * > QgsVectorTileBasicLabelProvider::subProviders ( )
overridevirtual

Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration.

Reimplemented from QgsAbstractLabelProvider.

Definition at line 163 of file qgsvectortilebasiclabeling.cpp.

◆ usedAttributes()

QMap< QString, QSet< QString > > QgsVectorTileBasicLabelProvider::usedAttributes ( const QgsRenderContext context,
int  tileZoom 
) const
overridevirtual

Returns field names for each sub-layer that are required for labeling.

Implements QgsVectorTileLabelProvider.

Definition at line 126 of file qgsvectortilebasiclabeling.cpp.

Member Data Documentation

◆ mPerLayerFields

QMap<QString, QgsFields> QgsVectorTileBasicLabelProvider::mPerLayerFields

Names of required fields for each sub-layer (only valid between startRender/stopRender calls)

Definition at line 207 of file qgsvectortilebasiclabeling.h.


The documentation for this class was generated from the following files: