diff --git a/src/FlightMap/FlightMap.qml b/src/FlightMap/FlightMap.qml index 4959a88cb6305c002dac1b8492d1bfdaa9a14f6f..ffa8eb6b983253c165f400687f60ce5385db0b9a 100644 --- a/src/FlightMap/FlightMap.qml +++ b/src/FlightMap/FlightMap.qml @@ -35,7 +35,7 @@ Map { property string mapName: 'defaultMap' property bool isSatelliteMap: activeMapType.name.indexOf("Satellite") > -1 || activeMapType.name.indexOf("Hybrid") > -1 property var gcsPosition: QGroundControl.qgcPositionManger.gcsPosition - property int gcsHeading: QGroundControl.qgcPositionManger.gcsHeading + property real gcsHeading: QGroundControl.qgcPositionManger.gcsHeading property bool userPanned: false ///< true: the user has manually panned the map property bool allowGCSLocationCenter: false ///< true: map will center/zoom to gcs location one time property bool allowVehicleLocationCenter: false ///< true: map will center/zoom to vehicle location one time diff --git a/src/PositionManager/PositionManager.cpp b/src/PositionManager/PositionManager.cpp index 7d5fab0d20925b05f141f4734ea22a89c8a416e0..e866ed5cefdc23efcd1e54f695422f1e842fc93a 100644 --- a/src/PositionManager/PositionManager.cpp +++ b/src/PositionManager/PositionManager.cpp @@ -13,12 +13,6 @@ QGCPositionManager::QGCPositionManager(QGCApplication* app, QGCToolbox* toolbox) : QGCTool (app, toolbox) - , _updateInterval (0) - , _gcsHeading (NAN) - , _currentSource (nullptr) - , _defaultSource (nullptr) - , _nmeaSource (nullptr) - , _simulatedSource (nullptr) { } @@ -34,6 +28,9 @@ void QGCPositionManager::setToolbox(QGCToolbox *toolbox) QGCTool::setToolbox(toolbox); //-- First see if plugin provides a position source _defaultSource = toolbox->corePlugin()->createPositionSource(this); + if (_defaultSource) { + _usingPluginSource = true; + } if (qgcApp()->runningUnitTests()) { // Units test on travis fail due to lack of position source @@ -91,7 +88,14 @@ void QGCPositionManager::_positionUpdated(const QGeoPositionInfo &update) _gcsPosition = newGCSPosition; emit gcsPositionChanged(_gcsPosition); } - if (newGCSHeading != _gcsHeading) { + + // At this point only plugins support gcs heading. The reason is that the quality of heading information from a local + // position device (not a compass) is unknown. In many cases it can only be trusted if the GCS location is moving above + // a certain rate of speed. When it is not, or the gcs is standing still the heading is just random. We don't want these + // random heading to be shown on the fly view. So until we can get a true compass based heading or some smarted heading quality + // information which takes into account the speed of movement we normally don't set a heading. We do use the heading though + // if the plugin overrides the position source. In that case we assume that it hopefully know what it is doing. + if (_usingPluginSource && newGCSHeading != _gcsHeading) { _gcsHeading = newGCSHeading; emit gcsHeadingChanged(_gcsHeading); } diff --git a/src/PositionManager/PositionManager.h b/src/PositionManager/PositionManager.h index 0f2d3a74c19f54f04429cbb8c410a0ec2381c8a3..a7e6b31ce19f352089a47ede9d369e646758d416 100644 --- a/src/PositionManager/PositionManager.h +++ b/src/PositionManager/PositionManager.h @@ -56,13 +56,14 @@ signals: void positionInfoUpdated(QGeoPositionInfo update); private: - int _updateInterval; + int _updateInterval = 0; QGeoPositionInfo _geoPositionInfo; QGeoCoordinate _gcsPosition; - qreal _gcsHeading; + qreal _gcsHeading = qQNaN(); - QGeoPositionInfoSource* _currentSource; - QGeoPositionInfoSource* _defaultSource; - QNmeaPositionInfoSource* _nmeaSource; - QGeoPositionInfoSource* _simulatedSource; + QGeoPositionInfoSource* _currentSource = nullptr; + QGeoPositionInfoSource* _defaultSource = nullptr; + QNmeaPositionInfoSource* _nmeaSource = nullptr; + QGeoPositionInfoSource* _simulatedSource = nullptr; + bool _usingPluginSource = false; };