Skip to content

Commit

Permalink
Catch crs transformation exceptions in gpsmarker
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14437 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Oct 27, 2010
1 parent d8ae3c1 commit 3c8f026
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/app/gps/qgsgpsmarker.cpp
Expand Up @@ -24,7 +24,7 @@


QgsGpsMarker::QgsGpsMarker( QgsMapCanvas* mapCanvas )
: QgsMapCanvasItem( mapCanvas )
: QgsMapCanvasItem( mapCanvas )
{
mSize = 16;
mWgs84CRS.createFromEpsg( 4326 );
Expand All @@ -38,10 +38,17 @@ void QgsGpsMarker::setSize( int theSize )
void QgsGpsMarker::setCenter( const QgsPoint& point )
{
//transform to map crs
if ( mMapCanvas && mMapCanvas->mapRenderer() )
if( mMapCanvas && mMapCanvas->mapRenderer() )
{
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapRenderer()->destinationSrs() );
mCenter = t.transform( point );
try
{
mCenter = t.transform( point );
}
catch( QgsCsException e ) //silently ignore transformation exceptions
{
return;
}
}
else
{
Expand All @@ -55,7 +62,7 @@ void QgsGpsMarker::setCenter( const QgsPoint& point )
void QgsGpsMarker::paint( QPainter* p )
{
QSvgRenderer mySVG;
if ( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
if( !mySVG.load( QString( ":/images/north_arrows/gpsarrow2.svg" ) ) )
{
qDebug( "GPS marker not found!" );
return;
Expand All @@ -68,7 +75,7 @@ void QgsGpsMarker::paint( QPainter* p )
QRectF QgsGpsMarker::boundingRect() const
{
float myHalfSize = mSize / 2.0;
return QRectF( -myHalfSize, -myHalfSize, 2.0*myHalfSize, 2.0*myHalfSize );
return QRectF( -myHalfSize, -myHalfSize, 2.0 * myHalfSize, 2.0 * myHalfSize );
}

void QgsGpsMarker::updatePosition()
Expand Down

0 comments on commit 3c8f026

Please sign in to comment.