Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2852 from ahuarte47/Labeling_CheckBoundingBoxes
[Improvement] Use BoundingBoxes in labeling
  • Loading branch information
nyalldawson committed Mar 7, 2016
2 parents a89b510 + b07bbd0 commit bd140a7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/qgspallabeling.cpp
Expand Up @@ -3827,17 +3827,17 @@ bool QgsPalLabeling::geometryRequiresPreparation( const QgsGeometry* geometry, Q
if ( ct )
return true;

//requires fixing
if ( geometry->type() == QGis::Polygon && !geometry->isGeosValid() )
return true;

//requires rotation
const QgsMapToPixel& m2p = context.mapToPixel();
if ( !qgsDoubleNear( m2p.mapRotation(), 0 ) )
return true;

//requires clip
if ( clipGeometry && !clipGeometry->contains( geometry ) )
if ( clipGeometry && !clipGeometry->boundingBox().contains( geometry->boundingBox() ) )
return true;

//requires fixing
if ( geometry->type() == QGis::Polygon && !geometry->isGeosValid() )
return true;

return false;
Expand Down Expand Up @@ -3944,7 +3944,9 @@ QgsGeometry* QgsPalLabeling::prepareGeometry( const QgsGeometry* geometry, QgsRe
clonedGeometry.reset( geom );
}

if ( clipGeometry && !clipGeometry->contains( geom ) )
if ( clipGeometry &&
(( qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->boundingBox().contains( geom->boundingBox() ) )
|| ( !qgsDoubleNear( m2p.mapRotation(), 0 ) && !clipGeometry->contains( geom ) ) ) )
{
QgsGeometry* clipGeom = geom->intersection( clipGeometry ); // creates new geometry
if ( !clipGeom )
Expand Down

0 comments on commit bd140a7

Please sign in to comment.