mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-06 00:03:16 -05:00
Inizialize QgsGpsInformation with sane values, add QgsGpsInformation::isValid and QgsGpsInformation::fixStatus
This commit is contained in:
parent
fc79502763
commit
3cf94e98fc
@ -22,25 +22,48 @@ struct QgsSatelliteInfo
|
||||
|
||||
struct QgsGpsInformation
|
||||
{
|
||||
|
||||
enum FixStatus
|
||||
{
|
||||
NoData,
|
||||
NoFix,
|
||||
Fix2D,
|
||||
Fix3D
|
||||
};
|
||||
|
||||
double latitude;
|
||||
double longitude;
|
||||
double elevation;
|
||||
double speed; //in km/h
|
||||
double speed;
|
||||
double direction;
|
||||
QList<QgsSatelliteInfo> satellitesInView;
|
||||
double pdop;
|
||||
double hdop;
|
||||
double vdop;
|
||||
double hacc; //horizontal accuracy in meters
|
||||
double vacc; //vertical accuracy in meters
|
||||
double hacc;
|
||||
double vacc;
|
||||
QDateTime utcDateTime;
|
||||
QChar fixMode;
|
||||
int fixType;
|
||||
int quality; // from GPGGA
|
||||
int satellitesUsed; // from GPGGA
|
||||
int quality;
|
||||
int satellitesUsed;
|
||||
QChar status; // from GPRMC A,V
|
||||
QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
|
||||
bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
|
||||
bool satInfoComplete;
|
||||
|
||||
bool isValid() const;
|
||||
%Docstring
|
||||
Returns whether the connection information is valid
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
FixStatus fixStatus() const;
|
||||
%Docstring
|
||||
Returns the fix status
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
};
|
||||
|
||||
class QgsGpsConnection : QObject
|
||||
|
||||
@ -25,6 +25,48 @@
|
||||
|
||||
#include "qgsnmeaconnection.h"
|
||||
#include "qgslogger.h"
|
||||
#include "info.h"
|
||||
|
||||
|
||||
bool QgsGpsInformation::isValid() const
|
||||
{
|
||||
bool valid = false;
|
||||
if ( status == 'V' || fixType == NMEA_FIX_BAD || quality == 0 ) // some sources say that 'V' indicates position fix, but is below acceptable quality
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if ( fixType == NMEA_FIX_2D )
|
||||
{
|
||||
valid = true;
|
||||
}
|
||||
else if ( status == 'A' || fixType == NMEA_FIX_3D || quality > 0 ) // good
|
||||
{
|
||||
valid = true;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
QgsGpsInformation::FixStatus QgsGpsInformation::fixStatus() const
|
||||
{
|
||||
FixStatus fixStatus = NoData;
|
||||
|
||||
// no fix if any of the three report bad; default values are invalid values and won't be changed if the corresponding NMEA msg is not received
|
||||
if ( status == 'V' || fixType == NMEA_FIX_BAD || quality == 0 ) // some sources say that 'V' indicates position fix, but is below acceptable quality
|
||||
{
|
||||
fixStatus = NoFix;
|
||||
}
|
||||
else if ( fixType == NMEA_FIX_2D ) // 2D indication (from GGA)
|
||||
{
|
||||
fixStatus = Fix2D;
|
||||
}
|
||||
else if ( status == 'A' || fixType == NMEA_FIX_3D || quality > 0 ) // good
|
||||
{
|
||||
fixStatus = Fix3D;
|
||||
}
|
||||
return fixStatus;
|
||||
}
|
||||
|
||||
|
||||
QgsGpsConnection::QgsGpsConnection( QIODevice *dev ): QObject( nullptr ), mSource( dev ), mStatus( NotConnected )
|
||||
{
|
||||
@ -82,24 +124,5 @@ void QgsGpsConnection::setSource( QIODevice *source )
|
||||
|
||||
void QgsGpsConnection::clearLastGPSInformation()
|
||||
{
|
||||
mLastGPSInformation.direction = 0;
|
||||
mLastGPSInformation.elevation = 0;
|
||||
mLastGPSInformation.hdop = 0;
|
||||
mLastGPSInformation.latitude = 0;
|
||||
mLastGPSInformation.longitude = 0;
|
||||
mLastGPSInformation.pdop = 0;
|
||||
mLastGPSInformation.satellitesInView.clear();
|
||||
mLastGPSInformation.speed = 0;
|
||||
mLastGPSInformation.vdop = 0;
|
||||
mLastGPSInformation.hacc = -1;
|
||||
mLastGPSInformation.vacc = -1;
|
||||
mLastGPSInformation.quality = -1; // valid values: 0,1,2, maybe others
|
||||
mLastGPSInformation.satellitesUsed = 0;
|
||||
mLastGPSInformation.fixMode = ' ';
|
||||
mLastGPSInformation.fixType = 0; // valid values: 1,2,3
|
||||
mLastGPSInformation.status = ' '; // valid values: A,V
|
||||
mLastGPSInformation.utcDateTime.setDate( QDate() );
|
||||
mLastGPSInformation.satPrn.clear();
|
||||
mLastGPSInformation.utcDateTime.setTime( QTime() );
|
||||
mLastGPSInformation.satInfoComplete = false;
|
||||
mLastGPSInformation = QgsGpsInformation();
|
||||
}
|
||||
|
||||
@ -38,25 +38,50 @@ struct CORE_EXPORT QgsSatelliteInfo
|
||||
|
||||
struct CORE_EXPORT QgsGpsInformation
|
||||
{
|
||||
double latitude;
|
||||
double longitude;
|
||||
double elevation;
|
||||
double speed; //in km/h
|
||||
double direction;
|
||||
|
||||
/**
|
||||
* GPS fix status
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
enum FixStatus
|
||||
{
|
||||
NoData,
|
||||
NoFix,
|
||||
Fix2D,
|
||||
Fix3D
|
||||
};
|
||||
|
||||
double latitude = 0;
|
||||
double longitude = 0;
|
||||
double elevation = 0;
|
||||
double speed = 0; //in km/h
|
||||
double direction = 0;
|
||||
QList<QgsSatelliteInfo> satellitesInView;
|
||||
double pdop;
|
||||
double hdop;
|
||||
double vdop;
|
||||
double hacc; //horizontal accuracy in meters
|
||||
double vacc; //vertical accuracy in meters
|
||||
double pdop = 0;
|
||||
double hdop = 0;
|
||||
double vdop = 0;
|
||||
double hacc = -1; //horizontal accuracy in meters
|
||||
double vacc = -1; //vertical accuracy in meters
|
||||
QDateTime utcDateTime;
|
||||
QChar fixMode;
|
||||
int fixType;
|
||||
int quality; // from GPGGA
|
||||
int satellitesUsed; // from GPGGA
|
||||
int fixType = 0; // valid values: 1,2,3
|
||||
int quality = -1; // from GPGGA, valid values: 0,1,2, maybe others
|
||||
int satellitesUsed = 0; // from GPGGA
|
||||
QChar status; // from GPRMC A,V
|
||||
QList<int> satPrn; // list of SVs in use; needed for QgsSatelliteInfo.inUse and other uses
|
||||
bool satInfoComplete; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
|
||||
bool satInfoComplete = false; // based on GPGSV sentences - to be used to determine when to graph signal and satellite position
|
||||
|
||||
/**
|
||||
* Returns whether the connection information is valid
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
bool isValid() const;
|
||||
|
||||
/**
|
||||
* Returns the fix status
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
FixStatus fixStatus() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user