gnss-js 1.42.0 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -155,6 +155,7 @@ __export(src_exports, {
155
155
  estimateWidelaneFcb: () => estimateWidelaneFcb,
156
156
  euclidean3D: () => euclidean3D,
157
157
  extractWidelaneArcs: () => extractWidelaneArcs,
158
+ feedGeoBlock: () => feedGeoBlock,
158
159
  fetchSourcetable: () => fetchSourcetable,
159
160
  findSatBias: () => findSatBias,
160
161
  fixPppPosition: () => fixPppPosition,
@@ -260,6 +261,7 @@ __export(src_exports, {
260
261
  parseSbfBdsNav: () => parseSbfBdsNav,
261
262
  parseSbfCnav: () => parseSbfCnav,
262
263
  parseSbfGalNav: () => parseSbfGalNav,
264
+ parseSbfGeoNav: () => parseSbfGeoNav,
263
265
  parseSbfGloNav: () => parseSbfGloNav,
264
266
  parseSbfGpsNav: () => parseSbfGpsNav,
265
267
  parseSbfHas: () => parseSbfHas,
@@ -6781,19 +6783,65 @@ var GloStringAssembler = class {
6781
6783
  }
6782
6784
  };
6783
6785
 
6784
- // src/ubx/rawnav.ts
6786
+ // src/navbits/sbas.ts
6785
6787
  var GPS_EPOCH_MS7 = Date.UTC(1980, 0, 6);
6786
- var SEC_PER_WEEK7 = 7 * 86400;
6788
+ var MS_PER_WEEK3 = 7 * 86400 * 1e3;
6787
6789
  var two2 = (n) => String(n).padStart(2, "0");
6790
+ var SBAS_MT_GEO_NAV = 9;
6791
+ function sbasMessageType(msg) {
6792
+ return getBitU(msg, 8, 6);
6793
+ }
6794
+ function sbasCrcOk(msg) {
6795
+ if (msg.length < 32) return false;
6796
+ return crc24q(msg, 226) === getBitU(msg, 226, 24);
6797
+ }
6798
+ function decodeSbasGeoNav(msg, prn, week, tow) {
6799
+ if (prn < 120 || prn > 158) return null;
6800
+ if (sbasMessageType(msg) !== SBAS_MT_GEO_NAV) return null;
6801
+ let t = getBitU(msg, 22, 13) * 16 - tow % 86400;
6802
+ if (t <= -43200) t += 86400;
6803
+ else if (t > 43200) t -= 86400;
6804
+ const t0Sec = tow + t;
6805
+ const ura = getBitU(msg, 35, 4);
6806
+ return {
6807
+ system: "S",
6808
+ prn: `S${two2(prn - 100)}`,
6809
+ tocDate: new Date(GPS_EPOCH_MS7 + week * MS_PER_WEEK3 + t0Sec * 1e3),
6810
+ tauN: getBitS(msg, 206, 12) * 2 ** -31,
6811
+ // a_Gf0, clock offset (s)
6812
+ gammaN: getBitS(msg, 218, 8) * 2 ** -39 / 2,
6813
+ // a_Gf1, clock drift (s/s)
6814
+ messageFrameTime: (tow % 86400 + 86400) % 86400,
6815
+ x: getBitS(msg, 39, 30) * 0.08 / 1e3,
6816
+ y: getBitS(msg, 69, 30) * 0.08 / 1e3,
6817
+ z: getBitS(msg, 99, 25) * 0.4 / 1e3,
6818
+ xDot: getBitS(msg, 124, 17) * 625e-6 / 1e3,
6819
+ yDot: getBitS(msg, 141, 17) * 625e-6 / 1e3,
6820
+ zDot: getBitS(msg, 158, 18) * 4e-3 / 1e3,
6821
+ xAcc: getBitS(msg, 176, 10) * 125e-7 / 1e3,
6822
+ yAcc: getBitS(msg, 186, 10) * 125e-7 / 1e3,
6823
+ zAcc: getBitS(msg, 196, 10) * 625e-7 / 1e3,
6824
+ health: ura === 15 ? 1 : 0,
6825
+ freqNum: 0
6826
+ };
6827
+ }
6828
+
6829
+ // src/ubx/rawnav.ts
6830
+ var GPS_EPOCH_MS8 = Date.UTC(1980, 0, 6);
6831
+ var SEC_PER_WEEK7 = 7 * 86400;
6832
+ var two3 = (n) => String(n).padStart(2, "0");
6788
6833
  function parseUbxRawNav(data, opts = {}) {
6789
6834
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
6790
6835
  const ephemerides = [];
6791
- const counts = { gal: 0, bds: 0, glo: 0 };
6836
+ const counts = { gal: 0, bds: 0, glo: 0, sbas: 0 };
6792
6837
  let badParity = 0;
6793
6838
  const inav = new GalInavAssembler();
6794
6839
  const bds = new BdsAssembler();
6795
6840
  const glo = new GloStringAssembler();
6796
6841
  let refDate = null;
6842
+ let refWeek = 0;
6843
+ let refTow = 0;
6844
+ const sbasSeen = /* @__PURE__ */ new Set();
6797
6845
  for (const f of ubxFrames(data)) {
6798
6846
  if (f.msgClass !== 2) continue;
6799
6847
  if (f.msgId === 21 && f.payload.length >= 16) {
@@ -6802,8 +6850,10 @@ function parseUbxRawNav(data, opts = {}) {
6802
6850
  if (week === 0 && opts.refWeek !== void 0) week = opts.refWeek;
6803
6851
  if (week > 0) {
6804
6852
  refDate = new Date(
6805
- GPS_EPOCH_MS7 + (week * SEC_PER_WEEK7 + rcvTow) * 1e3
6853
+ GPS_EPOCH_MS8 + (week * SEC_PER_WEEK7 + rcvTow) * 1e3
6806
6854
  );
6855
+ refWeek = week;
6856
+ refTow = rcvTow;
6807
6857
  }
6808
6858
  continue;
6809
6859
  }
@@ -6855,7 +6905,7 @@ function parseUbxRawNav(data, opts = {}) {
6855
6905
  badParity++;
6856
6906
  continue;
6857
6907
  }
6858
- const eph = bds.push(`C${two2(svId)}`, sf);
6908
+ const eph = bds.push(`C${two3(svId)}`, sf);
6859
6909
  if (eph) ephemerides.push(eph);
6860
6910
  } else if (gnssId === 6) {
6861
6911
  if (p.length < 8 + 16) continue;
@@ -6874,16 +6924,41 @@ function parseUbxRawNav(data, opts = {}) {
6874
6924
  continue;
6875
6925
  }
6876
6926
  if (!refDate) continue;
6877
- const eph = glo.push(`R${two2(svId)}`, str2, refDate, p[3] - 7);
6927
+ const eph = glo.push(`R${two3(svId)}`, str2, refDate, p[3] - 7);
6878
6928
  if (eph) ephemerides.push(eph);
6929
+ } else if (gnssId === 1) {
6930
+ if (p.length < 8 + 32) continue;
6931
+ counts.sbas++;
6932
+ if (svId < 120 || svId > 158) continue;
6933
+ const msg = new Uint8Array(32);
6934
+ for (let k = 0; k < 8; k++) {
6935
+ const w = view.getUint32(base + 4 * k, true);
6936
+ msg[4 * k] = w >>> 24;
6937
+ msg[4 * k + 1] = w >>> 16 & 255;
6938
+ msg[4 * k + 2] = w >>> 8 & 255;
6939
+ msg[4 * k + 3] = w & 255;
6940
+ }
6941
+ if (!sbasCrcOk(msg)) {
6942
+ badParity++;
6943
+ continue;
6944
+ }
6945
+ if (refWeek === 0) continue;
6946
+ const eph = decodeSbasGeoNav(msg, svId, refWeek, refTow);
6947
+ if (eph) {
6948
+ const key = `${eph.prn}@${eph.tocDate.getTime()}`;
6949
+ if (!sbasSeen.has(key)) {
6950
+ sbasSeen.add(key);
6951
+ ephemerides.push(eph);
6952
+ }
6953
+ }
6879
6954
  }
6880
6955
  }
6881
6956
  return { ephemerides, counts, badParity };
6882
6957
  }
6883
6958
 
6884
6959
  // src/ubx/index.ts
6885
- var GPS_EPOCH_MS8 = Date.UTC(1980, 0, 6);
6886
- var MS_PER_WEEK3 = 7 * 864e5;
6960
+ var GPS_EPOCH_MS9 = Date.UTC(1980, 0, 6);
6961
+ var MS_PER_WEEK4 = 7 * 864e5;
6887
6962
  var SIGNALS = {
6888
6963
  0: { 0: ["G", "1C"], 3: ["G", "2X"], 4: ["G", "2X"] },
6889
6964
  // GPS L1C/A, L2CL, L2CM
@@ -6899,20 +6974,20 @@ var SIGNALS = {
6899
6974
  // GLONASS L1OF, L2OF
6900
6975
  };
6901
6976
  function prnFor(gnssId, svId) {
6902
- const two7 = (n) => String(n).padStart(2, "0");
6977
+ const two8 = (n) => String(n).padStart(2, "0");
6903
6978
  switch (gnssId) {
6904
6979
  case 0:
6905
- return svId >= 1 && svId <= 32 ? `G${two7(svId)}` : null;
6980
+ return svId >= 1 && svId <= 32 ? `G${two8(svId)}` : null;
6906
6981
  case 1:
6907
- return svId >= 120 && svId <= 158 ? `S${two7(svId - 100)}` : null;
6982
+ return svId >= 120 && svId <= 158 ? `S${two8(svId - 100)}` : null;
6908
6983
  case 2:
6909
- return svId >= 1 && svId <= 36 ? `E${two7(svId)}` : null;
6984
+ return svId >= 1 && svId <= 36 ? `E${two8(svId)}` : null;
6910
6985
  case 3:
6911
- return svId >= 1 && svId <= 63 ? `C${two7(svId)}` : null;
6986
+ return svId >= 1 && svId <= 63 ? `C${two8(svId)}` : null;
6912
6987
  case 5:
6913
- return svId >= 1 && svId <= 10 ? `J${two7(svId)}` : null;
6988
+ return svId >= 1 && svId <= 10 ? `J${two8(svId)}` : null;
6914
6989
  case 6:
6915
- return svId >= 1 && svId <= 32 ? `R${two7(svId)}` : null;
6990
+ return svId >= 1 && svId <= 32 ? `R${two8(svId)}` : null;
6916
6991
  default:
6917
6992
  return null;
6918
6993
  }
@@ -6965,7 +7040,7 @@ function parseUbxRawx(data) {
6965
7040
  if (!codes.includes(sig[1])) codes.push(sig[1]);
6966
7041
  }
6967
7042
  epochs.push({
6968
- timeMs: GPS_EPOCH_MS8 + week * MS_PER_WEEK3 + Math.round(rcvTow * 1e3),
7043
+ timeMs: GPS_EPOCH_MS9 + week * MS_PER_WEEK4 + Math.round(rcvTow * 1e3),
6969
7044
  leapS: leapValid ? leapS : null,
6970
7045
  meas
6971
7046
  });
@@ -7015,31 +7090,31 @@ function scanSbfFrames(data, view, onBlock) {
7015
7090
  }
7016
7091
  return badCrc;
7017
7092
  }
7018
- var two3 = (n) => String(n).padStart(2, "0");
7093
+ var two4 = (n) => String(n).padStart(2, "0");
7019
7094
  function svidToPrn(svid) {
7020
- if (svid >= 1 && svid <= 37) return svid <= 32 ? `G${two3(svid)}` : null;
7021
- if (svid <= 61) return svid - 37 <= 27 ? `R${two3(svid - 37)}` : null;
7095
+ if (svid >= 1 && svid <= 37) return svid <= 32 ? `G${two4(svid)}` : null;
7096
+ if (svid <= 61) return svid - 37 <= 27 ? `R${two4(svid - 37)}` : null;
7022
7097
  if (svid <= 62) return null;
7023
- if (svid <= 68) return svid - 38 <= 27 ? `R${two3(svid - 38)}` : null;
7098
+ if (svid <= 68) return svid - 38 <= 27 ? `R${two4(svid - 38)}` : null;
7024
7099
  if (svid <= 70) return null;
7025
- if (svid <= 106) return svid - 70 <= 36 ? `E${two3(svid - 70)}` : null;
7100
+ if (svid <= 106) return svid - 70 <= 36 ? `E${two4(svid - 70)}` : null;
7026
7101
  if (svid <= 119) return null;
7027
- if (svid <= 140) return `S${two3(svid - 100)}`;
7028
- if (svid <= 180) return svid - 140 <= 50 ? `C${two3(svid - 140)}` : null;
7029
- if (svid <= 190) return `J${two3(svid - 180)}`;
7030
- if (svid <= 197) return svid - 190 <= 14 ? `I${two3(svid - 190)}` : null;
7031
- if (svid <= 215) return `S${two3(svid - 157)}`;
7032
- if (svid <= 222) return svid - 208 <= 14 ? `I${two3(svid - 208)}` : null;
7033
- if (svid <= 245) return svid - 182 <= 50 ? `C${two3(svid - 182)}` : null;
7102
+ if (svid <= 140) return `S${two4(svid - 100)}`;
7103
+ if (svid <= 180) return svid - 140 <= 50 ? `C${two4(svid - 140)}` : null;
7104
+ if (svid <= 190) return `J${two4(svid - 180)}`;
7105
+ if (svid <= 197) return svid - 190 <= 14 ? `I${two4(svid - 190)}` : null;
7106
+ if (svid <= 215) return `S${two4(svid - 157)}`;
7107
+ if (svid <= 222) return svid - 208 <= 14 ? `I${two4(svid - 208)}` : null;
7108
+ if (svid <= 245) return svid - 182 <= 50 ? `C${two4(svid - 182)}` : null;
7034
7109
  return null;
7035
7110
  }
7036
7111
 
7037
7112
  // src/sbf/nav.ts
7038
7113
  var PI2 = Math.PI;
7039
- var GPS_EPOCH_MS9 = Date.UTC(1980, 0, 6);
7114
+ var GPS_EPOCH_MS10 = Date.UTC(1980, 0, 6);
7040
7115
  var BDT_EPOCH_MS2 = Date.UTC(2006, 0, 1);
7041
7116
  var SEC_PER_WEEK8 = 7 * 86400;
7042
- var MS_PER_WEEK4 = SEC_PER_WEEK8 * 1e3;
7117
+ var MS_PER_WEEK5 = SEC_PER_WEEK8 * 1e3;
7043
7118
  var F4_DNU = -2e10;
7044
7119
  var U4_DNU = 4294967295;
7045
7120
  function adjustWeek(refWeek, wn, mod) {
@@ -7048,7 +7123,7 @@ function adjustWeek(refWeek, wn, mod) {
7048
7123
  if (offset < -(mod / 2 - 1)) offset += mod;
7049
7124
  return refWeek - offset;
7050
7125
  }
7051
- var gpsMs = (week, sec) => GPS_EPOCH_MS9 + week * MS_PER_WEEK4 + sec * 1e3;
7126
+ var gpsMs = (week, sec) => GPS_EPOCH_MS10 + week * MS_PER_WEEK5 + sec * 1e3;
7052
7127
  var sowOf2 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK8;
7053
7128
  function decodeGpsQzsNav(view, b, sys) {
7054
7129
  const svid = view.getUint8(b + 14);
@@ -7152,7 +7227,7 @@ function decodeBdsNav(view, b) {
7152
7227
  const toes = view.getUint32(b + 88, true);
7153
7228
  const wnToc = adjustWeek(bdsWeekRef, view.getUint16(b + 136, true), 8192);
7154
7229
  const wnToe = adjustWeek(bdsWeekRef, view.getUint16(b + 138, true), 8192);
7155
- const tocDate = new Date(BDT_EPOCH_MS2 + wnToc * MS_PER_WEEK4 + tocs * 1e3);
7230
+ const tocDate = new Date(BDT_EPOCH_MS2 + wnToc * MS_PER_WEEK5 + tocs * 1e3);
7156
7231
  return {
7157
7232
  system: "C",
7158
7233
  prn,
@@ -7198,7 +7273,7 @@ function decodeGloNav(view, b) {
7198
7273
  const tocDate = new Date(toeGpsMs - leapMs);
7199
7274
  const tofGpsMs = gpsMs(wnc, 0) + view.getUint32(b + 8, true);
7200
7275
  const tofLeapMs = getGpsLeap(new Date(tofGpsMs)) * 1e3;
7201
- const messageFrameTime = (tofGpsMs - tofLeapMs - GPS_EPOCH_MS9) / 1e3 % SEC_PER_WEEK8;
7276
+ const messageFrameTime = (tofGpsMs - tofLeapMs - GPS_EPOCH_MS10) / 1e3 % SEC_PER_WEEK8;
7202
7277
  return {
7203
7278
  system: "R",
7204
7279
  prn,
@@ -7565,8 +7640,8 @@ function isFnavDummy(page) {
7565
7640
  }
7566
7641
 
7567
7642
  // src/sbf/rawnav-bds.ts
7568
- var GPS_EPOCH_MS10 = Date.UTC(1980, 0, 6);
7569
- var MS_PER_WEEK5 = 7 * 86400 * 1e3;
7643
+ var GPS_EPOCH_MS11 = Date.UTC(1980, 0, 6);
7644
+ var MS_PER_WEEK6 = 7 * 86400 * 1e3;
7570
7645
  var TOW_DNU = 4294967295;
7571
7646
  var WNC_DNU2 = 65535;
7572
7647
  function feedBdsBlock(view, b, assembler) {
@@ -7626,7 +7701,7 @@ function feedGloBlock(view, b, assembler) {
7626
7701
  const eph = assembler.push(
7627
7702
  prn,
7628
7703
  str2,
7629
- new Date(GPS_EPOCH_MS10 + wnc * MS_PER_WEEK5 + towMs),
7704
+ new Date(GPS_EPOCH_MS11 + wnc * MS_PER_WEEK6 + towMs),
7630
7705
  view.getUint8(b + 18) - 8
7631
7706
  // FreqNr, offset by 8
7632
7707
  );
@@ -7648,6 +7723,49 @@ function parseSbfGloNav(data) {
7648
7723
  return { ephemerides, badCrc, messages };
7649
7724
  }
7650
7725
 
7726
+ // src/sbf/rawnav-sbas.ts
7727
+ function feedGeoBlock(view, b) {
7728
+ const tow = view.getUint32(b + 8, true);
7729
+ const wnc = view.getUint16(b + 12, true);
7730
+ const svid = view.getUint8(b + 14);
7731
+ const prnStr = svidToPrn(svid);
7732
+ if (!prnStr || prnStr[0] !== "S") return {};
7733
+ const msg = new Uint8Array(32);
7734
+ for (let k = 0; k < 8; k++) {
7735
+ const w = view.getUint32(b + 20 + 4 * k, true);
7736
+ msg[4 * k] = w >>> 24;
7737
+ msg[4 * k + 1] = w >>> 16 & 255;
7738
+ msg[4 * k + 2] = w >>> 8 & 255;
7739
+ msg[4 * k + 3] = w & 255;
7740
+ }
7741
+ if (!sbasCrcOk(msg)) return { badCrc: true };
7742
+ const prn = Number(prnStr.slice(1)) + 100;
7743
+ const eph = decodeSbasGeoNav(msg, prn, wnc, tow / 1e3);
7744
+ return eph ? { eph } : {};
7745
+ }
7746
+ function parseSbfGeoNav(data) {
7747
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
7748
+ const ephemerides = [];
7749
+ const seen = /* @__PURE__ */ new Set();
7750
+ let badCrc = 0;
7751
+ let messages = 0;
7752
+ scanSbfFrames(data, view, (id, b, len) => {
7753
+ if (id !== 4020 || len < 52) return;
7754
+ messages++;
7755
+ const r = feedGeoBlock(view, b);
7756
+ if (r.eph) {
7757
+ const key = `${r.eph.prn}|${r.eph.tocDate.getTime()}`;
7758
+ if (!seen.has(key)) {
7759
+ seen.add(key);
7760
+ ephemerides.push(r.eph);
7761
+ }
7762
+ } else if (r.badCrc) {
7763
+ badCrc++;
7764
+ }
7765
+ });
7766
+ return { ephemerides, badCrc, messages };
7767
+ }
7768
+
7651
7769
  // src/sbf/navigation.ts
7652
7770
  var F4_DNU4 = -2e10;
7653
7771
  function ephKey(e) {
@@ -7668,6 +7786,7 @@ function decodeSbfNavigation(data) {
7668
7786
  galRaw: 0,
7669
7787
  gloRaw: 0,
7670
7788
  bdsRaw: 0,
7789
+ sbasRaw: 0,
7671
7790
  badFrames: 0
7672
7791
  };
7673
7792
  const cnavAsm = newCnavAssemblers();
@@ -7771,6 +7890,14 @@ function decodeSbfNavigation(data) {
7771
7890
  else if (r.badCrc) counts.badFrames++;
7772
7891
  return;
7773
7892
  }
7893
+ case 4020: {
7894
+ if (len < 52) return;
7895
+ counts.sbasRaw++;
7896
+ const r = feedGeoBlock(view, b);
7897
+ if (r.eph) addEph(r.eph);
7898
+ else if (r.badCrc) counts.badFrames++;
7899
+ return;
7900
+ }
7774
7901
  /* ---- iono / UTC ---- */
7775
7902
  case 5893:
7776
7903
  // GPSIon
@@ -8323,8 +8450,8 @@ function parseSbfHas(data) {
8323
8450
 
8324
8451
  // src/sbf/index.ts
8325
8452
  var CLIGHT = 299792458;
8326
- var GPS_EPOCH_MS11 = Date.UTC(1980, 0, 6);
8327
- var MS_PER_WEEK6 = 7 * 864e5;
8453
+ var GPS_EPOCH_MS12 = Date.UTC(1980, 0, 6);
8454
+ var MS_PER_WEEK7 = 7 * 864e5;
8328
8455
  var M3_SYS = ["G", "R", "E", "C", "S", "J", "I"];
8329
8456
  var M3_PR_BASE = [19e6, 19e6, 22e6, 2e7, 34e6, 34e6, 34e6];
8330
8457
  var M3_INTERVALS = [
@@ -8423,23 +8550,23 @@ var MEAS2_SIG = [
8423
8550
  ["J", "1E"],
8424
8551
  ["J", "5P"]
8425
8552
  ];
8426
- var two4 = (n) => String(n).padStart(2, "0");
8553
+ var two5 = (n) => String(n).padStart(2, "0");
8427
8554
  function m3Prn(navsys, svid) {
8428
8555
  switch (navsys) {
8429
8556
  case 0:
8430
- return svid < 32 ? `G${two4(svid + 1)}` : null;
8557
+ return svid < 32 ? `G${two5(svid + 1)}` : null;
8431
8558
  case 1:
8432
- return svid < 27 ? `R${two4(svid + 1)}` : null;
8559
+ return svid < 27 ? `R${two5(svid + 1)}` : null;
8433
8560
  case 2:
8434
- return svid < 36 ? `E${two4(svid + 1)}` : null;
8561
+ return svid < 36 ? `E${two5(svid + 1)}` : null;
8435
8562
  case 3:
8436
- return svid < 50 ? `C${two4(svid + 1)}` : null;
8563
+ return svid < 50 ? `C${two5(svid + 1)}` : null;
8437
8564
  case 4:
8438
- return svid <= 38 ? `S${two4(svid + 20)}` : null;
8565
+ return svid <= 38 ? `S${two5(svid + 20)}` : null;
8439
8566
  case 5:
8440
- return svid < 10 ? `J${two4(svid + 1)}` : null;
8567
+ return svid < 10 ? `J${two5(svid + 1)}` : null;
8441
8568
  case 6:
8442
- return svid < 14 ? `I${two4(svid + 1)}` : null;
8569
+ return svid < 14 ? `I${two5(svid + 1)}` : null;
8443
8570
  default:
8444
8571
  return null;
8445
8572
  }
@@ -8977,7 +9104,7 @@ function parseSbfMeas(data) {
8977
9104
  const tow = view.getUint32(i + 8, true);
8978
9105
  const wnc = view.getUint16(i + 12, true);
8979
9106
  if (tow !== 4294967295 && wnc !== 65535) {
8980
- ensureEpoch(GPS_EPOCH_MS11 + wnc * MS_PER_WEEK6 + tow);
9107
+ ensureEpoch(GPS_EPOCH_MS12 + wnc * MS_PER_WEEK7 + tow);
8981
9108
  if (id === 4109) decodeMeas3Ranges(i, tow);
8982
9109
  else if (id === 4110) decodeMeas3CN0(i, len);
8983
9110
  else if (id === 4111) decodeMeas3Doppler(i, len);
@@ -9042,18 +9169,20 @@ var ID_GALEPHEMERIS = 1122;
9042
9169
  var ID_QZSSEPHEMERIS = 1336;
9043
9170
  var ID_GPSEPHEM = 7;
9044
9171
  var ID_BDSEPHEMERIS = 1696;
9045
- var GPS_EPOCH_MS12 = Date.UTC(1980, 0, 6);
9172
+ var ID_RAWWAASFRAME = 287;
9173
+ var ID_RAWSBASFRAME = 973;
9174
+ var GPS_EPOCH_MS13 = Date.UTC(1980, 0, 6);
9046
9175
  var BDT_EPOCH_MS3 = Date.UTC(2006, 0, 1);
9047
9176
  var SEC_PER_WEEK9 = 7 * 86400;
9048
9177
  var SEC_PER_DAY2 = 86400;
9049
- var MS_PER_WEEK7 = SEC_PER_WEEK9 * 1e3;
9050
- var gpsMs2 = (week, sec) => GPS_EPOCH_MS12 + week * MS_PER_WEEK7 + sec * 1e3;
9178
+ var MS_PER_WEEK8 = SEC_PER_WEEK9 * 1e3;
9179
+ var gpsMs2 = (week, sec) => GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + sec * 1e3;
9051
9180
  var sowOf3 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK9;
9052
9181
  function nearWeekMs(refMs, sow) {
9053
- const refWeek = Math.floor((refMs - GPS_EPOCH_MS12) / MS_PER_WEEK7);
9182
+ const refWeek = Math.floor((refMs - GPS_EPOCH_MS13) / MS_PER_WEEK8);
9054
9183
  let ms = gpsMs2(refWeek, sow);
9055
- if (ms < refMs - MS_PER_WEEK7 / 2) ms += MS_PER_WEEK7;
9056
- else if (ms > refMs + MS_PER_WEEK7 / 2) ms -= MS_PER_WEEK7;
9184
+ if (ms < refMs - MS_PER_WEEK8 / 2) ms += MS_PER_WEEK8;
9185
+ else if (ms > refMs + MS_PER_WEEK8 / 2) ms -= MS_PER_WEEK8;
9057
9186
  return ms;
9058
9187
  }
9059
9188
  function decodeRawEphem(data, view, p) {
@@ -9077,9 +9206,9 @@ function decodeGloEphemeris(view, p) {
9077
9206
  tof += Math.floor(tow / SEC_PER_DAY2) * SEC_PER_DAY2;
9078
9207
  if (tof < tow - 43200) tof += SEC_PER_DAY2;
9079
9208
  else if (tof > tow + 43200) tof -= SEC_PER_DAY2;
9080
- const toeGpsMs = GPS_EPOCH_MS12 + (week * SEC_PER_WEEK9 + tow) * 1e3;
9081
- const tofGpsMs = GPS_EPOCH_MS12 + (week * SEC_PER_WEEK9 + tof) * 1e3;
9082
- const tofUtcSec = (getUtcDate(new Date(tofGpsMs)).getTime() - GPS_EPOCH_MS12) / 1e3;
9209
+ const toeGpsMs = GPS_EPOCH_MS13 + (week * SEC_PER_WEEK9 + tow) * 1e3;
9210
+ const tofGpsMs = GPS_EPOCH_MS13 + (week * SEC_PER_WEEK9 + tof) * 1e3;
9211
+ const tofUtcSec = (getUtcDate(new Date(tofGpsMs)).getTime() - GPS_EPOCH_MS13) / 1e3;
9083
9212
  return {
9084
9213
  system: "R",
9085
9214
  prn: `R${String(slot).padStart(2, "0")}`,
@@ -9144,7 +9273,7 @@ function decodeGalEphemeris(view, p, headerMs) {
9144
9273
  omega: view.getFloat64(p + 60, true),
9145
9274
  omegaDot: view.getFloat64(p + 140, true),
9146
9275
  idot: view.getFloat64(p + 124, true),
9147
- week: Math.floor((toeMs - GPS_EPOCH_MS12) / MS_PER_WEEK7),
9276
+ week: Math.floor((toeMs - GPS_EPOCH_MS13) / MS_PER_WEEK8),
9148
9277
  // RINEX Galileo SVH bit layout (E1B DVS/HS in bits 0-2, E5a in
9149
9278
  // 3-5, E5b in 6-8) — same packing as RTKLIB.
9150
9279
  svHealth: svhE5b << 7 | dvsE5b << 6 | svhE5a << 4 | dvsE5a << 3 | svhE1b << 1 | dvsE1b,
@@ -9161,7 +9290,7 @@ function decodeBdsEphemeris2(view, p) {
9161
9290
  const tgd1 = view.getFloat64(p + 20, true);
9162
9291
  const tocs = view.getUint32(p + 40, true);
9163
9292
  const toes = view.getUint32(p + 72, true);
9164
- const tocDate = new Date(BDT_EPOCH_MS3 + week * MS_PER_WEEK7 + tocs * 1e3);
9293
+ const tocDate = new Date(BDT_EPOCH_MS3 + week * MS_PER_WEEK8 + tocs * 1e3);
9165
9294
  return {
9166
9295
  system: "C",
9167
9296
  prn: `C${String(prn).padStart(2, "0")}`,
@@ -9303,6 +9432,20 @@ function parseNovatelNav(data) {
9303
9432
  }
9304
9433
  lastGlo.set(eph.prn, eph);
9305
9434
  ephemerides.push(eph);
9435
+ } else if ((frame.id === ID_RAWSBASFRAME || frame.id === ID_RAWWAASFRAME) && frame.msgLen >= 41) {
9436
+ if (frame.week === 0) continue;
9437
+ const p = frame.payload;
9438
+ const prn = view.getUint32(p + 4, true);
9439
+ const msg = new Uint8Array(32);
9440
+ msg.set(data.subarray(p + 12, p + 41));
9441
+ const eph = decodeSbasGeoNav(msg, prn, frame.week, frame.towMs / 1e3);
9442
+ if (!eph) continue;
9443
+ const prev = lastGlo.get(eph.prn);
9444
+ if (prev && Math.abs(prev.tocDate.getTime() - eph.tocDate.getTime()) < 1e3 && prev.health === eph.health) {
9445
+ continue;
9446
+ }
9447
+ lastGlo.set(eph.prn, eph);
9448
+ ephemerides.push(eph);
9306
9449
  }
9307
9450
  }
9308
9451
  return {
@@ -9316,8 +9459,8 @@ function parseNovatelNav(data) {
9316
9459
  }
9317
9460
 
9318
9461
  // src/novatel/index.ts
9319
- var GPS_EPOCH_MS13 = Date.UTC(1980, 0, 6);
9320
- var MS_PER_WEEK8 = 7 * 864e5;
9462
+ var GPS_EPOCH_MS14 = Date.UTC(1980, 0, 6);
9463
+ var MS_PER_WEEK9 = 7 * 864e5;
9321
9464
  var HDR = 28;
9322
9465
  var ID_RANGE = 43;
9323
9466
  var ID_RANGECMP = 140;
@@ -9486,7 +9629,7 @@ function parseNovatelRange(data) {
9486
9629
  if (!codes.includes(code)) codes.push(code);
9487
9630
  }
9488
9631
  epochs.push({
9489
- timeMs: GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + towMs,
9632
+ timeMs: GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + towMs,
9490
9633
  meas
9491
9634
  });
9492
9635
  }
@@ -9538,7 +9681,7 @@ function parseNovatelRange(data) {
9538
9681
  if (!codes.includes(code)) codes.push(code);
9539
9682
  }
9540
9683
  epochs.push({
9541
- timeMs: GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + towMs,
9684
+ timeMs: GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + towMs,
9542
9685
  meas
9543
9686
  });
9544
9687
  }
@@ -9589,14 +9732,14 @@ function* trimbleFrames(data, stats) {
9589
9732
  }
9590
9733
 
9591
9734
  // src/trimble/nav.ts
9592
- var GPS_EPOCH_MS14 = Date.UTC(1980, 0, 6);
9735
+ var GPS_EPOCH_MS15 = Date.UTC(1980, 0, 6);
9593
9736
  var BDT_EPOCH_MS4 = Date.UTC(2006, 0, 1);
9594
9737
  var SEC_PER_WEEK10 = 7 * 86400;
9595
- var MS_PER_WEEK9 = SEC_PER_WEEK10 * 1e3;
9738
+ var MS_PER_WEEK10 = SEC_PER_WEEK10 * 1e3;
9596
9739
  var GPS_PI2 = 3.1415926535898;
9597
9740
  var BDS_WEEK_OFFSET = 1356;
9598
9741
  var BDS_LEAP_SEC = 14;
9599
- var gpsMs3 = (week, sec) => GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + sec * 1e3;
9742
+ var gpsMs3 = (week, sec) => GPS_EPOCH_MS15 + week * MS_PER_WEEK10 + sec * 1e3;
9600
9743
  var sowOf4 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK10;
9601
9744
  var SUB_GPS_EPHEMERIS = 1;
9602
9745
  var SUB_ION_UTC = 3;
@@ -9678,7 +9821,7 @@ function decodeBdsEphemeris3(view, base) {
9678
9821
  const tocSec = r.tocSec - BDS_LEAP_SEC;
9679
9822
  const toeSec = r.toeSec - BDS_LEAP_SEC;
9680
9823
  const tocDate = new Date(
9681
- BDT_EPOCH_MS4 + bdsWeek * MS_PER_WEEK9 + tocSec * 1e3
9824
+ BDT_EPOCH_MS4 + bdsWeek * MS_PER_WEEK10 + tocSec * 1e3
9682
9825
  );
9683
9826
  return {
9684
9827
  system: "C",
@@ -9749,7 +9892,7 @@ function decodeGloEphemeris2(view, base) {
9749
9892
  // RINEX stores −τn as the clock bias; the record carries τn (ICD sign).
9750
9893
  tauN: -view.getFloat64(base + 113, false),
9751
9894
  gammaN: view.getFloat64(base + 121, false),
9752
- messageFrameTime: (tocMs - GPS_EPOCH_MS14) / 1e3 % SEC_PER_WEEK10,
9895
+ messageFrameTime: (tocMs - GPS_EPOCH_MS15) / 1e3 % SEC_PER_WEEK10,
9753
9896
  // State vector: metres / m·s⁻¹ / m·s⁻² → km / km·s⁻¹ / km·s⁻².
9754
9897
  x: view.getFloat64(base + 33, false) / 1e3,
9755
9898
  xDot: view.getFloat64(base + 41, false) / 1e3,
@@ -9820,8 +9963,8 @@ function parseTrimbleNav(data) {
9820
9963
  }
9821
9964
 
9822
9965
  // src/trimble/index.ts
9823
- var GPS_EPOCH_MS15 = Date.UTC(1980, 0, 6);
9824
- var MS_PER_WEEK10 = 7 * 864e5;
9966
+ var GPS_EPOCH_MS16 = Date.UTC(1980, 0, 6);
9967
+ var MS_PER_WEEK11 = 7 * 864e5;
9825
9968
  var REC_TYPE_27 = 6;
9826
9969
  var SYS = {
9827
9970
  0: "G",
@@ -10018,7 +10161,7 @@ function decodeEpoch(epoch, epochs, obsCodes) {
10018
10161
  o += c.length;
10019
10162
  }
10020
10163
  const dv = new DataView(M.buffer, M.byteOffset, M.byteLength);
10021
- const timeMs = GPS_EPOCH_MS15 + epoch.week * MS_PER_WEEK10 + epoch.towMs;
10164
+ const timeMs = GPS_EPOCH_MS16 + epoch.week * MS_PER_WEEK11 + epoch.towMs;
10022
10165
  const meas = [];
10023
10166
  let q = 0;
10024
10167
  for (let sv = 0; sv < epoch.nsv && q + 8 <= M.length; sv++) {
@@ -10199,15 +10342,15 @@ function* binexRecords(data, view, stats) {
10199
10342
  }
10200
10343
 
10201
10344
  // src/binex/nav.ts
10202
- var GPS_EPOCH_MS16 = Date.UTC(1980, 0, 6);
10345
+ var GPS_EPOCH_MS17 = Date.UTC(1980, 0, 6);
10203
10346
  var GLO_DAY0_MS = Date.UTC(1980, 0, 1);
10204
10347
  var BDT_EPOCH_MS5 = Date.UTC(2006, 0, 1);
10205
10348
  var SEC_PER_WEEK11 = 7 * 86400;
10206
- var MS_PER_WEEK11 = SEC_PER_WEEK11 * 1e3;
10349
+ var MS_PER_WEEK12 = SEC_PER_WEEK11 * 1e3;
10207
10350
  var SC2RAD = GPS_PI;
10208
- var gpsMs4 = (week, sec) => GPS_EPOCH_MS16 + week * MS_PER_WEEK11 + sec * 1e3;
10351
+ var gpsMs4 = (week, sec) => GPS_EPOCH_MS17 + week * MS_PER_WEEK12 + sec * 1e3;
10209
10352
  var sowOf5 = (dateMs) => (dateMs / 1e3 % SEC_PER_WEEK11 + SEC_PER_WEEK11) % SEC_PER_WEEK11;
10210
- var two5 = (n) => String(n).padStart(2, "0");
10353
+ var two6 = (n) => String(n).padStart(2, "0");
10211
10354
  var Reader = class {
10212
10355
  constructor(view, start, le) {
10213
10356
  this.view = view;
@@ -10302,7 +10445,7 @@ function decodeGpsQzss(view, p, le, sys) {
10302
10445
  const tocDate = new Date(gpsMs4(week, toes));
10303
10446
  return {
10304
10447
  system: sys,
10305
- prn: `${sys}${two5(prn)}`,
10448
+ prn: `${sys}${two6(prn)}`,
10306
10449
  toc: sowOf5(tocDate.getTime()),
10307
10450
  tocDate,
10308
10451
  af0,
@@ -10335,7 +10478,7 @@ function decodeGalileo(view, p, le) {
10335
10478
  const tocDate = new Date(gpsMs4(week, toes));
10336
10479
  return {
10337
10480
  system: "E",
10338
- prn: `E${two5(prn)}`,
10481
+ prn: `E${two6(prn)}`,
10339
10482
  toc: sowOf5(tocDate.getTime()),
10340
10483
  tocDate,
10341
10484
  af0,
@@ -10370,10 +10513,10 @@ function decodeBeidou(view, p, le) {
10370
10513
  const iode = flag1 >> 6 & 31;
10371
10514
  const svHealth = flag1 & 1;
10372
10515
  const tgd = bdsTgd(flag2 >> 4);
10373
- const tocDate = new Date(BDT_EPOCH_MS5 + week * MS_PER_WEEK11 + toes * 1e3);
10516
+ const tocDate = new Date(BDT_EPOCH_MS5 + week * MS_PER_WEEK12 + toes * 1e3);
10374
10517
  return {
10375
10518
  system: "C",
10376
- prn: `C${two5(prn)}`,
10519
+ prn: `C${two6(prn)}`,
10377
10520
  toc: sowOf5(tocDate.getTime()),
10378
10521
  tocDate,
10379
10522
  af0,
@@ -10413,7 +10556,7 @@ function decodeGlonass(view, p, le) {
10413
10556
  );
10414
10557
  return {
10415
10558
  system: "R",
10416
- prn: `R${two5(slot)}`,
10559
+ prn: `R${two6(slot)}`,
10417
10560
  tocDate,
10418
10561
  tauN,
10419
10562
  gammaN,
@@ -10452,7 +10595,7 @@ function decodeSbas(view, p, le) {
10452
10595
  if (prn < 120 || prn > 158) return null;
10453
10596
  return {
10454
10597
  system: "S",
10455
- prn: `S${two5(prn - 100)}`,
10598
+ prn: `S${two6(prn - 100)}`,
10456
10599
  tocDate: new Date(gpsMs4(week, toe)),
10457
10600
  tauN: af0,
10458
10601
  gammaN: af1,
@@ -10493,7 +10636,7 @@ function decodeBinexEph(view, body, len, le) {
10493
10636
  }
10494
10637
 
10495
10638
  // src/binex/index.ts
10496
- var GPS_EPOCH_MS17 = Date.UTC(1980, 0, 6);
10639
+ var GPS_EPOCH_MS18 = Date.UTC(1980, 0, 6);
10497
10640
  var CLIGHT2 = 299792458;
10498
10641
  var OBS_CODES = {
10499
10642
  0: [
@@ -10629,22 +10772,22 @@ var OBS_CODES = {
10629
10772
  ]
10630
10773
  // QZSS
10631
10774
  };
10632
- var two6 = (n) => String(n).padStart(2, "0");
10775
+ var two7 = (n) => String(n).padStart(2, "0");
10633
10776
  function obsPrn(sys, prn) {
10634
10777
  switch (sys) {
10635
10778
  case 0:
10636
- return prn >= 1 && prn <= 32 ? `G${two6(prn)}` : null;
10779
+ return prn >= 1 && prn <= 32 ? `G${two7(prn)}` : null;
10637
10780
  case 1:
10638
- return prn >= 1 && prn <= 27 ? `R${two6(prn)}` : null;
10781
+ return prn >= 1 && prn <= 27 ? `R${two7(prn)}` : null;
10639
10782
  case 2:
10640
- return prn >= 120 && prn <= 158 ? `S${two6(prn - 100)}` : null;
10783
+ return prn >= 120 && prn <= 158 ? `S${two7(prn - 100)}` : null;
10641
10784
  case 3:
10642
- return prn >= 1 && prn <= 36 ? `E${two6(prn)}` : null;
10785
+ return prn >= 1 && prn <= 36 ? `E${two7(prn)}` : null;
10643
10786
  case 4:
10644
- return prn >= 1 && prn <= 63 ? `C${two6(prn)}` : null;
10787
+ return prn >= 1 && prn <= 63 ? `C${two7(prn)}` : null;
10645
10788
  case 5:
10646
- if (prn >= 193 && prn <= 202) return `J${two6(prn - 192)}`;
10647
- return prn >= 1 && prn <= 10 ? `J${two6(prn)}` : null;
10789
+ if (prn >= 193 && prn <= 202) return `J${two7(prn - 192)}`;
10790
+ return prn >= 1 && prn <= 10 ? `J${two7(prn)}` : null;
10648
10791
  default:
10649
10792
  return null;
10650
10793
  }
@@ -10751,7 +10894,7 @@ function decodeObsRecord(data, view, body, len, obsCodes) {
10751
10894
  p += 4;
10752
10895
  const msec = view.getUint16(p);
10753
10896
  p += 2;
10754
- const timeMs = GPS_EPOCH_MS17 + min * 6e4 + msec;
10897
+ const timeMs = GPS_EPOCH_MS18 + min * 6e4 + msec;
10755
10898
  const flag = data[p++];
10756
10899
  const nsat = (flag & 63) + 1;
10757
10900
  if (flag & 128) p += 3;
@@ -10837,7 +10980,7 @@ function parseBinex(data) {
10837
10980
  var GM_GPS = 3986005e8;
10838
10981
  var GM_GAL = 3986004418e5;
10839
10982
  var GM_BDS = 3986004418e5;
10840
- var GPS_EPOCH_MS18 = Date.UTC(1980, 0, 6);
10983
+ var GPS_EPOCH_MS19 = Date.UTC(1980, 0, 6);
10841
10984
  var BDT_EPOCH_MS6 = Date.UTC(2006, 0, 1);
10842
10985
  var WEEK_MS = 6048e5;
10843
10986
  var BDT_MINUS_GPST_MS = 14e3;
@@ -10846,7 +10989,7 @@ function almanacEpochMs(alm) {
10846
10989
  if (alm.system === "C") {
10847
10990
  return BDT_EPOCH_MS6 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3 + BDT_MINUS_GPST_MS;
10848
10991
  }
10849
- return GPS_EPOCH_MS18 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3;
10992
+ return GPS_EPOCH_MS19 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3;
10850
10993
  }
10851
10994
  function almanacSatPosition(alm, timeMs) {
10852
10995
  const GM = alm.system === "E" ? GM_GAL : alm.system === "C" ? GM_BDS : GM_GPS;
@@ -11355,10 +11498,10 @@ function selectBest(ephs, timeMs) {
11355
11498
  }
11356
11499
  return best;
11357
11500
  }
11358
- var GPS_EPOCH_MS19 = START_GPS_TIME.getTime();
11359
- var MS_PER_WEEK12 = 7 * 864e5;
11501
+ var GPS_EPOCH_MS20 = START_GPS_TIME.getTime();
11502
+ var MS_PER_WEEK13 = 7 * 864e5;
11360
11503
  var BDS_EPOCH_MS = START_BDS_TIME.getTime();
11361
- var GAL_EPOCH_MS = GPS_EPOCH_MS19 + 1024 * MS_PER_WEEK12;
11504
+ var GAL_EPOCH_MS = GPS_EPOCH_MS20 + 1024 * MS_PER_WEEK13;
11362
11505
  function ephInfoToEphemeris(info) {
11363
11506
  const sys = info.prn.charAt(0);
11364
11507
  if (sys === "R") {
@@ -11409,11 +11552,11 @@ function ephInfoToEphemeris(info) {
11409
11552
  } else if (sys === "E") {
11410
11553
  epochMs = GAL_EPOCH_MS;
11411
11554
  } else {
11412
- epochMs = GPS_EPOCH_MS19;
11413
- const weeksNow = (info.lastReceived - GPS_EPOCH_MS19) / MS_PER_WEEK12;
11555
+ epochMs = GPS_EPOCH_MS20;
11556
+ const weeksNow = (info.lastReceived - GPS_EPOCH_MS20) / MS_PER_WEEK13;
11414
11557
  week += 1024 * Math.round((weeksNow - week) / 1024);
11415
11558
  }
11416
- const tocDate = new Date(epochMs + week * MS_PER_WEEK12 + tocSec * 1e3);
11559
+ const tocDate = new Date(epochMs + week * MS_PER_WEEK13 + tocSec * 1e3);
11417
11560
  return {
11418
11561
  system: sys,
11419
11562
  prn: info.prn,
@@ -16801,6 +16944,7 @@ function computePsdDb(centerMHz, halfSpanChips, numPoints, psdFn, f0 = 1023e3, f
16801
16944
  estimateWidelaneFcb,
16802
16945
  euclidean3D,
16803
16946
  extractWidelaneArcs,
16947
+ feedGeoBlock,
16804
16948
  fetchSourcetable,
16805
16949
  findSatBias,
16806
16950
  fixPppPosition,
@@ -16906,6 +17050,7 @@ function computePsdDb(centerMHz, halfSpanChips, numPoints, psdFn, f0 = 1023e3, f
16906
17050
  parseSbfBdsNav,
16907
17051
  parseSbfCnav,
16908
17052
  parseSbfGalNav,
17053
+ parseSbfGeoNav,
16909
17054
  parseSbfGloNav,
16910
17055
  parseSbfGpsNav,
16911
17056
  parseSbfHas,