Skip to content

Commit

Permalink
Use BoundingBoxes in labeling
Browse files Browse the repository at this point in the history
Use BoundingBoxes to check faster if clipping is necessary
  • Loading branch information
ahuarte47 committed Mar 7, 2016
1 parent 697a25d commit b07bbd0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
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 b07bbd0

Please sign in to comment.