gnss-js 1.42.0 → 1.43.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,18 @@ 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 GPS_EPOCH_MS13 = Date.UTC(1980, 0, 6);
9046
9173
  var BDT_EPOCH_MS3 = Date.UTC(2006, 0, 1);
9047
9174
  var SEC_PER_WEEK9 = 7 * 86400;
9048
9175
  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;
9176
+ var MS_PER_WEEK8 = SEC_PER_WEEK9 * 1e3;
9177
+ var gpsMs2 = (week, sec) => GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + sec * 1e3;
9051
9178
  var sowOf3 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK9;
9052
9179
  function nearWeekMs(refMs, sow) {
9053
- const refWeek = Math.floor((refMs - GPS_EPOCH_MS12) / MS_PER_WEEK7);
9180
+ const refWeek = Math.floor((refMs - GPS_EPOCH_MS13) / MS_PER_WEEK8);
9054
9181
  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;
9182
+ if (ms < refMs - MS_PER_WEEK8 / 2) ms += MS_PER_WEEK8;
9183
+ else if (ms > refMs + MS_PER_WEEK8 / 2) ms -= MS_PER_WEEK8;
9057
9184
  return ms;
9058
9185
  }
9059
9186
  function decodeRawEphem(data, view, p) {
@@ -9077,9 +9204,9 @@ function decodeGloEphemeris(view, p) {
9077
9204
  tof += Math.floor(tow / SEC_PER_DAY2) * SEC_PER_DAY2;
9078
9205
  if (tof < tow - 43200) tof += SEC_PER_DAY2;
9079
9206
  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;
9207
+ const toeGpsMs = GPS_EPOCH_MS13 + (week * SEC_PER_WEEK9 + tow) * 1e3;
9208
+ const tofGpsMs = GPS_EPOCH_MS13 + (week * SEC_PER_WEEK9 + tof) * 1e3;
9209
+ const tofUtcSec = (getUtcDate(new Date(tofGpsMs)).getTime() - GPS_EPOCH_MS13) / 1e3;
9083
9210
  return {
9084
9211
  system: "R",
9085
9212
  prn: `R${String(slot).padStart(2, "0")}`,
@@ -9144,7 +9271,7 @@ function decodeGalEphemeris(view, p, headerMs) {
9144
9271
  omega: view.getFloat64(p + 60, true),
9145
9272
  omegaDot: view.getFloat64(p + 140, true),
9146
9273
  idot: view.getFloat64(p + 124, true),
9147
- week: Math.floor((toeMs - GPS_EPOCH_MS12) / MS_PER_WEEK7),
9274
+ week: Math.floor((toeMs - GPS_EPOCH_MS13) / MS_PER_WEEK8),
9148
9275
  // RINEX Galileo SVH bit layout (E1B DVS/HS in bits 0-2, E5a in
9149
9276
  // 3-5, E5b in 6-8) — same packing as RTKLIB.
9150
9277
  svHealth: svhE5b << 7 | dvsE5b << 6 | svhE5a << 4 | dvsE5a << 3 | svhE1b << 1 | dvsE1b,
@@ -9161,7 +9288,7 @@ function decodeBdsEphemeris2(view, p) {
9161
9288
  const tgd1 = view.getFloat64(p + 20, true);
9162
9289
  const tocs = view.getUint32(p + 40, true);
9163
9290
  const toes = view.getUint32(p + 72, true);
9164
- const tocDate = new Date(BDT_EPOCH_MS3 + week * MS_PER_WEEK7 + tocs * 1e3);
9291
+ const tocDate = new Date(BDT_EPOCH_MS3 + week * MS_PER_WEEK8 + tocs * 1e3);
9165
9292
  return {
9166
9293
  system: "C",
9167
9294
  prn: `C${String(prn).padStart(2, "0")}`,
@@ -9316,8 +9443,8 @@ function parseNovatelNav(data) {
9316
9443
  }
9317
9444
 
9318
9445
  // src/novatel/index.ts
9319
- var GPS_EPOCH_MS13 = Date.UTC(1980, 0, 6);
9320
- var MS_PER_WEEK8 = 7 * 864e5;
9446
+ var GPS_EPOCH_MS14 = Date.UTC(1980, 0, 6);
9447
+ var MS_PER_WEEK9 = 7 * 864e5;
9321
9448
  var HDR = 28;
9322
9449
  var ID_RANGE = 43;
9323
9450
  var ID_RANGECMP = 140;
@@ -9486,7 +9613,7 @@ function parseNovatelRange(data) {
9486
9613
  if (!codes.includes(code)) codes.push(code);
9487
9614
  }
9488
9615
  epochs.push({
9489
- timeMs: GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + towMs,
9616
+ timeMs: GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + towMs,
9490
9617
  meas
9491
9618
  });
9492
9619
  }
@@ -9538,7 +9665,7 @@ function parseNovatelRange(data) {
9538
9665
  if (!codes.includes(code)) codes.push(code);
9539
9666
  }
9540
9667
  epochs.push({
9541
- timeMs: GPS_EPOCH_MS13 + week * MS_PER_WEEK8 + towMs,
9668
+ timeMs: GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + towMs,
9542
9669
  meas
9543
9670
  });
9544
9671
  }
@@ -9589,14 +9716,14 @@ function* trimbleFrames(data, stats) {
9589
9716
  }
9590
9717
 
9591
9718
  // src/trimble/nav.ts
9592
- var GPS_EPOCH_MS14 = Date.UTC(1980, 0, 6);
9719
+ var GPS_EPOCH_MS15 = Date.UTC(1980, 0, 6);
9593
9720
  var BDT_EPOCH_MS4 = Date.UTC(2006, 0, 1);
9594
9721
  var SEC_PER_WEEK10 = 7 * 86400;
9595
- var MS_PER_WEEK9 = SEC_PER_WEEK10 * 1e3;
9722
+ var MS_PER_WEEK10 = SEC_PER_WEEK10 * 1e3;
9596
9723
  var GPS_PI2 = 3.1415926535898;
9597
9724
  var BDS_WEEK_OFFSET = 1356;
9598
9725
  var BDS_LEAP_SEC = 14;
9599
- var gpsMs3 = (week, sec) => GPS_EPOCH_MS14 + week * MS_PER_WEEK9 + sec * 1e3;
9726
+ var gpsMs3 = (week, sec) => GPS_EPOCH_MS15 + week * MS_PER_WEEK10 + sec * 1e3;
9600
9727
  var sowOf4 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK10;
9601
9728
  var SUB_GPS_EPHEMERIS = 1;
9602
9729
  var SUB_ION_UTC = 3;
@@ -9678,7 +9805,7 @@ function decodeBdsEphemeris3(view, base) {
9678
9805
  const tocSec = r.tocSec - BDS_LEAP_SEC;
9679
9806
  const toeSec = r.toeSec - BDS_LEAP_SEC;
9680
9807
  const tocDate = new Date(
9681
- BDT_EPOCH_MS4 + bdsWeek * MS_PER_WEEK9 + tocSec * 1e3
9808
+ BDT_EPOCH_MS4 + bdsWeek * MS_PER_WEEK10 + tocSec * 1e3
9682
9809
  );
9683
9810
  return {
9684
9811
  system: "C",
@@ -9749,7 +9876,7 @@ function decodeGloEphemeris2(view, base) {
9749
9876
  // RINEX stores −τn as the clock bias; the record carries τn (ICD sign).
9750
9877
  tauN: -view.getFloat64(base + 113, false),
9751
9878
  gammaN: view.getFloat64(base + 121, false),
9752
- messageFrameTime: (tocMs - GPS_EPOCH_MS14) / 1e3 % SEC_PER_WEEK10,
9879
+ messageFrameTime: (tocMs - GPS_EPOCH_MS15) / 1e3 % SEC_PER_WEEK10,
9753
9880
  // State vector: metres / m·s⁻¹ / m·s⁻² → km / km·s⁻¹ / km·s⁻².
9754
9881
  x: view.getFloat64(base + 33, false) / 1e3,
9755
9882
  xDot: view.getFloat64(base + 41, false) / 1e3,
@@ -9820,8 +9947,8 @@ function parseTrimbleNav(data) {
9820
9947
  }
9821
9948
 
9822
9949
  // src/trimble/index.ts
9823
- var GPS_EPOCH_MS15 = Date.UTC(1980, 0, 6);
9824
- var MS_PER_WEEK10 = 7 * 864e5;
9950
+ var GPS_EPOCH_MS16 = Date.UTC(1980, 0, 6);
9951
+ var MS_PER_WEEK11 = 7 * 864e5;
9825
9952
  var REC_TYPE_27 = 6;
9826
9953
  var SYS = {
9827
9954
  0: "G",
@@ -10018,7 +10145,7 @@ function decodeEpoch(epoch, epochs, obsCodes) {
10018
10145
  o += c.length;
10019
10146
  }
10020
10147
  const dv = new DataView(M.buffer, M.byteOffset, M.byteLength);
10021
- const timeMs = GPS_EPOCH_MS15 + epoch.week * MS_PER_WEEK10 + epoch.towMs;
10148
+ const timeMs = GPS_EPOCH_MS16 + epoch.week * MS_PER_WEEK11 + epoch.towMs;
10022
10149
  const meas = [];
10023
10150
  let q = 0;
10024
10151
  for (let sv = 0; sv < epoch.nsv && q + 8 <= M.length; sv++) {
@@ -10199,15 +10326,15 @@ function* binexRecords(data, view, stats) {
10199
10326
  }
10200
10327
 
10201
10328
  // src/binex/nav.ts
10202
- var GPS_EPOCH_MS16 = Date.UTC(1980, 0, 6);
10329
+ var GPS_EPOCH_MS17 = Date.UTC(1980, 0, 6);
10203
10330
  var GLO_DAY0_MS = Date.UTC(1980, 0, 1);
10204
10331
  var BDT_EPOCH_MS5 = Date.UTC(2006, 0, 1);
10205
10332
  var SEC_PER_WEEK11 = 7 * 86400;
10206
- var MS_PER_WEEK11 = SEC_PER_WEEK11 * 1e3;
10333
+ var MS_PER_WEEK12 = SEC_PER_WEEK11 * 1e3;
10207
10334
  var SC2RAD = GPS_PI;
10208
- var gpsMs4 = (week, sec) => GPS_EPOCH_MS16 + week * MS_PER_WEEK11 + sec * 1e3;
10335
+ var gpsMs4 = (week, sec) => GPS_EPOCH_MS17 + week * MS_PER_WEEK12 + sec * 1e3;
10209
10336
  var sowOf5 = (dateMs) => (dateMs / 1e3 % SEC_PER_WEEK11 + SEC_PER_WEEK11) % SEC_PER_WEEK11;
10210
- var two5 = (n) => String(n).padStart(2, "0");
10337
+ var two6 = (n) => String(n).padStart(2, "0");
10211
10338
  var Reader = class {
10212
10339
  constructor(view, start, le) {
10213
10340
  this.view = view;
@@ -10302,7 +10429,7 @@ function decodeGpsQzss(view, p, le, sys) {
10302
10429
  const tocDate = new Date(gpsMs4(week, toes));
10303
10430
  return {
10304
10431
  system: sys,
10305
- prn: `${sys}${two5(prn)}`,
10432
+ prn: `${sys}${two6(prn)}`,
10306
10433
  toc: sowOf5(tocDate.getTime()),
10307
10434
  tocDate,
10308
10435
  af0,
@@ -10335,7 +10462,7 @@ function decodeGalileo(view, p, le) {
10335
10462
  const tocDate = new Date(gpsMs4(week, toes));
10336
10463
  return {
10337
10464
  system: "E",
10338
- prn: `E${two5(prn)}`,
10465
+ prn: `E${two6(prn)}`,
10339
10466
  toc: sowOf5(tocDate.getTime()),
10340
10467
  tocDate,
10341
10468
  af0,
@@ -10370,10 +10497,10 @@ function decodeBeidou(view, p, le) {
10370
10497
  const iode = flag1 >> 6 & 31;
10371
10498
  const svHealth = flag1 & 1;
10372
10499
  const tgd = bdsTgd(flag2 >> 4);
10373
- const tocDate = new Date(BDT_EPOCH_MS5 + week * MS_PER_WEEK11 + toes * 1e3);
10500
+ const tocDate = new Date(BDT_EPOCH_MS5 + week * MS_PER_WEEK12 + toes * 1e3);
10374
10501
  return {
10375
10502
  system: "C",
10376
- prn: `C${two5(prn)}`,
10503
+ prn: `C${two6(prn)}`,
10377
10504
  toc: sowOf5(tocDate.getTime()),
10378
10505
  tocDate,
10379
10506
  af0,
@@ -10413,7 +10540,7 @@ function decodeGlonass(view, p, le) {
10413
10540
  );
10414
10541
  return {
10415
10542
  system: "R",
10416
- prn: `R${two5(slot)}`,
10543
+ prn: `R${two6(slot)}`,
10417
10544
  tocDate,
10418
10545
  tauN,
10419
10546
  gammaN,
@@ -10452,7 +10579,7 @@ function decodeSbas(view, p, le) {
10452
10579
  if (prn < 120 || prn > 158) return null;
10453
10580
  return {
10454
10581
  system: "S",
10455
- prn: `S${two5(prn - 100)}`,
10582
+ prn: `S${two6(prn - 100)}`,
10456
10583
  tocDate: new Date(gpsMs4(week, toe)),
10457
10584
  tauN: af0,
10458
10585
  gammaN: af1,
@@ -10493,7 +10620,7 @@ function decodeBinexEph(view, body, len, le) {
10493
10620
  }
10494
10621
 
10495
10622
  // src/binex/index.ts
10496
- var GPS_EPOCH_MS17 = Date.UTC(1980, 0, 6);
10623
+ var GPS_EPOCH_MS18 = Date.UTC(1980, 0, 6);
10497
10624
  var CLIGHT2 = 299792458;
10498
10625
  var OBS_CODES = {
10499
10626
  0: [
@@ -10629,22 +10756,22 @@ var OBS_CODES = {
10629
10756
  ]
10630
10757
  // QZSS
10631
10758
  };
10632
- var two6 = (n) => String(n).padStart(2, "0");
10759
+ var two7 = (n) => String(n).padStart(2, "0");
10633
10760
  function obsPrn(sys, prn) {
10634
10761
  switch (sys) {
10635
10762
  case 0:
10636
- return prn >= 1 && prn <= 32 ? `G${two6(prn)}` : null;
10763
+ return prn >= 1 && prn <= 32 ? `G${two7(prn)}` : null;
10637
10764
  case 1:
10638
- return prn >= 1 && prn <= 27 ? `R${two6(prn)}` : null;
10765
+ return prn >= 1 && prn <= 27 ? `R${two7(prn)}` : null;
10639
10766
  case 2:
10640
- return prn >= 120 && prn <= 158 ? `S${two6(prn - 100)}` : null;
10767
+ return prn >= 120 && prn <= 158 ? `S${two7(prn - 100)}` : null;
10641
10768
  case 3:
10642
- return prn >= 1 && prn <= 36 ? `E${two6(prn)}` : null;
10769
+ return prn >= 1 && prn <= 36 ? `E${two7(prn)}` : null;
10643
10770
  case 4:
10644
- return prn >= 1 && prn <= 63 ? `C${two6(prn)}` : null;
10771
+ return prn >= 1 && prn <= 63 ? `C${two7(prn)}` : null;
10645
10772
  case 5:
10646
- if (prn >= 193 && prn <= 202) return `J${two6(prn - 192)}`;
10647
- return prn >= 1 && prn <= 10 ? `J${two6(prn)}` : null;
10773
+ if (prn >= 193 && prn <= 202) return `J${two7(prn - 192)}`;
10774
+ return prn >= 1 && prn <= 10 ? `J${two7(prn)}` : null;
10648
10775
  default:
10649
10776
  return null;
10650
10777
  }
@@ -10751,7 +10878,7 @@ function decodeObsRecord(data, view, body, len, obsCodes) {
10751
10878
  p += 4;
10752
10879
  const msec = view.getUint16(p);
10753
10880
  p += 2;
10754
- const timeMs = GPS_EPOCH_MS17 + min * 6e4 + msec;
10881
+ const timeMs = GPS_EPOCH_MS18 + min * 6e4 + msec;
10755
10882
  const flag = data[p++];
10756
10883
  const nsat = (flag & 63) + 1;
10757
10884
  if (flag & 128) p += 3;
@@ -10837,7 +10964,7 @@ function parseBinex(data) {
10837
10964
  var GM_GPS = 3986005e8;
10838
10965
  var GM_GAL = 3986004418e5;
10839
10966
  var GM_BDS = 3986004418e5;
10840
- var GPS_EPOCH_MS18 = Date.UTC(1980, 0, 6);
10967
+ var GPS_EPOCH_MS19 = Date.UTC(1980, 0, 6);
10841
10968
  var BDT_EPOCH_MS6 = Date.UTC(2006, 0, 1);
10842
10969
  var WEEK_MS = 6048e5;
10843
10970
  var BDT_MINUS_GPST_MS = 14e3;
@@ -10846,7 +10973,7 @@ function almanacEpochMs(alm) {
10846
10973
  if (alm.system === "C") {
10847
10974
  return BDT_EPOCH_MS6 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3 + BDT_MINUS_GPST_MS;
10848
10975
  }
10849
- return GPS_EPOCH_MS18 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3;
10976
+ return GPS_EPOCH_MS19 + alm.weekAlm * WEEK_MS + alm.toaSec * 1e3;
10850
10977
  }
10851
10978
  function almanacSatPosition(alm, timeMs) {
10852
10979
  const GM = alm.system === "E" ? GM_GAL : alm.system === "C" ? GM_BDS : GM_GPS;
@@ -11355,10 +11482,10 @@ function selectBest(ephs, timeMs) {
11355
11482
  }
11356
11483
  return best;
11357
11484
  }
11358
- var GPS_EPOCH_MS19 = START_GPS_TIME.getTime();
11359
- var MS_PER_WEEK12 = 7 * 864e5;
11485
+ var GPS_EPOCH_MS20 = START_GPS_TIME.getTime();
11486
+ var MS_PER_WEEK13 = 7 * 864e5;
11360
11487
  var BDS_EPOCH_MS = START_BDS_TIME.getTime();
11361
- var GAL_EPOCH_MS = GPS_EPOCH_MS19 + 1024 * MS_PER_WEEK12;
11488
+ var GAL_EPOCH_MS = GPS_EPOCH_MS20 + 1024 * MS_PER_WEEK13;
11362
11489
  function ephInfoToEphemeris(info) {
11363
11490
  const sys = info.prn.charAt(0);
11364
11491
  if (sys === "R") {
@@ -11409,11 +11536,11 @@ function ephInfoToEphemeris(info) {
11409
11536
  } else if (sys === "E") {
11410
11537
  epochMs = GAL_EPOCH_MS;
11411
11538
  } else {
11412
- epochMs = GPS_EPOCH_MS19;
11413
- const weeksNow = (info.lastReceived - GPS_EPOCH_MS19) / MS_PER_WEEK12;
11539
+ epochMs = GPS_EPOCH_MS20;
11540
+ const weeksNow = (info.lastReceived - GPS_EPOCH_MS20) / MS_PER_WEEK13;
11414
11541
  week += 1024 * Math.round((weeksNow - week) / 1024);
11415
11542
  }
11416
- const tocDate = new Date(epochMs + week * MS_PER_WEEK12 + tocSec * 1e3);
11543
+ const tocDate = new Date(epochMs + week * MS_PER_WEEK13 + tocSec * 1e3);
11417
11544
  return {
11418
11545
  system: sys,
11419
11546
  prn: info.prn,
@@ -16801,6 +16928,7 @@ function computePsdDb(centerMHz, halfSpanChips, numPoints, psdFn, f0 = 1023e3, f
16801
16928
  estimateWidelaneFcb,
16802
16929
  euclidean3D,
16803
16930
  extractWidelaneArcs,
16931
+ feedGeoBlock,
16804
16932
  fetchSourcetable,
16805
16933
  findSatBias,
16806
16934
  fixPppPosition,
@@ -16906,6 +17034,7 @@ function computePsdDb(centerMHz, halfSpanChips, numPoints, psdFn, f0 = 1023e3, f
16906
17034
  parseSbfBdsNav,
16907
17035
  parseSbfCnav,
16908
17036
  parseSbfGalNav,
17037
+ parseSbfGeoNav,
16909
17038
  parseSbfGloNav,
16910
17039
  parseSbfGpsNav,
16911
17040
  parseSbfHas,