From 1d97fa4e61df44c15e5ebcee146314d364d9b350 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 8 May 2019 15:26:53 +0200 Subject: [PATCH] Fix week rollover in RTCM messages --- src/algorithms/PVT/libs/rtcm.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/algorithms/PVT/libs/rtcm.cc b/src/algorithms/PVT/libs/rtcm.cc index e0a0c10a5..2d9e943d4 100644 --- a/src/algorithms/PVT/libs/rtcm.cc +++ b/src/algorithms/PVT/libs/rtcm.cc @@ -3402,6 +3402,13 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double { const double gps_t = obs_time; boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) + + if (eph.i_GPS_week < 512) + { + boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t); + return p_time; + } + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3411,6 +3418,13 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, d { const double gps_t = obs_time; boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) + + if (eph.i_GPS_week < 512) + { + boost::posix_time::ptime p_time(boost::gregorian::date(2019, 4, 7), t); + return p_time; + } + boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; }