Skip to content

Commit

Permalink
[gps] Fix incorrect double-reprojection of GPS marker position on
Browse files Browse the repository at this point in the history
canvas extent changes
  • Loading branch information
nyalldawson committed Jan 6, 2020
1 parent 494b52b commit e2bb325
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/gps/qgsgpsinformationwidget.cpp
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/app/gps/qgsgpsmarker.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -88,5 +88,6 @@ QRectF QgsGpsMarker::boundingRect() const

void QgsGpsMarker::updatePosition()
{
setCenter( mCenter );
QPointF pt = toCanvasCoordinates( mCenter );
setPos( pt );
}
7 changes: 5 additions & 2 deletions src/app/gps/qgsgpsmarker.h
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit e2bb325

Please sign in to comment.