Skip to content

Commit

Permalink
osm: transform extents to EPSG:4326 (fixes #8709)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 17, 2014
1 parent ebdcaa7 commit 7becd76
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/app/openstreetmap/qgsosmdownloaddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
#include <QMessageBox>
#include <QPushButton>

#include "qgis.h"
#include "qgisapp.h"
#include "qgsmapcanvas.h"
#include "qgsmaplayer.h"
#include "qgsmaplayerregistry.h"
#include "qgsrectangle.h"
#include "qgscoordinatetransform.h"

#include "qgsosmdownload.h"

Expand Down Expand Up @@ -96,7 +98,22 @@ void QgsOSMDownloadDialog::setRectReadOnly( bool readonly )

void QgsOSMDownloadDialog::onExtentCanvas()
{
setRect( QgisApp::instance()->mapCanvas()->extent() ); // TODO: transform to WGS84
QgsRectangle r( QgisApp::instance()->mapCanvas()->extent() );

if ( QgisApp::instance()->mapCanvas()->hasCrsTransformEnabled() )
{
QgsCoordinateReferenceSystem dst( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId );

QgsCoordinateTransform ct( QgisApp::instance()->mapCanvas()->mapRenderer()->destinationCrs(), dst );
r = ct.transformBoundingBox( r );
if ( !r.isFinite() )
{
QMessageBox::information( this, tr( "OpenStreetMap download" ), tr( "Could not transform canvas extent." ) );
return;
}
}

setRect( r );
setRectReadOnly( true );
cboLayers->setEnabled( false );
}
Expand Down Expand Up @@ -124,7 +141,14 @@ void QgsOSMDownloadDialog::onCurrentLayerChanged( int index )
if ( !layer )
return;

setRect( layer->extent() ); // TODO: transform to WGS84
QgsCoordinateReferenceSystem dst( GEOCRS_ID, QgsCoordinateReferenceSystem::InternalCrsId );

QgsCoordinateTransform ct( layer->crs(), dst );
QgsRectangle rect( ct.transformBoundingBox( layer->extent() ) );
if ( rect.isFinite() )
setRect( rect );
else
QMessageBox::information( this, tr( "OpenStreetMap download" ), tr( "Could not transform layer extent." ) );
}

void QgsOSMDownloadDialog::onBrowseClicked()
Expand Down

0 comments on commit 7becd76

Please sign in to comment.