Skip to content

Commit

Permalink
Fix extent to determine center point for angle calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Aug 17, 2012
1 parent 3d380c6 commit a18e396
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/app/qgsdecorationnortharrow.cpp
Expand Up @@ -203,7 +203,15 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()

bool goodDirn = false;

if ( mapCanvas->layerCount() > 0 )
// Get the shown extent...
QgsRectangle canvasExtent = mapCanvas->extent();
// ... and all layers extent, ...
QgsRectangle fullExtent = mapCanvas->fullExtent();
// ... and combine
QgsRectangle extent = canvasExtent.intersect( & fullExtent );

// If no layers are added or shown, we can't get any direction
if ( mapCanvas->layerCount() > 0 && ! extent.isEmpty() )
{
QgsCoordinateReferenceSystem outputCRS = mapCanvas->mapRenderer()->destinationCrs();

Expand All @@ -216,7 +224,6 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()

QgsCoordinateTransform transform( outputCRS, ourCRS );

QgsRectangle extent = mapCanvas->extent();
QgsPoint p1( extent.center() );
// A point a bit above p1. XXX assumes that y increases up!!
// May need to involve the maptopixel transform if this proves
Expand Down

0 comments on commit a18e396

Please sign in to comment.