24
24
25
25
26
26
QgsGpsMarker::QgsGpsMarker ( QgsMapCanvas* mapCanvas )
27
- : QgsMapCanvasItem( mapCanvas )
27
+ : QgsMapCanvasItem( mapCanvas )
28
28
{
29
29
mSize = 16 ;
30
30
mWgs84CRS .createFromEpsg ( 4326 );
@@ -38,10 +38,17 @@ void QgsGpsMarker::setSize( int theSize )
38
38
void QgsGpsMarker::setCenter ( const QgsPoint& point )
39
39
{
40
40
// transform to map crs
41
- if ( mMapCanvas && mMapCanvas ->mapRenderer () )
41
+ if ( mMapCanvas && mMapCanvas ->mapRenderer () )
42
42
{
43
43
QgsCoordinateTransform t ( mWgs84CRS , mMapCanvas ->mapRenderer ()->destinationSrs () );
44
- mCenter = t.transform ( point );
44
+ try
45
+ {
46
+ mCenter = t.transform ( point );
47
+ }
48
+ catch ( QgsCsException e ) // silently ignore transformation exceptions
49
+ {
50
+ return ;
51
+ }
45
52
}
46
53
else
47
54
{
@@ -55,7 +62,7 @@ void QgsGpsMarker::setCenter( const QgsPoint& point )
55
62
void QgsGpsMarker::paint ( QPainter* p )
56
63
{
57
64
QSvgRenderer mySVG;
58
- if ( !mySVG.load ( QString ( " :/images/north_arrows/gpsarrow2.svg" ) ) )
65
+ if ( !mySVG.load ( QString ( " :/images/north_arrows/gpsarrow2.svg" ) ) )
59
66
{
60
67
qDebug ( " GPS marker not found!" );
61
68
return ;
@@ -68,7 +75,7 @@ void QgsGpsMarker::paint( QPainter* p )
68
75
QRectF QgsGpsMarker::boundingRect () const
69
76
{
70
77
float myHalfSize = mSize / 2.0 ;
71
- return QRectF ( -myHalfSize, -myHalfSize, 2.0 * myHalfSize, 2.0 * myHalfSize );
78
+ return QRectF ( -myHalfSize, -myHalfSize, 2.0 * myHalfSize, 2.0 * myHalfSize );
72
79
}
73
80
74
81
void QgsGpsMarker::updatePosition ()
0 commit comments