Skip to content

Commit

Permalink
Check mode Field (#100)
Browse files Browse the repository at this point in the history
* Switching to use mode of fix instead of status to be more robust to changes in API

* Making altitude NaN if in 2D fix mode
  • Loading branch information
danthony06 authored May 9, 2024
1 parent 4e61959 commit c3331a7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gpsd_client/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ namespace gpsd_client
}
#if GPSD_API_MAJOR_VERSION >= 10
#ifdef STATUS_FIX
if ((p->fix.status != STATUS_NO_FIX) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
if (((p->fix.mode == MODE_2D) || (p->fix.mode == MODE_3D)) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
#else
if ((p->fix.status != STATUS_NO_FIX) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
if (((p->fix.mode == MODE_2D) || (p->fix.mode == MODE_3D)) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
#endif
#else
if ((p->status != STATUS_NO_FIX) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
if (((p->fix.mode == MODE_2D) || (p->fix.mode == MODE_3D)) && !(check_fix_by_variance_ && std::isnan(p->fix.epx)))
#endif
{
status.status = 0; // FIXME: gpsmm puts its constants in the global
Expand All @@ -208,7 +208,14 @@ namespace gpsd_client
#endif
fix.latitude = p->fix.latitude;
fix.longitude = p->fix.longitude;
fix.altitude = p->fix.altitude;
if (p->fix.mode == MODE_3D)
{
fix.altitude = p->fix.altitude;
}
else
{
fix.altitude = std::nan("");
}
fix.track = p->fix.track;
fix.speed = p->fix.speed;
fix.climb = p->fix.climb;
Expand Down

0 comments on commit c3331a7

Please sign in to comment.