Skip to content
Permalink
Browse files
refs #6956
Fix map frame resizing : do not touch the frame size, adapt the geometry's extent if needed
  • Loading branch information
Hugo Mercier committed Jan 14, 2013
1 parent 831f99a commit ca77a9876cb4dcd4dccc907d8e63fadcccf54287
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/core/composer/qgsatlascomposition.cpp
@@ -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 );

0 comments on commit ca77a98

Please sign in to comment.