Skip to content

Commit 450c3ef

Browse files
committed
Fix missing labels if map rotation is enabled with OTF reprojection
(fix #12025)
1 parent d598069 commit 450c3ef

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

src/core/qgspallabeling.cpp

+27-11
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,33 @@ QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const
34573457
return 0;
34583458
}
34593459

3460+
// Rotate the geometry if needed, before clipping
3461+
const QgsMapToPixel& m2p = context.mapToPixel();
3462+
if ( !qgsDoubleNear( m2p.mapRotation(), 0 ) )
3463+
{
3464+
QgsPoint center = context.extent().center();
3465+
3466+
if ( ct )
3467+
{
3468+
try
3469+
{
3470+
center = ct->transform( center );
3471+
}
3472+
catch ( QgsCsException &cse )
3473+
{
3474+
Q_UNUSED( cse );
3475+
QgsDebugMsgLevel( QString( "Ignoring feature due to transformation exception" ), 4 );
3476+
return 0;
3477+
}
3478+
}
3479+
3480+
if ( geom->rotate( m2p.mapRotation(), center ) )
3481+
{
3482+
QgsDebugMsg( QString( "Error rotating geometry" ).arg( geom->exportToWkt() ) );
3483+
return 0;
3484+
}
3485+
}
3486+
34603487
if ( !geom->asGeos() )
34613488
return 0; // there is something really wrong with the geometry
34623489

@@ -3472,17 +3499,6 @@ QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const
34723499
clonedGeometry.reset( geom );
34733500
}
34743501

3475-
// Rotate the geometry if needed, before clipping
3476-
const QgsMapToPixel& m2p = context.mapToPixel();
3477-
if ( !qgsDoubleNear( m2p.mapRotation(), 0 ) )
3478-
{
3479-
if ( geom->rotate( m2p.mapRotation(), context.extent().center() ) )
3480-
{
3481-
QgsDebugMsg( QString( "Error rotating geometry" ).arg( geom->exportToWkt() ) );
3482-
return 0;
3483-
}
3484-
}
3485-
34863502
if ( clipGeometry && !clipGeometry->contains( geom ) )
34873503
{
34883504
QgsGeometry* clipGeom = geom->intersection( clipGeometry ); // creates new geometry

0 commit comments

Comments
 (0)