Navigation Menu

Skip to content

Commit

Permalink
Fix missing labels if map rotation is enabled with OTF reprojection
Browse files Browse the repository at this point in the history
(fix #12025)
  • Loading branch information
nyalldawson committed Jun 2, 2015
1 parent d598069 commit 450c3ef
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/core/qgspallabeling.cpp
Expand Up @@ -3457,6 +3457,33 @@ QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, const
return 0;
}

// Rotate the geometry if needed, before clipping
const QgsMapToPixel& m2p = context.mapToPixel();
if ( !qgsDoubleNear( m2p.mapRotation(), 0 ) )
{
QgsPoint center = context.extent().center();

if ( ct )
{
try
{
center = ct->transform( center );
}
catch ( QgsCsException &cse )
{
Q_UNUSED( cse );
QgsDebugMsgLevel( QString( "Ignoring feature due to transformation exception" ), 4 );
return 0;
}
}

if ( geom->rotate( m2p.mapRotation(), center ) )
{
QgsDebugMsg( QString( "Error rotating geometry" ).arg( geom->exportToWkt() ) );
return 0;
}
}

if ( !geom->asGeos() )
return 0; // there is something really wrong with the geometry

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

// Rotate the geometry if needed, before clipping
const QgsMapToPixel& m2p = context.mapToPixel();
if ( !qgsDoubleNear( m2p.mapRotation(), 0 ) )
{
if ( geom->rotate( m2p.mapRotation(), context.extent().center() ) )
{
QgsDebugMsg( QString( "Error rotating geometry" ).arg( geom->exportToWkt() ) );
return 0;
}
}

if ( clipGeometry && !clipGeometry->contains( geom ) )
{
QgsGeometry* clipGeom = geom->intersection( clipGeometry ); // creates new geometry
Expand Down

2 comments on commit 450c3ef

@isabellams
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @nyalldawson ! I have the same problem with labels rotation in QGIS 2.10 and 2.12, how can I get the latest version fixed by you? I've tried to update QGIS, now there're QGIS 2.12.3 and QGIS 2.13.0 installed on my PC and none of them solves the problem.

@gioman
Copy link
Contributor

@gioman gioman commented on 450c3ef Feb 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @isabellams this fix was not for label rotation, but for labels when the map canvas is rotated. What's your issue with labels rotation? Anyway questions like this are better suited for the users or developers mailing lists.

Please sign in to comment.