Skip to content

Commit

Permalink
Make the original layer CRS of label features accessible via
Browse files Browse the repository at this point in the history
QgsLabelFeature
  • Loading branch information
nyalldawson committed Feb 23, 2021
1 parent 493329c commit 07a21af
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/labeling/qgslabelfeature.cpp
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/core/labeling/qgslabelfeature.h
Expand Up @@ -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;
Expand Down Expand Up @@ -593,6 +609,8 @@ class CORE_EXPORT QgsLabelFeature

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

QgsCoordinateReferenceSystem mOriginalFeatureCrs;
};

#endif // QGSLABELFEATURE_H
1 change: 1 addition & 0 deletions src/core/labeling/qgspallabeling.cpp
Expand Up @@ -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
Expand Down

0 comments on commit 07a21af

Please sign in to comment.