Getting QGeoPositionInfo::Direction when using gpsd
-
Hi
I need Direction and GroundSpeed from gps, it is no problem when I'm using QGeoPositionInfo on mobile platform, QGeoPositionInfo has attributes QGeoPositionInfo::Direction and QGeoPositionInfo::GroundSpeed but when I try to use this when reading from gpsd:
tcpSocket->write("?WATCH={\"enable\":true,\"nmea\":true}\n"); nmeaSource=new QNmeaPositionInfoSource(QNmeaPositionInfoSource::RealTimeMode); nmeaSource->setUpdateInterval(1000); nmeaSource->setDevice(tcpSocket); connect(nmeaSource,SIGNAL(positionUpdated(QGeoPositionInfo)),this,SLOT(positionUpdated(QGeoPositionInfo))); nmeaSource->startUpdates();
I have this attribute only for a few first coordinates then Qt stops providing that.
When I check with gpsmon it always has correct Direction and Speed. How can I overcome that?Best,
Marek -
@Marek have you checked connecting QTcpSocket's error() signal?
What about capturing network traffic when you're using Qt app and then with the gpsmon tool and comparing them to see if you can find something there?
-
@Pablo-J.-Rogina I have function to check tcp socket errors
But I have reliable latitude and longitude data all the time, it's just Direction and GroundSpeed that is causing problem for me.
If I save previous coordinates given by Qt
QGeoCoordinate prev_coord=info.coordinate();
//later
QGeoCoordinate coord=info.coordinate();
I should be able to calculate bearing and distance (assuming I have gps coords once a second, it will be speed) myself using:
qreal azimuthTo(const QGeoCoordinate &other) const
qreal distanceTo(const QGeoCoordinate &other) constAm I right?
prev_coord.azimuthTo(coord)