Skip to content
Permalink
Browse files

Fix transform errors caused by GPS bearing update

The center was being double-transformed
  • Loading branch information
nyalldawson committed Feb 5, 2020
1 parent 60d89ec commit dcd144798b8d599375d2ab63df20913825ccef34
Showing with 10 additions and 3 deletions.
  1. +3 −2 src/app/gps/qgsgpsbearingitem.cpp
  2. +7 −1 src/app/gps/qgsgpsbearingitem.h
@@ -40,13 +40,14 @@ QgsGpsBearingItem::QgsGpsBearingItem( QgsMapCanvas *mapCanvas )

void QgsGpsBearingItem::setGpsPosition( const QgsPointXY &point )
{
mCenterWGS84 = point;
//transform to map crs
if ( mMapCanvas )
{
QgsCoordinateTransform t( mWgs84CRS, mMapCanvas->mapSettings().destinationCrs(), QgsProject::instance() );
try
{
mCenter = t.transform( point );
mCenter = t.transform( mCenterWGS84 );
}
catch ( QgsCsException &e ) //silently ignore transformation exceptions
{
@@ -69,7 +70,7 @@ void QgsGpsBearingItem::setGpsBearing( double bearing )

void QgsGpsBearingItem::updatePosition()
{
setGpsPosition( mCenter );
setGpsPosition( mCenterWGS84 );
}

void QgsGpsBearingItem::updateLine()
@@ -34,16 +34,22 @@ class QgsGpsBearingItem : public QObject, public QgsMapCanvasLineSymbolItem
public:
explicit QgsGpsBearingItem( QgsMapCanvas *mapCanvas );

/**
* Point is in WGS84
*/
void setGpsPosition( const QgsPointXY &point );
void setGpsBearing( double bearing );

void updatePosition() override;

protected:

//! coordinates of the point in the center
//! coordinates of the point in the center (map units)
QgsPointXY mCenter;

//! coordinates of the point in the center (WGS84)
QgsPointXY mCenterWGS84;

private:
void updateLine();

0 comments on commit dcd1447

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