gnss-js 1.13.0 → 1.14.1

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/rtcm3.cjs CHANGED
@@ -587,6 +587,96 @@ function decodeEphemeris(frame) {
587
587
  }
588
588
  }
589
589
 
590
+ // src/constants/time.ts
591
+ var MILLISECONDS_IN_WEEK = 6048e5;
592
+ var MILLISECONDS_IN_SECOND = 1e3;
593
+ var MILLISECONDS_GPS_TAI = 19e3;
594
+ var START_GPS_TIME = /* @__PURE__ */ new Date("1980-01-06T00:00:00Z");
595
+ var START_BDS_TIME = /* @__PURE__ */ new Date("2006-01-01T00:00:14Z");
596
+ var START_NTP_TIME = /* @__PURE__ */ new Date("1900-01-01T00:00:00Z");
597
+
598
+ // src/time/gnss.ts
599
+ function getTaiDate(date) {
600
+ return new Date(date.getTime() + MILLISECONDS_GPS_TAI);
601
+ }
602
+ function getNtpTime(date) {
603
+ return getTaiDate(date).getTime() - START_NTP_TIME.getTime();
604
+ }
605
+
606
+ // src/time/utc.ts
607
+ var LEAP_SECONDS_TABLE = [
608
+ [3692217600, 37],
609
+ // 1 Jan 2017
610
+ [3644697600, 36],
611
+ // 1 Jul 2015
612
+ [3550089600, 35],
613
+ // 1 Jul 2012
614
+ [3439756800, 34],
615
+ // 1 Jan 2009
616
+ [3345062400, 33],
617
+ // 1 Jan 2006
618
+ [3124137600, 32],
619
+ // 1 Jan 1999
620
+ [3076704e3, 31],
621
+ // 1 Jul 1997
622
+ [3029443200, 30],
623
+ // 1 Jan 1996
624
+ [2982009600, 29],
625
+ // 1 Jul 1994
626
+ [2950473600, 28],
627
+ // 1 Jul 1993
628
+ [2918937600, 27],
629
+ // 1 Jul 1992
630
+ [2871676800, 26],
631
+ // 1 Jan 1991
632
+ [2840140800, 25],
633
+ // 1 Jan 1990
634
+ [2776982400, 24],
635
+ // 1 Jan 1988
636
+ [2698012800, 23],
637
+ // 1 Jul 1985
638
+ [2634854400, 22],
639
+ // 1 Jul 1983
640
+ [2603318400, 21],
641
+ // 1 Jul 1982
642
+ [2571782400, 20],
643
+ // 1 Jul 1981
644
+ [2524521600, 19],
645
+ // 1 Jan 1980
646
+ [2492985600, 18],
647
+ // 1 Jan 1979
648
+ [2461449600, 17],
649
+ // 1 Jan 1978
650
+ [2429913600, 16],
651
+ // 1 Jan 1977
652
+ [2398291200, 15],
653
+ // 1 Jan 1976
654
+ [2366755200, 14],
655
+ // 1 Jan 1975
656
+ [2335219200, 13],
657
+ // 1 Jan 1974
658
+ [2303683200, 12],
659
+ // 1 Jan 1973
660
+ [2287785600, 11],
661
+ // 1 Jul 1972
662
+ [2272060800, 10]
663
+ // 1 Jan 1972
664
+ ];
665
+ function getLeap(date) {
666
+ const ntp_time = getNtpTime(date);
667
+ for (const [timestamp, leapSeconds] of LEAP_SECONDS_TABLE) {
668
+ if (ntp_time / MILLISECONDS_IN_SECOND - leapSeconds >= timestamp) {
669
+ return leapSeconds;
670
+ }
671
+ }
672
+ return 8;
673
+ }
674
+ function getGpsLeap(date) {
675
+ const leap_seconds = getLeap(date);
676
+ if (leap_seconds < 0) return 0;
677
+ return leap_seconds - 19;
678
+ }
679
+
590
680
  // src/constants/gnss.ts
591
681
  var C_LIGHT = 299792458;
592
682
  var FREQ = {
@@ -616,11 +706,6 @@ var GLO_F1_STEP = 562500;
616
706
  var GLO_F2_BASE = 1246e6;
617
707
  var GLO_F2_STEP = 437500;
618
708
 
619
- // src/constants/time.ts
620
- var MILLISECONDS_IN_WEEK = 6048e5;
621
- var START_GPS_TIME = /* @__PURE__ */ new Date("1980-01-06T00:00:00Z");
622
- var START_BDS_TIME = /* @__PURE__ */ new Date("2006-01-01T00:00:14Z");
623
-
624
709
  // src/rtcm3/msm.ts
625
710
  var GPS_L1 = FREQ.G["1"];
626
711
  var GPS_L2 = FREQ.G["2"];
@@ -1130,7 +1215,7 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
1130
1215
  let t2 = refMs - refMs % dayMs + diff * dayMs + msOfDay - 3 * 36e5;
1131
1216
  while (t2 - refMs > 3 * dayMs) t2 -= 7 * dayMs;
1132
1217
  while (refMs - t2 > 3 * dayMs) t2 += 7 * dayMs;
1133
- return new Date(t2);
1218
+ return new Date(t2 + getGpsLeap(new Date(t2)) * 1e3);
1134
1219
  }
1135
1220
  if (sys === "C") {
1136
1221
  const BDS_EPOCH = START_BDS_TIME.getTime();
@@ -1138,14 +1223,12 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
1138
1223
  let t2 = BDS_EPOCH + weeksSinceEpoch2 * MS_PER_WEEK + epochMs;
1139
1224
  if (t2 - refMs > MS_PER_WEEK / 2) t2 -= MS_PER_WEEK;
1140
1225
  else if (refMs - t2 > MS_PER_WEEK / 2) t2 += MS_PER_WEEK;
1141
- t2 -= 18e3;
1142
1226
  return new Date(t2);
1143
1227
  }
1144
1228
  const weeksSinceEpoch = Math.floor((refMs - GPS_EPOCH) / MS_PER_WEEK);
1145
1229
  let t = GPS_EPOCH + weeksSinceEpoch * MS_PER_WEEK + epochMs;
1146
1230
  if (t - refMs > MS_PER_WEEK / 2) t -= MS_PER_WEEK;
1147
1231
  else if (refMs - t > MS_PER_WEEK / 2) t += MS_PER_WEEK;
1148
- t -= 18e3;
1149
1232
  return new Date(t);
1150
1233
  }
1151
1234
  function setGloFreqNumber(slot, k) {
package/dist/rtcm3.d.cts CHANGED
@@ -62,6 +62,14 @@ declare function decodeMsmFull(frame: Rtcm3Frame): MsmEpoch | null;
62
62
  *
63
63
  * Requires an approximate reference time to resolve the current week.
64
64
  */
65
+ /**
66
+ * NOTE: returns a GPS-scale Date — the clock-face convention used by
67
+ * the RINEX parser and every consumer of epoch milliseconds in this
68
+ * library (satellite propagation, SPP, RINEX epoch tags). It is NOT
69
+ * UTC: converting to UTC here put every downstream satellite position
70
+ * 18 s (the current leap-second count) off — a ±14 km per-satellite
71
+ * range error that scattered live SPP solutions by kilometres.
72
+ */
65
73
  declare function msmEpochToDate(sys: string, epochMs: number, refTime?: Date): Date;
66
74
  /**
67
75
  * Set a GLONASS FDMA frequency number (k = -7..+13) for a slot (1-24),
package/dist/rtcm3.d.ts CHANGED
@@ -62,6 +62,14 @@ declare function decodeMsmFull(frame: Rtcm3Frame): MsmEpoch | null;
62
62
  *
63
63
  * Requires an approximate reference time to resolve the current week.
64
64
  */
65
+ /**
66
+ * NOTE: returns a GPS-scale Date — the clock-face convention used by
67
+ * the RINEX parser and every consumer of epoch milliseconds in this
68
+ * library (satellite propagation, SPP, RINEX epoch tags). It is NOT
69
+ * UTC: converting to UTC here put every downstream satellite position
70
+ * 18 s (the current leap-second count) off — a ±14 km per-satellite
71
+ * range error that scattered live SPP solutions by kilometres.
72
+ */
65
73
  declare function msmEpochToDate(sys: string, epochMs: number, refTime?: Date): Date;
66
74
  /**
67
75
  * Set a GLONASS FDMA frequency number (k = -7..+13) for a slot (1-24),
package/dist/rtcm3.js CHANGED
@@ -15,7 +15,8 @@ import {
15
15
  setRtcm3DebugHandler,
16
16
  updateStationMeta,
17
17
  updateStreamStats
18
- } from "./chunk-FGRC3PB3.js";
18
+ } from "./chunk-BRT6XZ7B.js";
19
+ import "./chunk-HVXYFUCB.js";
19
20
  import "./chunk-LEEU5OIO.js";
20
21
  import "./chunk-FIEWO4J4.js";
21
22
  export {