Skip to content
Permalink
Browse files
Fix missing labels if map rotation is enabled with OTF reprojection
(fix #12025)
  • Loading branch information
nyalldawson committed Jun 2, 2015
1 parent d598069 commit 450c3effd51c5be5f99cb2ddf52c181be4f04f08
Showing with 27 additions and 11 deletions.
  1. +27 −11 src/core/qgspallabeling.cpp
@@ -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

@@ -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

2 comments on commit 450c3ef

@isabellams

This comment has been minimized.

Copy link

@isabellams isabellams replied Feb 4, 2016

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

This comment has been minimized.

Copy link
Contributor

@gioman gioman replied Feb 4, 2016

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.