Skip to content
Permalink
Browse files

[gps] Fix incorrect double-reprojection of GPS marker position on

canvas extent changes
  • Loading branch information
nyalldawson committed Jan 6, 2020
1 parent 494b52b commit e2bb325c3e50b80a820380500277a37590942752
Showing with 9 additions and 5 deletions.
  1. +1 −1 src/app/gps/qgsgpsinformationwidget.cpp
  2. +3 −2 src/app/gps/qgsgpsmarker.cpp
  3. +5 −2 src/app/gps/qgsgpsmarker.h
@@ -953,7 +953,7 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in
mMapMarker = new QgsGpsMarker( mMapCanvas );
}
mMapMarker->setSize( mSliderMarkerSize->value() );
mMapMarker->setCenter( myNewCenter );
mMapMarker->setGpsPosition( myNewCenter );
}
}
else
@@ -38,7 +38,7 @@ void QgsGpsMarker::setSize( int size )
mSize = size;
}

void QgsGpsMarker::setCenter( const QgsPointXY &point )
void QgsGpsMarker::setGpsPosition( const QgsPointXY &point )
{
//transform to map crs
if ( mMapCanvas )
@@ -88,5 +88,6 @@ QRectF QgsGpsMarker::boundingRect() const

void QgsGpsMarker::updatePosition()
{
setCenter( mCenter );
QPointF pt = toCanvasCoordinates( mCenter );
setPos( pt );
}
@@ -32,7 +32,10 @@ class QgsGpsMarker : public QgsMapCanvasItem
public:
explicit QgsGpsMarker( QgsMapCanvas *mapCanvas );

void setCenter( const QgsPointXY &point );
/**
* Sets the current GPS \a position (in WGS84 coordinate reference system).
*/
void setGpsPosition( const QgsPointXY &position );

void paint( QPainter *p ) override;

@@ -44,7 +47,7 @@ class QgsGpsMarker : public QgsMapCanvasItem

protected:

//! coordinates of the point in the center
//! Coordinates of the point in the center, in map CRS
QgsPointXY mCenter;
//! Size of the marker - e.g. 8 will draw it as 8x8
int mSize;

0 comments on commit e2bb325

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