Skip to content
Permalink
Browse files

Make the original layer CRS of label features accessible via

QgsLabelFeature
  • Loading branch information
nyalldawson committed Feb 23, 2021
1 parent 493329c commit 07a21af98b72630780b0e24c79ad3252f261c649
@@ -110,6 +110,16 @@ void QgsLabelFeature::setObstacleSettings( const QgsLabelObstacleSettings &setti
mObstacleSettings = settings;
}

QgsCoordinateReferenceSystem QgsLabelFeature::originalFeatureCrs() const
{
return mOriginalFeatureCrs;
}

void QgsLabelFeature::setOriginalFeatureCrs( const QgsCoordinateReferenceSystem &originalFeatureCrs )
{
mOriginalFeatureCrs = originalFeatureCrs;
}

void QgsLabelFeature::setAnchorPosition( const QgsPointXY &anchorPosition )
{
mAnchorPosition = anchorPosition;
@@ -514,6 +514,22 @@ class CORE_EXPORT QgsLabelFeature
*/
void setObstacleSettings( const QgsLabelObstacleSettings &settings );

/**
* Returns the original layer CRS of the feature associated with the label.
*
* \see setOriginalFeatureCrs()
* \since QGIS 3.20
*/
QgsCoordinateReferenceSystem originalFeatureCrs() const;

/**
* Sets the original layer \a crs of the feature associated with the label.
*
* \see originalFeatureCrs()
* \since QGIS 3.20
*/
void setOriginalFeatureCrs( const QgsCoordinateReferenceSystem &crs );

protected:
//! Pointer to PAL layer (assigned when registered to PAL)
pal::Layer *mLayer = nullptr;
@@ -593,6 +609,8 @@ class CORE_EXPORT QgsLabelFeature

double mLineAnchorPercent = 0.5;
QgsLabelLineSettings::AnchorType mLineAnchorType = QgsLabelLineSettings::AnchorType::HintOnly;

QgsCoordinateReferenceSystem mOriginalFeatureCrs;
};

#endif // QGSLABELFEATURE_H
@@ -2497,6 +2497,7 @@ void QgsPalLayerSettings::registerFeature( const QgsFeature &f, QgsRenderContext
( *labelFeature )->setLineAnchorPercent( lineSettings.lineAnchorPercent() );
( *labelFeature )->setLineAnchorType( lineSettings.anchorType() );
( *labelFeature )->setLabelAllParts( labelAll );
( *labelFeature )->setOriginalFeatureCrs( context.coordinateTransform().sourceCrs() );
if ( geom.type() == QgsWkbTypes::PointGeometry && !obstacleGeometry.isNull() )
{
//register symbol size

0 comments on commit 07a21af

Please sign in to comment.