gnss-js 1.14.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.
@@ -1,3 +1,6 @@
1
+ import {
2
+ getGpsLeap
3
+ } from "./chunk-HVXYFUCB.js";
1
4
  import {
2
5
  MILLISECONDS_IN_WEEK,
3
6
  START_BDS_TIME,
@@ -1069,7 +1072,7 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
1069
1072
  let t2 = refMs - refMs % dayMs + diff * dayMs + msOfDay - 3 * 36e5;
1070
1073
  while (t2 - refMs > 3 * dayMs) t2 -= 7 * dayMs;
1071
1074
  while (refMs - t2 > 3 * dayMs) t2 += 7 * dayMs;
1072
- return new Date(t2);
1075
+ return new Date(t2 + getGpsLeap(new Date(t2)) * 1e3);
1073
1076
  }
1074
1077
  if (sys === "C") {
1075
1078
  const BDS_EPOCH = START_BDS_TIME.getTime();
@@ -1077,14 +1080,12 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
1077
1080
  let t2 = BDS_EPOCH + weeksSinceEpoch2 * MS_PER_WEEK + epochMs;
1078
1081
  if (t2 - refMs > MS_PER_WEEK / 2) t2 -= MS_PER_WEEK;
1079
1082
  else if (refMs - t2 > MS_PER_WEEK / 2) t2 += MS_PER_WEEK;
1080
- t2 -= 18e3;
1081
1083
  return new Date(t2);
1082
1084
  }
1083
1085
  const weeksSinceEpoch = Math.floor((refMs - GPS_EPOCH) / MS_PER_WEEK);
1084
1086
  let t = GPS_EPOCH + weeksSinceEpoch * MS_PER_WEEK + epochMs;
1085
1087
  if (t - refMs > MS_PER_WEEK / 2) t -= MS_PER_WEEK;
1086
1088
  else if (refMs - t > MS_PER_WEEK / 2) t += MS_PER_WEEK;
1087
- t -= 18e3;
1088
1089
  return new Date(t);
1089
1090
  }
1090
1091
  function setGloFreqNumber(slot, k) {
@@ -2,7 +2,7 @@ import {
2
2
  computeDop,
3
3
  computeSatPosition,
4
4
  ecefToAzEl
5
- } from "./chunk-VAHMHYID.js";
5
+ } from "./chunk-OMVL3X7V.js";
6
6
  import {
7
7
  ecefToGeodetic
8
8
  } from "./chunk-37QNKGTC.js";
package/dist/index.cjs CHANGED
@@ -4224,7 +4224,7 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
4224
4224
  let t2 = refMs - refMs % dayMs + diff * dayMs + msOfDay - 3 * 36e5;
4225
4225
  while (t2 - refMs > 3 * dayMs) t2 -= 7 * dayMs;
4226
4226
  while (refMs - t2 > 3 * dayMs) t2 += 7 * dayMs;
4227
- return new Date(t2);
4227
+ return new Date(t2 + getGpsLeap(new Date(t2)) * 1e3);
4228
4228
  }
4229
4229
  if (sys === "C") {
4230
4230
  const BDS_EPOCH = START_BDS_TIME.getTime();
@@ -4232,14 +4232,12 @@ function msmEpochToDate(sys, epochMs, refTime = /* @__PURE__ */ new Date()) {
4232
4232
  let t2 = BDS_EPOCH + weeksSinceEpoch2 * MS_PER_WEEK + epochMs;
4233
4233
  if (t2 - refMs > MS_PER_WEEK / 2) t2 -= MS_PER_WEEK;
4234
4234
  else if (refMs - t2 > MS_PER_WEEK / 2) t2 += MS_PER_WEEK;
4235
- t2 -= 18e3;
4236
4235
  return new Date(t2);
4237
4236
  }
4238
4237
  const weeksSinceEpoch = Math.floor((refMs - GPS_EPOCH) / MS_PER_WEEK);
4239
4238
  let t = GPS_EPOCH + weeksSinceEpoch * MS_PER_WEEK + epochMs;
4240
4239
  if (t - refMs > MS_PER_WEEK / 2) t -= MS_PER_WEEK;
4241
4240
  else if (refMs - t > MS_PER_WEEK / 2) t += MS_PER_WEEK;
4242
- t -= 18e3;
4243
4241
  return new Date(t);
4244
4242
  }
4245
4243
  function setGloFreqNumber(slot, k) {
package/dist/index.js CHANGED
@@ -112,7 +112,7 @@ import {
112
112
  klobucharDelay,
113
113
  satClockCorrection,
114
114
  solveSpp
115
- } from "./chunk-E5CP37P2.js";
115
+ } from "./chunk-QXZZNXE3.js";
116
116
  import {
117
117
  computeAllPositions,
118
118
  computeDop,
@@ -129,42 +129,7 @@ import {
129
129
  navTimesFromEph,
130
130
  rangeRate,
131
131
  selectEphemeris
132
- } from "./chunk-VAHMHYID.js";
133
- import {
134
- getBdsTime,
135
- getDateFromBdsTime,
136
- getDateFromGalTime,
137
- getDateFromGloN,
138
- getDateFromGpsData,
139
- getDateFromGpsTime,
140
- getDateFromTai,
141
- getDateFromTt,
142
- getDateFromUnixTime,
143
- getDateFromUtc,
144
- getGalTime,
145
- getGloN4,
146
- getGloNA,
147
- getGpsLeap,
148
- getGpsTime,
149
- getHoursFromTimeDifference,
150
- getLeap,
151
- getMinutesFromTimeDifference,
152
- getNtpTime,
153
- getSecondsFromTimeDifference,
154
- getTaiDate,
155
- getTimeDifference,
156
- getTimeDifferenceFromDays,
157
- getTimeDifferenceFromHours,
158
- getTimeDifferenceFromMinutes,
159
- getTimeDifferenceFromObject,
160
- getTimeDifferenceFromSeconds,
161
- getTimeOfWeek,
162
- getTotalDaysFromTimeDifference,
163
- getTtDate,
164
- getUnixTime,
165
- getUtcDate,
166
- getWeekNumber
167
- } from "./chunk-HVXYFUCB.js";
132
+ } from "./chunk-OMVL3X7V.js";
168
133
  import {
169
134
  clampUnit,
170
135
  ecefToGeodetic,
@@ -224,7 +189,42 @@ import {
224
189
  setRtcm3DebugHandler,
225
190
  updateStationMeta,
226
191
  updateStreamStats
227
- } from "./chunk-FGRC3PB3.js";
192
+ } from "./chunk-BRT6XZ7B.js";
193
+ import {
194
+ getBdsTime,
195
+ getDateFromBdsTime,
196
+ getDateFromGalTime,
197
+ getDateFromGloN,
198
+ getDateFromGpsData,
199
+ getDateFromGpsTime,
200
+ getDateFromTai,
201
+ getDateFromTt,
202
+ getDateFromUnixTime,
203
+ getDateFromUtc,
204
+ getGalTime,
205
+ getGloN4,
206
+ getGloNA,
207
+ getGpsLeap,
208
+ getGpsTime,
209
+ getHoursFromTimeDifference,
210
+ getLeap,
211
+ getMinutesFromTimeDifference,
212
+ getNtpTime,
213
+ getSecondsFromTimeDifference,
214
+ getTaiDate,
215
+ getTimeDifference,
216
+ getTimeDifferenceFromDays,
217
+ getTimeDifferenceFromHours,
218
+ getTimeDifferenceFromMinutes,
219
+ getTimeDifferenceFromObject,
220
+ getTimeDifferenceFromSeconds,
221
+ getTimeOfWeek,
222
+ getTotalDaysFromTimeDifference,
223
+ getTtDate,
224
+ getUnixTime,
225
+ getUtcDate,
226
+ getWeekNumber
227
+ } from "./chunk-HVXYFUCB.js";
228
228
  import {
229
229
  DAYS_MJD2000_MJD,
230
230
  DAYS_MJD_JULIAN,
package/dist/orbit.js CHANGED
@@ -14,13 +14,13 @@ import {
14
14
  navTimesFromEph,
15
15
  rangeRate,
16
16
  selectEphemeris
17
- } from "./chunk-VAHMHYID.js";
18
- import "./chunk-HVXYFUCB.js";
17
+ } from "./chunk-OMVL3X7V.js";
19
18
  import {
20
19
  ecefToGeodetic,
21
20
  geodeticToEcef
22
21
  } from "./chunk-37QNKGTC.js";
23
22
  import "./chunk-6FAL6P4G.js";
23
+ import "./chunk-HVXYFUCB.js";
24
24
  import "./chunk-LEEU5OIO.js";
25
25
  import "./chunk-FIEWO4J4.js";
26
26
  export {
@@ -3,11 +3,11 @@ import {
3
3
  klobucharDelay,
4
4
  satClockCorrection,
5
5
  solveSpp
6
- } from "./chunk-E5CP37P2.js";
7
- import "./chunk-VAHMHYID.js";
8
- import "./chunk-HVXYFUCB.js";
6
+ } from "./chunk-QXZZNXE3.js";
7
+ import "./chunk-OMVL3X7V.js";
9
8
  import "./chunk-37QNKGTC.js";
10
9
  import "./chunk-6FAL6P4G.js";
10
+ import "./chunk-HVXYFUCB.js";
11
11
  import "./chunk-LEEU5OIO.js";
12
12
  import "./chunk-FIEWO4J4.js";
13
13
  export {
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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gnss-js",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Comprehensive GNSS library for JavaScript — time scales, coordinates, RINEX parsing, RTCM3 decoding, orbit computation, and signal analysis",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -1,9 +1,9 @@
1
- import {
2
- getGpsLeap
3
- } from "./chunk-HVXYFUCB.js";
4
1
  import {
5
2
  ecefToGeodetic
6
3
  } from "./chunk-37QNKGTC.js";
4
+ import {
5
+ getGpsLeap
6
+ } from "./chunk-HVXYFUCB.js";
7
7
  import {
8
8
  START_BDS_TIME,
9
9
  START_GPS_TIME