QGIS API Documentation  3.23.0-Master (eb871beae0)
qgsvectorlayerdiagramprovider.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerdiagramprovider.cpp
3  --------------------------------------
4  Date : September 2015
5  Copyright : (C) 2015 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 
17 
18 #include "qgsgeometry.h"
19 #include "qgslabelsearchtree.h"
20 #include "qgsvectorlayer.h"
22 #include "diagram/qgsdiagram.h"
23 #include "qgsgeos.h"
24 #include "qgslabelingresults.h"
25 #include "qgsrendercontext.h"
26 
27 #include "feature.h"
28 #include "labelposition.h"
29 
31  : QgsAbstractLabelProvider( layer )
32  , mSettings( *layer->diagramLayerSettings() )
33  , mDiagRenderer( layer->diagramRenderer()->clone() )
34  , mFields( layer->fields() )
35  , mLayerCrs( layer->crs() )
36  , mSource( ownFeatureLoop ? new QgsVectorLayerFeatureSource( layer ) : nullptr )
37  , mOwnsSource( ownFeatureLoop )
38 {
39  init();
40 }
41 
42 
44 {
45  mName = mLayerId;
46  mPriority = 1 - mSettings.priority() / 10.0; // convert 0..10 --> 1..0
48 }
49 
50 
52 {
53  if ( mOwnsSource )
54  delete mSource;
55 
56  qDeleteAll( mFeatures );
57 
58  // renderer is owned by mSettings
59 }
60 
61 
63 {
64  if ( !mSource )
65  {
66  // we have created the provider with "own feature loop" == false
67  // so it is assumed that prepare() has been already called followed by registerFeature() calls
68  return mFeatures;
69  }
70 
71  QSet<QString> attributeNames;
72  if ( !prepare( context, attributeNames ) )
73  return QList<QgsLabelFeature *>();
74 
75  QgsRectangle layerExtent = context.extent();
77  layerExtent = mSettings.coordinateTransform().transformBoundingBox( context.extent(), Qgis::TransformDirection::Reverse );
78 
79  QgsFeatureRequest request;
80  request.setFilterRect( layerExtent );
81  request.setSubsetOfAttributes( attributeNames, mFields );
82  const QgsFeatureFilterProvider *featureFilterProvider = context.featureFilterProvider();
83  if ( featureFilterProvider )
84  {
85  featureFilterProvider->filterFeatures( qobject_cast<QgsVectorLayer *>( mLayer ), request );
86  }
87  QgsFeatureIterator fit = mSource->getFeatures( request );
88 
89  QgsFeature fet;
90  while ( fit.nextFeature( fet ) )
91  {
92  context.expressionContext().setFeature( fet );
93  registerFeature( fet, context );
94  }
95 
96  return mFeatures;
97 }
98 
99 
101 {
102 #if 1 // XXX strk
103  // features are pre-rotated but not scaled/translated,
104  // so we only disable rotation here. Ideally, they'd be
105  // also pre-scaled/translated, as suggested here:
106  // https://github.com/qgis/QGIS/issues/20071
107  QgsMapToPixel xform = context.mapToPixel();
108  xform.setMapRotation( 0, 0, 0 );
109 #else
110  const QgsMapToPixel &xform = context.mapToPixel();
111 #endif
112 
113  QgsDiagramLabelFeature *dlf = dynamic_cast<QgsDiagramLabelFeature *>( label->getFeaturePart()->feature() );
114 
115  QgsFeature feature;
116  feature.setFields( mFields );
117  feature.setValid( true );
118  feature.setId( label->getFeaturePart()->featureId() );
119  feature.setAttributes( dlf->attributes() );
120 
121  context.expressionContext().setFeature( feature );
122 
123  //calculate top-left point for diagram
124  //first, calculate the centroid of the label (accounts for PAL creating
125  //rotated labels when we do not want to draw the diagrams rotated)
126  double centerX = 0;
127  double centerY = 0;
128  for ( int i = 0; i < 4; ++i )
129  {
130  centerX += label->getX( i );
131  centerY += label->getY( i );
132  }
133  QgsPointXY outPt( centerX / 4.0, centerY / 4.0 );
134  //then, calculate the top left point for the diagram with this center position
135  QgsPointXY centerPt = xform.transform( outPt.x() - label->getWidth() / 2,
136  outPt.y() - label->getHeight() / 2 );
137 
138  mSettings.renderer()->renderDiagram( feature, context, centerPt.toQPointF(), mSettings.dataDefinedProperties() );
139 
140  //insert into label search tree to manipulate position interactively
141  mEngine->results()->mLabelSearchTree->insertLabel( label, label->getFeaturePart()->featureId(), mLayerId, QString(), QFont(), true, false );
142 
143 }
144 
145 
146 bool QgsVectorLayerDiagramProvider::prepare( const QgsRenderContext &context, QSet<QString> &attributeNames )
147 {
149  const QgsMapSettings &mapSettings = mEngine->mapSettings();
150 
151  if ( context.coordinateTransform().isValid() )
152  // this is context for layer rendering
154  else
155  {
156  // otherwise fall back to creating our own CT
158  }
159 
161 
162  bool result = s2.prepare( context.expressionContext() );
163 
164  //add attributes needed by the diagram renderer
165  attributeNames.unite( s2.referencedFields( context.expressionContext() ) );
166 
167  return result;
168 }
169 
170 
172 {
173  QgsLabelFeature *label = registerDiagram( feature, context, obstacleGeometry );
174  if ( label )
175  mFeatures << label;
176 }
177 
179 {
180  mLabelClipFeatureGeom = geometry;
181 }
182 
184 {
185  const QgsMapSettings &mapSettings = mEngine->mapSettings();
186 
187  const QgsDiagramRenderer *dr = mSettings.renderer();
188  if ( dr )
189  {
190  QList<QgsDiagramSettings> settingList = dr->diagramSettings();
191  if ( !settingList.isEmpty() && settingList.at( 0 ).scaleBasedVisibility )
192  {
193  double maxScale = settingList.at( 0 ).maximumScale;
194  if ( maxScale > 0 && context.rendererScale() < maxScale )
195  {
196  return nullptr;
197  }
198 
199  double minScale = settingList.at( 0 ).minimumScale;
200  if ( minScale > 0 && context.rendererScale() > minScale )
201  {
202  return nullptr;
203  }
204  }
205  }
206 
207  // data defined show diagram? check this before doing any other processing
209  return nullptr;
210 
211  // data defined obstacle?
213 
214  //convert geom to geos
215  QgsGeometry geom = feat.geometry();
216  QgsGeometry extentGeom = QgsGeometry::fromRect( mapSettings.visibleExtent() );
217  if ( !qgsDoubleNear( mapSettings.rotation(), 0.0 ) )
218  {
219  //PAL features are prerotated, so extent also needs to be unrotated
220  extentGeom.rotate( -mapSettings.rotation(), mapSettings.visibleExtent().center() );
221  }
222 
223  if ( QgsPalLabeling::geometryRequiresPreparation( geom, context, mSettings.coordinateTransform(), extentGeom ) )
224  {
225  geom = QgsPalLabeling::prepareGeometry( geom, context, mSettings.coordinateTransform(), extentGeom );
226  }
227  if ( geom.isEmpty() )
228  return nullptr;
229 
231  if ( !clipGeometry.isEmpty() )
232  {
233  const QgsWkbTypes::GeometryType expectedType = geom.type();
234  geom = geom.intersection( clipGeometry );
235  geom.convertGeometryCollectionToSubclass( expectedType );
236  }
237  if ( geom.isEmpty() )
238  return nullptr;
239 
240  QgsGeometry preparedObstacleGeom;
241  if ( isObstacle && !obstacleGeometry.isNull() && QgsPalLabeling::geometryRequiresPreparation( obstacleGeometry, context, mSettings.coordinateTransform(), extentGeom ) )
242  {
243  preparedObstacleGeom = QgsPalLabeling::prepareGeometry( obstacleGeometry, context, mSettings.coordinateTransform(), extentGeom );
244  }
245  else if ( mSettings.isObstacle() && !obstacleGeometry.isNull() )
246  {
247  preparedObstacleGeom = obstacleGeometry;
248  }
249 
250  double diagramWidth = 0;
251  double diagramHeight = 0;
252  if ( dr )
253  {
254  QSizeF diagSize = dr->sizeMapUnits( feat, context );
255  if ( diagSize.isValid() )
256  {
257  diagramWidth = diagSize.width();
258  diagramHeight = diagSize.height();
259  }
260  }
261 
262  // feature to the layer
263  bool alwaysShow = mSettings.showAllDiagrams();
264  context.expressionContext().setOriginalValueVariable( alwaysShow );
266 
267  // new style data defined position
268  bool ddPos = false;
269  double ddPosX = 0.0;
270  double ddPosY = 0.0;
275  {
276  ddPosX = mSettings.dataDefinedProperties().valueAsDouble( QgsDiagramLayerSettings::PositionX, context.expressionContext(), std::numeric_limits<double>::quiet_NaN() );
277  ddPosY = mSettings.dataDefinedProperties().valueAsDouble( QgsDiagramLayerSettings::PositionY, context.expressionContext(), std::numeric_limits<double>::quiet_NaN() );
278 
279  ddPos = !std::isnan( ddPosX ) && !std::isnan( ddPosY );
280 
281  if ( ddPos )
282  {
284  if ( ct.isValid() && !ct.isShortCircuited() )
285  {
286  double z = 0;
287  ct.transformInPlace( ddPosX, ddPosY, z );
288  }
289  //data defined diagram position is always centered
290  ddPosX -= diagramWidth / 2.0;
291  ddPosY -= diagramHeight / 2.0;
292  }
293  }
294 
295  QgsDiagramLabelFeature *lf = new QgsDiagramLabelFeature( feat.id(), QgsGeos::asGeos( geom ), QSizeF( diagramWidth, diagramHeight ) );
296  lf->setHasFixedPosition( ddPos );
297  lf->setFixedPosition( QgsPointXY( ddPosX, ddPosY ) );
298  lf->setHasFixedAngle( true );
299  lf->setFixedAngle( 0 );
300  lf->setAlwaysShow( alwaysShow );
302  os.setIsObstacle( isObstacle );
303  os.setObstacleGeometry( preparedObstacleGeom );
304  lf->setObstacleSettings( os );
305 
306  if ( dr )
307  {
308  //append the diagram attributes to lbl
309  lf->setAttributes( feat.attributes() );
310  }
311 
312  // data defined priority?
315  {
318  priorityD = std::clamp( priorityD, 0.0, 10.0 );
319  priorityD = 1 - priorityD / 10.0; // convert 0..10 --> 1..0
320  lf->setPriority( priorityD );
321  }
322 
323  // z-Index
324  double zIndex = mSettings.zIndex();
327  {
328  context.expressionContext().setOriginalValueVariable( zIndex );
330  }
331  lf->setZIndex( zIndex );
332 
333  // label distance
334  QgsPointXY ptZero = mapSettings.mapToPixel().toMapCoordinates( 0, 0 );
335  QgsPointXY ptOne = mapSettings.mapToPixel().toMapCoordinates( 1, 0 );
336  double dist = mSettings.distance();
337 
340  {
343  }
344 
345  dist *= ptOne.distance( ptZero );
346 
347  lf->setDistLabel( dist );
348  return lf;
349 }
350 
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())=0
Gets an iterator for features matching the specified request.
The QgsAbstractLabelProvider class is an interface class.
QString mName
Name of the layer.
QString mLayerId
Associated layer's ID, if applicable.
double mPriority
Default priority of labels.
const QgsLabelingEngine * mEngine
Associated labeling engine.
QgsWeakMapLayerPointer mLayer
Weak pointer to source layer.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean.
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
Class for doing transforms between two map coordinate systems.
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
void transformInPlace(double &x, double &y, double &z, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward) const SIP_THROW(QgsCsException)
Transforms an array of x, y and z double coordinates in place, from the source CRS to the destination...
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Class that adds extra information to QgsLabelFeature for labeling of diagrams.
const QgsAttributes & attributes()
Gets feature's attributes - used for rendering of diagrams.
void setAttributes(const QgsAttributes &attrs)
Store feature's attributes - used for rendering of diagrams.
Stores the settings for rendering of all diagrams for a layer.
Placement placement() const
Returns the diagram placement.
QgsCoordinateTransform coordinateTransform() const
Returns the coordinate transform associated with the layer, or an invalid transform if no transformat...
QgsDiagramRenderer * renderer()
Returns the diagram renderer associated with the layer.
@ Distance
Distance to diagram from feature.
@ IsObstacle
Whether diagram features act as obstacles for other diagrams/labels.
@ PositionX
X-coordinate data defined diagram position.
@ Priority
Diagram priority (between 0 and 10)
@ AlwaysShow
Whether the diagram should always be shown, even if it overlaps other diagrams/labels.
@ Show
Whether to show the diagram.
@ ZIndex
Z-index for diagram ordering.
@ PositionY
Y-coordinate data defined diagram position.
void setRenderer(QgsDiagramRenderer *diagramRenderer)
Sets the diagram renderer associated with the layer.
bool showAllDiagrams() const
Returns whether the layer should show all diagrams, including overlapping diagrams.
int priority() const
Returns the diagram priority.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext()) const
Returns the set of any fields referenced by the layer's diagrams.
bool isObstacle() const
Returns whether the feature associated with a diagram acts as an obstacle for other labels or diagram...
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the diagrams for a specified expression context.
void setCoordinateTransform(const QgsCoordinateTransform &transform)
Sets the coordinate transform associated with the layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the diagram's property collection, used for data defined overrides.
double zIndex() const
Returns the diagram z-index.
double distance() const
Returns the distance between the diagram and the feature (in mm).
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, QPointF pos, const QgsPropertyCollection &properties=QgsPropertyCollection()) const
Renders the diagram for a specified feature at a specific position in the passed render context.
virtual QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c) const
Returns size of the diagram for a feature in map units. Returns an invalid QSizeF in case of error.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Abstract interface for use by classes that filter the features or attributes of a layer.
virtual void filterFeatures(const QgsVectorLayer *layer, QgsFeatureRequest &featureRequest) const =0
Add additional filters to the feature request to further restrict the features returned by the reques...
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
QgsAttributes attributes
Definition: qgsfeature.h:65
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
Definition: qgsfeature.cpp:135
void setFields(const QgsFields &fields, bool initAttributes=false)
Assigns a field map with the feature to allow attribute access by attribute name.
Definition: qgsfeature.cpp:170
void setId(QgsFeatureId id)
Sets the feature id for this feature.
Definition: qgsfeature.cpp:115
QgsGeometry geometry
Definition: qgsfeature.h:67
void setValid(bool validity)
Sets the validity of the feature.
Definition: qgsfeature.cpp:196
Q_GADGET QgsFeatureId id
Definition: qgsfeature.h:64
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:125
Q_GADGET bool isNull
Definition: qgsgeometry.h:127
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:128
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY &center)
Rotate this geometry around the Z axis.
bool convertGeometryCollectionToSubclass(QgsWkbTypes::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0)
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
Definition: qgsgeos.cpp:181
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
void setDistLabel(double dist)
Applies to "around point" placement strategy or linestring features.
void setAlwaysShow(bool enabled)
Sets whether label should be always shown (sets very high label priority)
void setZIndex(double zIndex)
Sets the label's z-index.
void setHasFixedAngle(bool enabled)
Sets whether the label should use a fixed angle instead of using angle from automatic placement.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label's obstacle settings.
void setPriority(double priority)
Sets the priority for labeling the feature.
void setHasFixedPosition(bool enabled)
Sets whether the label should use a fixed position instead of being automatically placed.
void setFixedPosition(const QgsPointXY &point)
Sets coordinates of the fixed position (relevant only if hasFixedPosition() returns true)
void setFixedAngle(double angle)
Sets angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true)
Contains settings related to how the label engine treats features as obstacles.
void setIsObstacle(bool isObstacle)
Sets whether features are obstacles to labels of other layers.
void setObstacleGeometry(const QgsGeometry &obstacleGeom)
Sets the label's obstacle geometry, if different to the feature geometry.
const QgsMapSettings & mapSettings() const
Gets associated map settings.
QgsLabelingResults * results() const
For internal use by the providers.
The QgsMapSettings class contains configuration for rendering of the map.
const QgsMapToPixel & mapToPixel() const
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
double rotation() const
Returns the rotation of the resulting map image, in degrees clockwise.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
void setMapRotation(double degrees, double cx, double cy)
Sets map rotation in degrees (clockwise).
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
Definition: qgsmaptopixel.h:90
static QgsGeometry prepareGeometry(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Prepares a geometry for registration with PAL.
static bool geometryRequiresPreparation(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Checks whether a geometry requires preparation before registration with PAL.
Placement
Placement modes which determine how label candidates are generated for a feature.
A class to represent a 2D point.
Definition: qgspointxy.h:59
double y
Definition: qgspointxy.h:63
Q_GADGET double x
Definition: qgspointxy.h:62
double distance(double x, double y) const SIP_HOLDGIL
Returns the distance between this point and a specified x, y coordinate.
Definition: qgspointxy.h:211
QPointF toQPointF() const
Converts a point to a QPointF.
Definition: qgspointxy.h:169
bool hasProperty(int key) const override
Returns true if the collection contains a property with the specified key.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
bool isActive() const
Returns whether the property is currently active.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsPointXY center() const SIP_HOLDGIL
Returns the center point of the rectangle.
Definition: qgsrectangle.h:251
Contains information about the context of a rendering operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsCoordinateTransformContext transformContext() const
Returns the context's coordinate transform context, which stores various information regarding which ...
QgsGeometry featureClipGeometry() const
Returns the geometry to use to clip features at render time.
const QgsFeatureFilterProvider * featureFilterProvider() const
Gets the filter feature provider used for additional filtering of rendered features.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsDiagramLayerSettings mSettings
Diagram layer settings.
QgsLabelFeature * registerDiagram(QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
helper method to register one diagram feature
QgsAbstractFeatureSource * mSource
Layer's feature source.
QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context) override
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
void init()
initialization method - called from constructors
bool mOwnsSource
Whether layer's feature source is owned.
QgsCoordinateReferenceSystem mLayerCrs
Layer's CRS.
virtual bool prepare(const QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry())
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures.
QgsDiagramRenderer * mDiagRenderer
Diagram renderer instance (owned by mSettings)
QList< QgsLabelFeature * > mFeatures
List of generated label features (owned by the provider)
QgsVectorLayerDiagramProvider(QgsVectorLayer *layer, bool ownFeatureLoop=true)
Convenience constructor to initialize the provider from given vector layer.
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw this label at the position determined by the labeling engine.
void setClipFeatureGeometry(const QgsGeometry &geometry)
Sets a geometry to use to clip features to when registering them as diagrams.
Partial snapshot of vector layer's state (only the members necessary for access to features)
Represents a vector layer which manages a vector based data sets.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QgsFeatureId featureId() const
Returns the unique ID of the feature.
Definition: feature.cpp:161
QgsLabelFeature * feature()
Returns the parent feature.
Definition: feature.h:94
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
double getHeight() const
double getWidth() const
FeaturePart * getFeaturePart() const
Returns the feature corresponding to this labelposition.
double getX(int i=0) const
Returns the down-left x coordinate.
double getY(int i=0) const
Returns the down-left y coordinate.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:1504
const QgsCoordinateReferenceSystem & crs