Skip to content
Permalink
Browse files

Use BoundingBoxes in labeling

Use BoundingBoxes to check faster if clipping is necessary
  • Loading branch information
ahuarte47 committed Mar 7, 2016
1 parent 697a25d commit b07bbd043dca0b6b682da5203695011ba867e959
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/core/qgspallabeling.cpp
@@ -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;
@@ -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 )

0 comments on commit b07bbd0

Please sign in to comment.
You can’t perform that action at this time.