Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #386 from Oslandia/atlas
Fix atlas map resizing
  • Loading branch information
mhugent committed Jan 15, 2013
2 parents bdcb6c1 + ca77a98 commit 0357f0f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/core/composer/qgsatlascomposition.cpp
Expand Up @@ -216,19 +216,21 @@ void QgsAtlasComposition::prepareForFeature( size_t featureI )
// geometry height is too big
if ( geom_ratio < map_ratio )
{
new_extent = QgsRectangle(( xa1 + xa2 + map_ratio * ( ya1 - ya2 ) ) / 2.0,
ya1,
xa1 + map_ratio * ( ya2 - ya1 ),
ya2 );
// extent the bbox's width
double adj_width = ( map_ratio * geom_rect.height() - geom_rect.width() ) / 2.0;
xa1 -= adj_width;
xa2 += adj_width;
}
// geometry width is too big
else if ( geom_ratio > map_ratio )
{
new_extent = QgsRectangle( xa1,
( ya1 + ya2 + ( xa1 - xa2 ) / map_ratio ) / 2.0,
xa2,
ya1 + ( xa2 - xa1 ) / map_ratio );
// extent the bbox's height
double adj_height = (geom_rect.width() / map_ratio - geom_rect.height() ) / 2.0;
ya1 -= adj_height;
ya2 += adj_height;
}
new_extent = QgsRectangle( xa1, ya1, xa2, ya2 );

if ( mMargin > 0.0 )
{
new_extent.scale( 1 + mMargin );
Expand Down

0 comments on commit 0357f0f

Please sign in to comment.