Skip to content
Permalink
Browse files

osm: transform extents to EPSG:4326 (fixes #8709)

  • Loading branch information
jef-n committed Feb 17, 2014
1 parent ebdcaa7 commit 7becd761af05d3946e3c94017cffacf5ed72be4e
Showing with 26 additions and 2 deletions.
  1. +26 −2 src/app/openstreetmap/qgsosmdownloaddialog.cpp
@@ -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"

@@ -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 );
}
@@ -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()

0 comments on commit 7becd76

Please sign in to comment.
You can’t perform that action at this time.