Ignore:
Timestamp:
Sep 30, 2026, 10:52:22 PM (28 hours ago)
Author:
stuerze
Message:

some more fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/RTCM3/RTCM3coDecoder.cpp

    r11057 r11058  
    11321132  // Set _lastTime close to currentTime
    11331133  // ----------------------------------
     1134  if (_type == IGSssr) {
     1135    if      (epoSecGPS  != -1) _igsRefEpoSec = epoSecGPS;
     1136    else if (epoSecGal  != -1) _igsRefEpoSec = epoSecGal;
     1137    else if (epoSecQzss != -1) _igsRefEpoSec = epoSecQzss;
     1138    else if (epoSecSbas != -1) _igsRefEpoSec = epoSecSbas;
     1139  }
     1140
    11341141  if      (epoSecGPS != -1) {
    11351142    _lastTime.set(currentWeek, epoSecGPS);
    … …  
    11371144  else if (epoSecGlo != -1) {
    11381145    QDate date = dateAndTimeFromGPSweek(currentTime.gpsw(), currentTime.gpssec()).date();
     1146    double leap = gnumleap(date.year(), date.month(), date.day());
    11391147    // IGS-SSR: the SSR Epoch Time (IDF003, 20 bit) is given in one continuous
    11401148    // time scale for all GNSS, i.e. GPS seconds of week also for GLONASS
    1141     // (IGS SSR v1.00) - no conversion
     1149    // (IGS SSR v1.00) - no conversion. Old encoders (e.g. BNC before
     1150    // 2026-09-30) wrote UTC seconds of day instead: recognised by comparison
     1151    // with the GPS/Galileo epoch of the same stream and converted, with a
     1152    // warning, during a transition period.
     1153    if (_type == IGSssr && _igsRefEpoSec >= 0.0 &&
     1154        igsLegacyEpoch(epoSecGlo, fmod(_igsRefEpoSec - leap + 7 * 86400.0, 86400.0), 86400.0)) {
     1155      double sow = floor(_igsRefEpoSec / 86400.0) * 86400.0 + epoSecGlo + leap;
     1156      if      (sow - _igsRefEpoSec >  43200.0) sow -= 86400.0;
     1157      else if (_igsRefEpoSec - sow >  43200.0) sow += 86400.0;
     1158      epoSecGlo = sow;
     1159      bncTime& warned = _legacyEpochWarned['R'];
     1160      if (!warned.valid() || currentTime - warned >= 3600.0) {
     1161        warned = currentTime;
     1162        emit newMessage(_staID.toLatin1() + ": IGS-SSR GLONASS epoch time in outdated convention "
     1163                        "(UTC seconds of day instead of GPS seconds of week, IGS SSR v1.00 IDF003) "
     1164                        "detected and converted - the SSR encoder should be updated", true);
     1165      }
     1166    }
    11421167    if (_type == RTCMssr || _type == RTCMnewssr) {
    11431168      // Same GLONASS epoch wire convention (UTC+3h) as RTCMssr
    1144       epoSecGlo = epoSecGlo - 3 * 3600 + gnumleap(date.year(), date.month(), date.day());
     1169      epoSecGlo = epoSecGlo - 3 * 3600 + leap;
    11451170    }
    11461171    _lastTime.set(currentWeek, epoSecGlo);
    … …  
    11561181  }
    11571182  else if (epoSecBds != -1) {
    1158     // RTCM-SSR: BDT; IGS-SSR: GPS time scale for all GNSS (IDF003)
    1159     if (_type != IGSssr) {
     1183    // RTCM-SSR: BDT; IGS-SSR: GPS time scale for all GNSS (IDF003). Old
     1184    // IGS-SSR encoders wrote BDT: recognised and converted as for GLONASS.
     1185    bool bdt = (_type != IGSssr);
     1186    if (_type == IGSssr && _igsRefEpoSec >= 0.0 &&
     1187        igsLegacyEpoch(epoSecBds, fmod(_igsRefEpoSec - 14.0 + 604800.0, 604800.0), 604800.0)) {
     1188      bdt = true;
     1189      bncTime& warned = _legacyEpochWarned['C'];
     1190      if (!warned.valid() || currentTime - warned >= 3600.0) {
     1191        warned = currentTime;
     1192        emit newMessage(_staID.toLatin1() + ": IGS-SSR BDS epoch time in outdated convention "
     1193                        "(BDT instead of GPS seconds of week, IGS SSR v1.00 IDF003) "
     1194                        "detected and converted - the SSR encoder should be updated", true);
     1195      }
     1196    }
     1197    if (bdt) {
    11601198      epoSecBds += 14.0;
    11611199      if (epoSecBds > 604800.0) {
    … …  
    11821220    }
    11831221  }
     1222}
     1223
     1224// IGS-SSR: true if value (seconds, periodic with period) matches the epoch
     1225// expected in the outdated convention (legacyRef) better than the GPS time
     1226// reference of the stream, within the spread of epochs of one update cycle
     1227////////////////////////////////////////////////////////////////////////////
     1228bool RTCM3coDecoder::igsLegacyEpoch(double value, double legacyRef, double period) const {
     1229  auto dist = [period](double a, double b) {
     1230    double d = fmod(fabs(a - b), period);
     1231    return std::min(d, period - d);
     1232  };
     1233  double dSpec   = dist(value, fmod(_igsRefEpoSec, period));
     1234  double dLegacy = dist(value, legacyRef);
     1235  return dLegacy < dSpec && dLegacy <= 30.0;
    11841236}
    11851237
Note: See TracChangeset for help on using the changeset viewer.