@@ -2803,35 +2803,14 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, QgsRenderContext &cont
2803
2803
ydiff = yd;
2804
2804
}
2805
2805
2806
- // project xPos and yPos from layer to map CRS
2807
- double z = 0 ;
2808
- if ( ct )
2806
+ // project xPos and yPos from layer to map CRS, handle rotation
2807
+ QgsGeometry ddPoint ( new QgsPointV2 ( xPos, yPos ) ) ;
2808
+ if ( QgsPalLabeling::geometryRequiresPreparation ( &ddPoint, context, ct ) )
2809
2809
{
2810
- try
2811
- {
2812
- ct->transformInPlace ( xPos, yPos, z );
2813
- }
2814
- catch ( QgsCsException &e )
2815
- {
2816
- Q_UNUSED ( e );
2817
- QgsDebugMsgLevel ( QString ( " Ignoring feature %1 due transformation exception on data-defined position" ).arg ( f.id () ), 4 );
2818
- return ;
2819
- }
2820
- }
2821
-
2822
- // rotate position with map if data-defined
2823
- if ( dataDefinedPosition && m2p.mapRotation () )
2824
- {
2825
- const QgsPoint& center = context.extent ().center ();
2826
- QTransform t = QTransform::fromTranslate ( center.x (), center.y () );
2827
- t.rotate ( -m2p.mapRotation () );
2828
- t.translate ( -center.x (), -center.y () );
2829
- qreal xPosR, yPosR;
2830
- qreal xPos_qreal = xPos, yPos_qreal = yPos;
2831
- t.map ( xPos_qreal, yPos_qreal, &xPosR, &yPosR );
2832
- xPos = xPosR;
2833
- yPos = yPosR;
2834
-
2810
+ QgsGeometry* newPoint = QgsPalLabeling::prepareGeometry ( &ddPoint, context, ct );
2811
+ xPos = static_cast < QgsPointV2* >( newPoint->geometry () )->x ();
2812
+ yPos = static_cast < QgsPointV2* >( newPoint->geometry () )->y ();
2813
+ delete newPoint;
2835
2814
}
2836
2815
2837
2816
xPos += xdiff;
0 commit comments