gnss-js 1.0.1 → 1.2.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/README.md +54 -0
- package/dist/analysis.cjs +3 -3
- package/dist/analysis.js +3 -3
- package/dist/{chunk-HKN3PUGN.js → chunk-5SPJH4MG.js} +35 -26
- package/dist/{chunk-WP2JFDLA.js → chunk-7EEWQ5DU.js} +93 -118
- package/dist/{chunk-SO3POWWR.js → chunk-G3N4S3DM.js} +2 -2
- package/dist/{chunk-7NOFXKET.js → chunk-HVXYFUCB.js} +72 -257
- package/dist/chunk-L5OUUNLT.js +198 -0
- package/dist/{chunk-HBLU2EJ4.js → chunk-OZCYOM5D.js} +1 -1
- package/dist/{chunk-4YN353Q7.js → chunk-VANVV4F7.js} +21 -7
- package/dist/{chunk-LWNTWBHB.js → chunk-W5WKEV7U.js} +3 -2
- package/dist/constants.cjs +3 -2
- package/dist/constants.js +7 -7
- package/dist/{ephemeris-C10stHhM.d.cts → ephemeris-Ohl6NAfw.d.cts} +11 -1
- package/dist/{ephemeris-C10stHhM.d.ts → ephemeris-Ohl6NAfw.d.ts} +11 -1
- package/dist/frames.cjs +250 -0
- package/dist/frames.d.cts +56 -0
- package/dist/frames.d.ts +56 -0
- package/dist/frames.js +222 -0
- package/dist/index.cjs +133 -152
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +96 -88
- package/dist/orbit.cjs +103 -7
- package/dist/orbit.d.cts +1 -1
- package/dist/orbit.d.ts +1 -1
- package/dist/orbit.js +3 -1
- package/dist/positioning.cjs +565 -0
- package/dist/positioning.d.cts +68 -0
- package/dist/positioning.d.ts +68 -0
- package/dist/positioning.js +206 -0
- package/dist/rinex.js +2 -2
- package/dist/rtcm3.cjs +116 -117
- package/dist/rtcm3.d.cts +9 -3
- package/dist/rtcm3.d.ts +9 -3
- package/dist/rtcm3.js +9 -2
- package/dist/signals.cjs +55 -26
- package/dist/signals.d.cts +26 -26
- package/dist/signals.d.ts +26 -26
- package/dist/signals.js +2 -1
- package/dist/time.js +20 -18
- package/package.json +11 -2
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
DAYS_MJD2000_MJD,
|
|
3
|
-
DAYS_MJD_JULIAN,
|
|
4
2
|
MILLISECONDS_GPS_TAI,
|
|
5
3
|
MILLISECONDS_IN_DAY,
|
|
6
4
|
MILLISECONDS_IN_HOUR,
|
|
@@ -8,98 +6,13 @@ import {
|
|
|
8
6
|
MILLISECONDS_IN_SECOND,
|
|
9
7
|
MILLISECONDS_IN_WEEK,
|
|
10
8
|
MILLISECONDS_TT_TAI,
|
|
11
|
-
RINEX_CODES,
|
|
12
9
|
START_BDS_TIME,
|
|
13
10
|
START_GAL_TIME,
|
|
14
11
|
START_GLO_LEAP,
|
|
15
12
|
START_GPS_TIME,
|
|
16
|
-
|
|
17
|
-
START_NTP_TIME,
|
|
18
|
-
START_TAI_TIME
|
|
13
|
+
START_NTP_TIME
|
|
19
14
|
} from "./chunk-LEEU5OIO.js";
|
|
20
15
|
|
|
21
|
-
// src/types/enums.ts
|
|
22
|
-
var Scale = /* @__PURE__ */ ((Scale2) => {
|
|
23
|
-
Scale2[Scale2["TAI"] = 0] = "TAI";
|
|
24
|
-
Scale2[Scale2["TT"] = 1] = "TT";
|
|
25
|
-
Scale2[Scale2["GPS"] = 2] = "GPS";
|
|
26
|
-
Scale2[Scale2["UTC"] = 3] = "UTC";
|
|
27
|
-
return Scale2;
|
|
28
|
-
})(Scale || {});
|
|
29
|
-
|
|
30
|
-
// src/time/functions.ts
|
|
31
|
-
function getTimeOfDay(date) {
|
|
32
|
-
return date.getTime() - Date.UTC(
|
|
33
|
-
date.getUTCFullYear(),
|
|
34
|
-
date.getUTCMonth(),
|
|
35
|
-
date.getUTCDate(),
|
|
36
|
-
0,
|
|
37
|
-
0,
|
|
38
|
-
0
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
function getDateFromTimeOfDay(timeOfDay, dateRaw) {
|
|
42
|
-
return new Date(
|
|
43
|
-
Date.UTC(
|
|
44
|
-
dateRaw.getUTCFullYear(),
|
|
45
|
-
dateRaw.getUTCMonth(),
|
|
46
|
-
dateRaw.getUTCDate(),
|
|
47
|
-
0,
|
|
48
|
-
0,
|
|
49
|
-
0
|
|
50
|
-
) + timeOfDay
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
function getDayOfYear(date) {
|
|
54
|
-
return Math.floor(
|
|
55
|
-
(date.getTime() - Date.UTC(date.getUTCFullYear())) / MILLISECONDS_IN_DAY
|
|
56
|
-
) + 1;
|
|
57
|
-
}
|
|
58
|
-
function getDateFromDayOfYear(dayOfYear, date) {
|
|
59
|
-
return new Date(
|
|
60
|
-
Date.UTC(
|
|
61
|
-
date.getUTCFullYear(),
|
|
62
|
-
0,
|
|
63
|
-
1,
|
|
64
|
-
date.getUTCHours(),
|
|
65
|
-
date.getUTCMinutes(),
|
|
66
|
-
date.getUTCSeconds(),
|
|
67
|
-
date.getUTCMilliseconds()
|
|
68
|
-
) + (dayOfYear - 1) * MILLISECONDS_IN_DAY
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
function getDayOfWeek(date) {
|
|
72
|
-
return date.getUTCDay();
|
|
73
|
-
}
|
|
74
|
-
function getDateFromDayOfWeek(dayOfWeek, dateRaw) {
|
|
75
|
-
if (dayOfWeek < 0 || dayOfWeek > 6)
|
|
76
|
-
throw new Error("Day of week must be a value between 0 and 7");
|
|
77
|
-
return new Date(
|
|
78
|
-
dateRaw.getTime() + (dayOfWeek - dateRaw.getUTCDay()) * MILLISECONDS_IN_DAY
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
function getDateFromHourCode(hourCode, date) {
|
|
82
|
-
const hour = RINEX_CODES.indexOf(hourCode);
|
|
83
|
-
if (hour === -1)
|
|
84
|
-
throw new Error("Hour code must be a lowercase letter between a and x");
|
|
85
|
-
const newDate = new Date(date.getTime());
|
|
86
|
-
newDate.setUTCHours(hour);
|
|
87
|
-
return newDate;
|
|
88
|
-
}
|
|
89
|
-
function getHourCode(date) {
|
|
90
|
-
return RINEX_CODES[date.getUTCHours()];
|
|
91
|
-
}
|
|
92
|
-
function getWeekOfYear(date) {
|
|
93
|
-
const target = new Date(
|
|
94
|
-
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
|
|
95
|
-
);
|
|
96
|
-
const dayNr = (target.getUTCDay() + 6) % 7;
|
|
97
|
-
target.setUTCDate(target.getUTCDate() - dayNr + 3);
|
|
98
|
-
const firstThursday = new Date(Date.UTC(target.getUTCFullYear(), 0, 4));
|
|
99
|
-
const dayDiff = (target.getTime() - firstThursday.getTime()) / (86400 * 1e3);
|
|
100
|
-
return 1 + Math.floor(dayDiff / 7) + 1;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
16
|
// src/time/time-difference.ts
|
|
104
17
|
function getTimeDifference(startDate, finalDate) {
|
|
105
18
|
return Math.floor(finalDate.getTime() - startDate.getTime());
|
|
@@ -139,6 +52,76 @@ function getTimeDifferenceFromObject(timeDifferenceObject) {
|
|
|
139
52
|
return getTimeDifferenceFromSeconds(seconds) + getTimeDifferenceFromMinutes(minutes) + getTimeDifferenceFromHours(hours) + getTimeDifferenceFromDays(days);
|
|
140
53
|
}
|
|
141
54
|
|
|
55
|
+
// src/time/gnss.ts
|
|
56
|
+
function getGpsTime(date) {
|
|
57
|
+
return date.getTime() - START_GPS_TIME.getTime();
|
|
58
|
+
}
|
|
59
|
+
function getDateFromGpsTime(gpsTime) {
|
|
60
|
+
return new Date(gpsTime + START_GPS_TIME.getTime());
|
|
61
|
+
}
|
|
62
|
+
function getGalTime(date) {
|
|
63
|
+
return date.getTime() - START_GAL_TIME.getTime();
|
|
64
|
+
}
|
|
65
|
+
function getDateFromGalTime(galTime) {
|
|
66
|
+
return new Date(galTime + START_GAL_TIME.getTime());
|
|
67
|
+
}
|
|
68
|
+
function getBdsTime(date) {
|
|
69
|
+
return date.getTime() - START_BDS_TIME.getTime();
|
|
70
|
+
}
|
|
71
|
+
function getDateFromBdsTime(bdsTime) {
|
|
72
|
+
return new Date(bdsTime + START_BDS_TIME.getTime());
|
|
73
|
+
}
|
|
74
|
+
function getUnixTime(date) {
|
|
75
|
+
const utc_date = getUtcDate(date);
|
|
76
|
+
return utc_date.getTime();
|
|
77
|
+
}
|
|
78
|
+
function getDateFromUnixTime(unixTime) {
|
|
79
|
+
return getDateFromUtc(new Date(unixTime));
|
|
80
|
+
}
|
|
81
|
+
function getWeekNumber(date) {
|
|
82
|
+
return Math.floor(getGpsTime(date) / MILLISECONDS_IN_WEEK);
|
|
83
|
+
}
|
|
84
|
+
function getTimeOfWeek(date) {
|
|
85
|
+
return getGpsTime(date) % MILLISECONDS_IN_WEEK;
|
|
86
|
+
}
|
|
87
|
+
function getDateFromGpsData(weekNumber, timeOfWeek) {
|
|
88
|
+
return new Date(
|
|
89
|
+
weekNumber * MILLISECONDS_IN_WEEK + timeOfWeek + START_GPS_TIME.getTime()
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
function getTaiDate(date) {
|
|
93
|
+
return new Date(date.getTime() + MILLISECONDS_GPS_TAI);
|
|
94
|
+
}
|
|
95
|
+
function getDateFromTai(tai_date) {
|
|
96
|
+
return new Date(tai_date.getTime() - MILLISECONDS_GPS_TAI);
|
|
97
|
+
}
|
|
98
|
+
function getTtDate(date) {
|
|
99
|
+
return new Date(date.getTime() + MILLISECONDS_GPS_TAI + MILLISECONDS_TT_TAI);
|
|
100
|
+
}
|
|
101
|
+
function getDateFromTt(tt_date) {
|
|
102
|
+
return new Date(
|
|
103
|
+
tt_date.getTime() - MILLISECONDS_GPS_TAI - MILLISECONDS_TT_TAI
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
function getGloN4(date) {
|
|
107
|
+
return Math.floor((date.getUTCFullYear() - START_GLO_LEAP.getFullYear()) / 4);
|
|
108
|
+
}
|
|
109
|
+
function getGloNA(date) {
|
|
110
|
+
const n4 = getGloN4(date);
|
|
111
|
+
const init4YearPeriod = new Date(START_GLO_LEAP);
|
|
112
|
+
init4YearPeriod.setUTCFullYear(init4YearPeriod.getUTCFullYear() + n4 * 4);
|
|
113
|
+
return Math.floor(getTimeDifference(init4YearPeriod, date) / MILLISECONDS_IN_DAY) + 1;
|
|
114
|
+
}
|
|
115
|
+
function getDateFromGloN(n4, na, tod) {
|
|
116
|
+
const date = new Date(START_GLO_LEAP);
|
|
117
|
+
date.setFullYear(date.getUTCFullYear() + n4 * 4);
|
|
118
|
+
date.setTime(date.getTime() + (na - 1) * MILLISECONDS_IN_DAY + tod);
|
|
119
|
+
return date;
|
|
120
|
+
}
|
|
121
|
+
function getNtpTime(date) {
|
|
122
|
+
return getTaiDate(date).getTime() - START_NTP_TIME.getTime();
|
|
123
|
+
}
|
|
124
|
+
|
|
142
125
|
// src/time/utc.ts
|
|
143
126
|
var LEAP_SECONDS_TABLE = [
|
|
144
127
|
[3692217600, 37],
|
|
@@ -228,167 +211,7 @@ function getDateFromUtc(utc_date) {
|
|
|
228
211
|
return gps_date;
|
|
229
212
|
}
|
|
230
213
|
|
|
231
|
-
// src/time/gnss.ts
|
|
232
|
-
function getGpsTime(date) {
|
|
233
|
-
return date.getTime() - START_GPS_TIME.getTime();
|
|
234
|
-
}
|
|
235
|
-
function getDateFromGpsTime(gpsTime) {
|
|
236
|
-
return new Date(gpsTime + START_GPS_TIME.getTime());
|
|
237
|
-
}
|
|
238
|
-
function getGalTime(date) {
|
|
239
|
-
return date.getTime() - START_GAL_TIME.getTime();
|
|
240
|
-
}
|
|
241
|
-
function getDateFromGalTime(galTime) {
|
|
242
|
-
return new Date(galTime + START_GAL_TIME.getTime());
|
|
243
|
-
}
|
|
244
|
-
function getBdsTime(date) {
|
|
245
|
-
return date.getTime() - START_BDS_TIME.getTime();
|
|
246
|
-
}
|
|
247
|
-
function getDateFromBdsTime(bdsTime) {
|
|
248
|
-
return new Date(bdsTime + START_BDS_TIME.getTime());
|
|
249
|
-
}
|
|
250
|
-
function getUnixTime(date) {
|
|
251
|
-
const utc_date = getUtcDate(date);
|
|
252
|
-
return utc_date.getTime();
|
|
253
|
-
}
|
|
254
|
-
function getDateFromUnixTime(unixTime) {
|
|
255
|
-
return getDateFromUtc(new Date(unixTime));
|
|
256
|
-
}
|
|
257
|
-
function getWeekNumber(date) {
|
|
258
|
-
return Math.floor(getGpsTime(date) / MILLISECONDS_IN_WEEK);
|
|
259
|
-
}
|
|
260
|
-
function getTimeOfWeek(date) {
|
|
261
|
-
return getGpsTime(date) % MILLISECONDS_IN_WEEK;
|
|
262
|
-
}
|
|
263
|
-
function getDateFromGpsData(weekNumber, timeOfWeek) {
|
|
264
|
-
return new Date(
|
|
265
|
-
weekNumber * MILLISECONDS_IN_WEEK + timeOfWeek + START_GPS_TIME.getTime()
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
function getTaiDate(date) {
|
|
269
|
-
return new Date(date.getTime() + MILLISECONDS_GPS_TAI);
|
|
270
|
-
}
|
|
271
|
-
function getDateFromTai(tai_date) {
|
|
272
|
-
return new Date(tai_date.getTime() - MILLISECONDS_GPS_TAI);
|
|
273
|
-
}
|
|
274
|
-
function getTtDate(date) {
|
|
275
|
-
return new Date(date.getTime() + MILLISECONDS_GPS_TAI + MILLISECONDS_TT_TAI);
|
|
276
|
-
}
|
|
277
|
-
function getDateFromTt(tt_date) {
|
|
278
|
-
return new Date(
|
|
279
|
-
tt_date.getTime() - MILLISECONDS_GPS_TAI - MILLISECONDS_TT_TAI
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
function getGloN4(date) {
|
|
283
|
-
return Math.floor((date.getUTCFullYear() - START_GLO_LEAP.getFullYear()) / 4);
|
|
284
|
-
}
|
|
285
|
-
function getGloNA(date) {
|
|
286
|
-
const n4 = getGloN4(date);
|
|
287
|
-
const init4YearPeriod = new Date(START_GLO_LEAP);
|
|
288
|
-
init4YearPeriod.setUTCFullYear(init4YearPeriod.getUTCFullYear() + n4 * 4);
|
|
289
|
-
return Math.floor(getTimeDifference(init4YearPeriod, date) / MILLISECONDS_IN_DAY) + 1;
|
|
290
|
-
}
|
|
291
|
-
function getDateFromGloN(n4, na, tod) {
|
|
292
|
-
const date = new Date(START_GLO_LEAP);
|
|
293
|
-
date.setFullYear(date.getUTCFullYear() + n4 * 4);
|
|
294
|
-
date.setTime(date.getTime() + (na - 1) * MILLISECONDS_IN_DAY + tod);
|
|
295
|
-
return date;
|
|
296
|
-
}
|
|
297
|
-
function getNtpTime(date) {
|
|
298
|
-
return getTaiDate(date).getTime() - START_NTP_TIME.getTime();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/time/rinex.ts
|
|
302
|
-
function getRINEX(date) {
|
|
303
|
-
const seconds = date.getUTCSeconds();
|
|
304
|
-
const milliseconds = date.getUTCMilliseconds();
|
|
305
|
-
const fractionalSeconds = (milliseconds / MILLISECONDS_IN_SECOND).toFixed(7).slice(1);
|
|
306
|
-
const formatted = `> ${date.getUTCFullYear()} ${String(
|
|
307
|
-
date.getUTCMonth() + 1
|
|
308
|
-
).padStart(2, "0")} ${String(date.getUTCDate()).padStart(2, "0")} ${String(
|
|
309
|
-
date.getUTCHours()
|
|
310
|
-
).padStart(2, "0")} ${String(date.getUTCMinutes()).padStart(
|
|
311
|
-
2,
|
|
312
|
-
"0"
|
|
313
|
-
)} ${String(seconds).padStart(2, "0")}${fractionalSeconds}`;
|
|
314
|
-
return formatted;
|
|
315
|
-
}
|
|
316
|
-
function getDateFromRINEX(rinex) {
|
|
317
|
-
const year = Number.parseInt(rinex.substring(2, 6));
|
|
318
|
-
const month = Number.parseInt(rinex.substring(7, 9)) - 1;
|
|
319
|
-
const day = Number.parseInt(rinex.substring(10, 12));
|
|
320
|
-
const hour = Number.parseInt(rinex.substring(13, 15));
|
|
321
|
-
const minute = Number.parseInt(rinex.substring(16, 18));
|
|
322
|
-
const second = Number.parseInt(rinex.substring(19, 21));
|
|
323
|
-
const millisecond = Number.parseInt(rinex.substring(22, 29)) / 1e4;
|
|
324
|
-
const date = new Date(
|
|
325
|
-
Date.UTC(year, month, day, hour, minute, second, millisecond)
|
|
326
|
-
);
|
|
327
|
-
return date;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// src/time/julian.ts
|
|
331
|
-
function getJulianDate(date, scale = 1 /* TT */) {
|
|
332
|
-
if (scale === 0 /* TAI */) {
|
|
333
|
-
return (date.getTime() - START_TAI_TIME.getTime()) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
334
|
-
}
|
|
335
|
-
if (scale === 2 /* GPS */) {
|
|
336
|
-
return (date.getTime() - START_TAI_TIME.getTime() - MILLISECONDS_GPS_TAI) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
337
|
-
}
|
|
338
|
-
if (scale === 3 /* UTC */) {
|
|
339
|
-
return (date.getTime() - START_TAI_TIME.getTime() - getLeap(date) * MILLISECONDS_IN_SECOND) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
340
|
-
}
|
|
341
|
-
return (date.getTime() - START_TAI_TIME.getTime() + MILLISECONDS_TT_TAI) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
342
|
-
}
|
|
343
|
-
function getDateFromJulianDate(julianDate, scale = 1 /* TT */) {
|
|
344
|
-
if (scale === 0 /* TAI */) {
|
|
345
|
-
return new Date(
|
|
346
|
-
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime()
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
if (scale === 2 /* GPS */) {
|
|
350
|
-
return new Date(
|
|
351
|
-
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime() + MILLISECONDS_GPS_TAI
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
if (scale === 3 /* UTC */) {
|
|
355
|
-
const utc_date = new Date(
|
|
356
|
-
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime()
|
|
357
|
-
);
|
|
358
|
-
const tai_date = new Date(
|
|
359
|
-
utc_date.getTime() + getLeap(utc_date) * MILLISECONDS_IN_SECOND
|
|
360
|
-
);
|
|
361
|
-
const leap_seconds = getLeap(getDateFromTai(tai_date));
|
|
362
|
-
return new Date(utc_date.getTime() + leap_seconds * MILLISECONDS_IN_SECOND);
|
|
363
|
-
}
|
|
364
|
-
return new Date(
|
|
365
|
-
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime() - MILLISECONDS_TT_TAI
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
function getMJD(date, scale = 1 /* TT */) {
|
|
369
|
-
return getJulianDate(date, scale) - DAYS_MJD_JULIAN;
|
|
370
|
-
}
|
|
371
|
-
function getDateFromMJD(mjd, scale = 1 /* TT */) {
|
|
372
|
-
return getDateFromJulianDate(mjd + DAYS_MJD_JULIAN, scale);
|
|
373
|
-
}
|
|
374
|
-
function getMJD2000(date, scale = 1 /* TT */) {
|
|
375
|
-
return getMJD(date, scale) - DAYS_MJD2000_MJD;
|
|
376
|
-
}
|
|
377
|
-
function getDateFromMJD2000(mjd2000, scale = 1 /* TT */) {
|
|
378
|
-
return getDateFromMJD(mjd2000 + DAYS_MJD2000_MJD, scale);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
214
|
export {
|
|
382
|
-
Scale,
|
|
383
|
-
getTimeOfDay,
|
|
384
|
-
getDateFromTimeOfDay,
|
|
385
|
-
getDayOfYear,
|
|
386
|
-
getDateFromDayOfYear,
|
|
387
|
-
getDayOfWeek,
|
|
388
|
-
getDateFromDayOfWeek,
|
|
389
|
-
getDateFromHourCode,
|
|
390
|
-
getHourCode,
|
|
391
|
-
getWeekOfYear,
|
|
392
215
|
getTimeDifference,
|
|
393
216
|
getSecondsFromTimeDifference,
|
|
394
217
|
getMinutesFromTimeDifference,
|
|
@@ -421,13 +244,5 @@ export {
|
|
|
421
244
|
getGloN4,
|
|
422
245
|
getGloNA,
|
|
423
246
|
getDateFromGloN,
|
|
424
|
-
getNtpTime
|
|
425
|
-
getRINEX,
|
|
426
|
-
getDateFromRINEX,
|
|
427
|
-
getJulianDate,
|
|
428
|
-
getDateFromJulianDate,
|
|
429
|
-
getMJD,
|
|
430
|
-
getDateFromMJD,
|
|
431
|
-
getMJD2000,
|
|
432
|
-
getDateFromMJD2000
|
|
247
|
+
getNtpTime
|
|
433
248
|
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getDateFromTai,
|
|
3
|
+
getLeap
|
|
4
|
+
} from "./chunk-HVXYFUCB.js";
|
|
5
|
+
import {
|
|
6
|
+
DAYS_MJD2000_MJD,
|
|
7
|
+
DAYS_MJD_JULIAN,
|
|
8
|
+
MILLISECONDS_GPS_TAI,
|
|
9
|
+
MILLISECONDS_IN_DAY,
|
|
10
|
+
MILLISECONDS_IN_SECOND,
|
|
11
|
+
MILLISECONDS_TT_TAI,
|
|
12
|
+
RINEX_CODES,
|
|
13
|
+
START_JULIAN_TAI,
|
|
14
|
+
START_TAI_TIME
|
|
15
|
+
} from "./chunk-LEEU5OIO.js";
|
|
16
|
+
|
|
17
|
+
// src/types/enums.ts
|
|
18
|
+
var Scale = /* @__PURE__ */ ((Scale2) => {
|
|
19
|
+
Scale2[Scale2["TAI"] = 0] = "TAI";
|
|
20
|
+
Scale2[Scale2["TT"] = 1] = "TT";
|
|
21
|
+
Scale2[Scale2["GPS"] = 2] = "GPS";
|
|
22
|
+
Scale2[Scale2["UTC"] = 3] = "UTC";
|
|
23
|
+
return Scale2;
|
|
24
|
+
})(Scale || {});
|
|
25
|
+
|
|
26
|
+
// src/time/functions.ts
|
|
27
|
+
function getTimeOfDay(date) {
|
|
28
|
+
return date.getTime() - Date.UTC(
|
|
29
|
+
date.getUTCFullYear(),
|
|
30
|
+
date.getUTCMonth(),
|
|
31
|
+
date.getUTCDate(),
|
|
32
|
+
0,
|
|
33
|
+
0,
|
|
34
|
+
0
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
function getDateFromTimeOfDay(timeOfDay, dateRaw) {
|
|
38
|
+
return new Date(
|
|
39
|
+
Date.UTC(
|
|
40
|
+
dateRaw.getUTCFullYear(),
|
|
41
|
+
dateRaw.getUTCMonth(),
|
|
42
|
+
dateRaw.getUTCDate(),
|
|
43
|
+
0,
|
|
44
|
+
0,
|
|
45
|
+
0
|
|
46
|
+
) + timeOfDay
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
function getDayOfYear(date) {
|
|
50
|
+
return Math.floor(
|
|
51
|
+
(date.getTime() - Date.UTC(date.getUTCFullYear())) / MILLISECONDS_IN_DAY
|
|
52
|
+
) + 1;
|
|
53
|
+
}
|
|
54
|
+
function getDateFromDayOfYear(dayOfYear, date) {
|
|
55
|
+
return new Date(
|
|
56
|
+
Date.UTC(
|
|
57
|
+
date.getUTCFullYear(),
|
|
58
|
+
0,
|
|
59
|
+
1,
|
|
60
|
+
date.getUTCHours(),
|
|
61
|
+
date.getUTCMinutes(),
|
|
62
|
+
date.getUTCSeconds(),
|
|
63
|
+
date.getUTCMilliseconds()
|
|
64
|
+
) + (dayOfYear - 1) * MILLISECONDS_IN_DAY
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function getDayOfWeek(date) {
|
|
68
|
+
return date.getUTCDay();
|
|
69
|
+
}
|
|
70
|
+
function getDateFromDayOfWeek(dayOfWeek, dateRaw) {
|
|
71
|
+
if (dayOfWeek < 0 || dayOfWeek > 6)
|
|
72
|
+
throw new Error("Day of week must be a value between 0 and 7");
|
|
73
|
+
return new Date(
|
|
74
|
+
dateRaw.getTime() + (dayOfWeek - dateRaw.getUTCDay()) * MILLISECONDS_IN_DAY
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function getDateFromHourCode(hourCode, date) {
|
|
78
|
+
const hour = RINEX_CODES.indexOf(hourCode);
|
|
79
|
+
if (hour === -1)
|
|
80
|
+
throw new Error("Hour code must be a lowercase letter between a and x");
|
|
81
|
+
const newDate = new Date(date.getTime());
|
|
82
|
+
newDate.setUTCHours(hour);
|
|
83
|
+
return newDate;
|
|
84
|
+
}
|
|
85
|
+
function getHourCode(date) {
|
|
86
|
+
return RINEX_CODES[date.getUTCHours()];
|
|
87
|
+
}
|
|
88
|
+
function getWeekOfYear(date) {
|
|
89
|
+
const target = new Date(
|
|
90
|
+
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
|
|
91
|
+
);
|
|
92
|
+
const dayNr = (target.getUTCDay() + 6) % 7;
|
|
93
|
+
target.setUTCDate(target.getUTCDate() - dayNr + 3);
|
|
94
|
+
const firstThursday = new Date(Date.UTC(target.getUTCFullYear(), 0, 4));
|
|
95
|
+
const dayDiff = (target.getTime() - firstThursday.getTime()) / (86400 * 1e3);
|
|
96
|
+
return 1 + Math.floor(dayDiff / 7) + 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/time/rinex.ts
|
|
100
|
+
function getRINEX(date) {
|
|
101
|
+
const seconds = date.getUTCSeconds();
|
|
102
|
+
const milliseconds = date.getUTCMilliseconds();
|
|
103
|
+
const fractionalSeconds = (milliseconds / MILLISECONDS_IN_SECOND).toFixed(7).slice(1);
|
|
104
|
+
const formatted = `> ${date.getUTCFullYear()} ${String(
|
|
105
|
+
date.getUTCMonth() + 1
|
|
106
|
+
).padStart(2, "0")} ${String(date.getUTCDate()).padStart(2, "0")} ${String(
|
|
107
|
+
date.getUTCHours()
|
|
108
|
+
).padStart(2, "0")} ${String(date.getUTCMinutes()).padStart(
|
|
109
|
+
2,
|
|
110
|
+
"0"
|
|
111
|
+
)} ${String(seconds).padStart(2, "0")}${fractionalSeconds}`;
|
|
112
|
+
return formatted;
|
|
113
|
+
}
|
|
114
|
+
function getDateFromRINEX(rinex) {
|
|
115
|
+
const year = Number.parseInt(rinex.substring(2, 6));
|
|
116
|
+
const month = Number.parseInt(rinex.substring(7, 9)) - 1;
|
|
117
|
+
const day = Number.parseInt(rinex.substring(10, 12));
|
|
118
|
+
const hour = Number.parseInt(rinex.substring(13, 15));
|
|
119
|
+
const minute = Number.parseInt(rinex.substring(16, 18));
|
|
120
|
+
const second = Number.parseInt(rinex.substring(19, 21));
|
|
121
|
+
const millisecond = Number.parseInt(rinex.substring(22, 29)) / 1e4;
|
|
122
|
+
const date = new Date(
|
|
123
|
+
Date.UTC(year, month, day, hour, minute, second, millisecond)
|
|
124
|
+
);
|
|
125
|
+
return date;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// src/time/julian.ts
|
|
129
|
+
function getJulianDate(date, scale = 1 /* TT */) {
|
|
130
|
+
if (scale === 0 /* TAI */) {
|
|
131
|
+
return (date.getTime() - START_TAI_TIME.getTime()) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
132
|
+
}
|
|
133
|
+
if (scale === 2 /* GPS */) {
|
|
134
|
+
return (date.getTime() - START_TAI_TIME.getTime() - MILLISECONDS_GPS_TAI) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
135
|
+
}
|
|
136
|
+
if (scale === 3 /* UTC */) {
|
|
137
|
+
return (date.getTime() - START_TAI_TIME.getTime() - getLeap(date) * MILLISECONDS_IN_SECOND) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
138
|
+
}
|
|
139
|
+
return (date.getTime() - START_TAI_TIME.getTime() + MILLISECONDS_TT_TAI) / MILLISECONDS_IN_DAY + START_JULIAN_TAI;
|
|
140
|
+
}
|
|
141
|
+
function getDateFromJulianDate(julianDate, scale = 1 /* TT */) {
|
|
142
|
+
if (scale === 0 /* TAI */) {
|
|
143
|
+
return new Date(
|
|
144
|
+
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime()
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (scale === 2 /* GPS */) {
|
|
148
|
+
return new Date(
|
|
149
|
+
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime() + MILLISECONDS_GPS_TAI
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
if (scale === 3 /* UTC */) {
|
|
153
|
+
const utc_date = new Date(
|
|
154
|
+
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime()
|
|
155
|
+
);
|
|
156
|
+
const tai_date = new Date(
|
|
157
|
+
utc_date.getTime() + getLeap(utc_date) * MILLISECONDS_IN_SECOND
|
|
158
|
+
);
|
|
159
|
+
const leap_seconds = getLeap(getDateFromTai(tai_date));
|
|
160
|
+
return new Date(utc_date.getTime() + leap_seconds * MILLISECONDS_IN_SECOND);
|
|
161
|
+
}
|
|
162
|
+
return new Date(
|
|
163
|
+
(julianDate - START_JULIAN_TAI) * MILLISECONDS_IN_DAY + START_TAI_TIME.getTime() - MILLISECONDS_TT_TAI
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
function getMJD(date, scale = 1 /* TT */) {
|
|
167
|
+
return getJulianDate(date, scale) - DAYS_MJD_JULIAN;
|
|
168
|
+
}
|
|
169
|
+
function getDateFromMJD(mjd, scale = 1 /* TT */) {
|
|
170
|
+
return getDateFromJulianDate(mjd + DAYS_MJD_JULIAN, scale);
|
|
171
|
+
}
|
|
172
|
+
function getMJD2000(date, scale = 1 /* TT */) {
|
|
173
|
+
return getMJD(date, scale) - DAYS_MJD2000_MJD;
|
|
174
|
+
}
|
|
175
|
+
function getDateFromMJD2000(mjd2000, scale = 1 /* TT */) {
|
|
176
|
+
return getDateFromMJD(mjd2000 + DAYS_MJD2000_MJD, scale);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export {
|
|
180
|
+
Scale,
|
|
181
|
+
getTimeOfDay,
|
|
182
|
+
getDateFromTimeOfDay,
|
|
183
|
+
getDayOfYear,
|
|
184
|
+
getDateFromDayOfYear,
|
|
185
|
+
getDayOfWeek,
|
|
186
|
+
getDateFromDayOfWeek,
|
|
187
|
+
getDateFromHourCode,
|
|
188
|
+
getHourCode,
|
|
189
|
+
getWeekOfYear,
|
|
190
|
+
getRINEX,
|
|
191
|
+
getDateFromRINEX,
|
|
192
|
+
getJulianDate,
|
|
193
|
+
getDateFromJulianDate,
|
|
194
|
+
getMJD,
|
|
195
|
+
getDateFromMJD,
|
|
196
|
+
getMJD2000,
|
|
197
|
+
getDateFromMJD2000
|
|
198
|
+
};
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getGpsLeap
|
|
3
|
+
} from "./chunk-HVXYFUCB.js";
|
|
1
4
|
import {
|
|
2
5
|
ecefToGeodetic
|
|
3
6
|
} from "./chunk-37QNKGTC.js";
|
|
7
|
+
import {
|
|
8
|
+
START_BDS_TIME,
|
|
9
|
+
START_GPS_TIME
|
|
10
|
+
} from "./chunk-LEEU5OIO.js";
|
|
4
11
|
|
|
5
12
|
// src/orbit/index.ts
|
|
6
13
|
var GM_GPS = 3986005e8;
|
|
@@ -8,6 +15,8 @@ var GM_GAL = 3986004418e5;
|
|
|
8
15
|
var GM_BDS = 3986004418e5;
|
|
9
16
|
var GM_GLO = 39860044e7;
|
|
10
17
|
var OMEGA_E = 72921151467e-15;
|
|
18
|
+
var BDS_GEO_MAX_INCLINATION_RAD = 0.1;
|
|
19
|
+
var BDS_GEO_MIN_SEMIMAJOR_AXIS_M = 4e7;
|
|
11
20
|
var AE_GLO = 6378136;
|
|
12
21
|
var J2_GLO = 108263e-8;
|
|
13
22
|
var TWO_PI = 2 * Math.PI;
|
|
@@ -45,7 +54,7 @@ function keplerPosition(eph, t) {
|
|
|
45
54
|
const ik = eph.i0 + dik + eph.idot * tk;
|
|
46
55
|
const xp = rk * Math.cos(uk);
|
|
47
56
|
const yp = rk * Math.sin(uk);
|
|
48
|
-
const isBdsGeo = eph.system === "C" && Math.abs(eph.i0) <
|
|
57
|
+
const isBdsGeo = eph.system === "C" && Math.abs(eph.i0) < BDS_GEO_MAX_INCLINATION_RAD && a > BDS_GEO_MIN_SEMIMAJOR_AXIS_M;
|
|
49
58
|
if (isBdsGeo) {
|
|
50
59
|
const omegak2 = eph.omega0 + eph.omegaDot * tk - OMEGA_E * eph.toe;
|
|
51
60
|
const cosO2 = Math.cos(omegak2);
|
|
@@ -224,11 +233,13 @@ function selectEphemeris(ephemerides, prn, timeMs) {
|
|
|
224
233
|
}
|
|
225
234
|
function computeSatPosition(eph, timeMs) {
|
|
226
235
|
if (eph.system === "R" || eph.system === "S") {
|
|
227
|
-
|
|
236
|
+
const leapMs = getGpsLeap(new Date(timeMs)) * 1e3;
|
|
237
|
+
return glonassPosition(eph, (timeMs - leapMs) / 1e3);
|
|
228
238
|
}
|
|
229
|
-
const GPS_EPOCH =
|
|
239
|
+
const GPS_EPOCH = START_GPS_TIME.getTime();
|
|
230
240
|
const gpsSeconds = (timeMs - GPS_EPOCH) / 1e3;
|
|
231
|
-
|
|
241
|
+
let tow = gpsSeconds % (7 * 86400);
|
|
242
|
+
if (eph.system === "C") tow = (tow - 14 + 604800) % 604800;
|
|
232
243
|
return keplerPosition(eph, tow);
|
|
233
244
|
}
|
|
234
245
|
function navTimesFromEph(ephs) {
|
|
@@ -310,8 +321,8 @@ function selectBest(ephs, timeMs) {
|
|
|
310
321
|
}
|
|
311
322
|
return best;
|
|
312
323
|
}
|
|
313
|
-
var GPS_EPOCH_MS =
|
|
314
|
-
var BDS_EPOCH_MS =
|
|
324
|
+
var GPS_EPOCH_MS = START_GPS_TIME.getTime();
|
|
325
|
+
var BDS_EPOCH_MS = START_BDS_TIME.getTime();
|
|
315
326
|
var GAL_EPOCH_MS = GPS_EPOCH_MS;
|
|
316
327
|
function ephInfoToEphemeris(info) {
|
|
317
328
|
const sys = info.prn.charAt(0);
|
|
@@ -352,6 +363,9 @@ function ephInfoToEphemeris(info) {
|
|
|
352
363
|
}
|
|
353
364
|
if (info.sqrtA === void 0 || info.eccentricity === void 0 || info.inclination === void 0 || info.omega0 === void 0 || info.argPerigee === void 0 || info.meanAnomaly === void 0 || info.toe === void 0 || info.week === void 0)
|
|
354
365
|
return null;
|
|
366
|
+
if (info.eccentricity < 0 || info.eccentricity >= 1 || info.sqrtA < 3e3 || info.sqrtA > 9e3 || info.toe < 0 || info.toe > 604800) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
355
369
|
let epochMs;
|
|
356
370
|
const tocSec = info.toc ?? info.toe;
|
|
357
371
|
if (sys === "C") {
|
|
@@ -393,7 +407,7 @@ function ephInfoToEphemeris(info) {
|
|
|
393
407
|
};
|
|
394
408
|
}
|
|
395
409
|
function computeLiveSkyPositions(ephemerides, rxPos, cn0Map) {
|
|
396
|
-
const now = Date.now();
|
|
410
|
+
const now = Date.now() + getGpsLeap(/* @__PURE__ */ new Date()) * 1e3;
|
|
397
411
|
const result = [];
|
|
398
412
|
const [rxX, rxY, rxZ] = rxPos;
|
|
399
413
|
const [rxLat, rxLon] = ecefToGeodetic(rxX, rxY, rxZ);
|
|
@@ -20,7 +20,8 @@ var SYS_SHORT = {
|
|
|
20
20
|
var C_LIGHT = 299792458;
|
|
21
21
|
var FREQ = {
|
|
22
22
|
G: { "1": 157542e4, "2": 12276e5, "5": 117645e4 },
|
|
23
|
-
R
|
|
23
|
+
// R bands 4/6 are the CDMA L1OC/L2OC center frequencies
|
|
24
|
+
R: { "3": 1202025e3, "4": 1600995e3, "6": 124806e4 },
|
|
24
25
|
E: {
|
|
25
26
|
"1": 157542e4,
|
|
26
27
|
"5": 117645e4,
|
|
@@ -114,11 +115,11 @@ function buildGloChannelMap(slots) {
|
|
|
114
115
|
return map;
|
|
115
116
|
}
|
|
116
117
|
function gloFreq(gloChannels, prn, band) {
|
|
118
|
+
if (band === "3" || band === "4" || band === "6") return FREQ.R[band];
|
|
117
119
|
const k = gloChannels[prn];
|
|
118
120
|
if (k === void 0) return void 0;
|
|
119
121
|
if (band === "1") return GLO_F1_BASE + k * GLO_F1_STEP;
|
|
120
122
|
if (band === "2") return GLO_F2_BASE + k * GLO_F2_STEP;
|
|
121
|
-
if (band === "3") return GLO_F3;
|
|
122
123
|
return void 0;
|
|
123
124
|
}
|
|
124
125
|
function getFreq(gloChannels, prn, band) {
|
package/dist/constants.cjs
CHANGED
|
@@ -148,7 +148,8 @@ var SYS_SHORT = {
|
|
|
148
148
|
var C_LIGHT = 299792458;
|
|
149
149
|
var FREQ = {
|
|
150
150
|
G: { "1": 157542e4, "2": 12276e5, "5": 117645e4 },
|
|
151
|
-
R
|
|
151
|
+
// R bands 4/6 are the CDMA L1OC/L2OC center frequencies
|
|
152
|
+
R: { "3": 1202025e3, "4": 1600995e3, "6": 124806e4 },
|
|
152
153
|
E: {
|
|
153
154
|
"1": 157542e4,
|
|
154
155
|
"5": 117645e4,
|
|
@@ -242,11 +243,11 @@ function buildGloChannelMap(slots) {
|
|
|
242
243
|
return map;
|
|
243
244
|
}
|
|
244
245
|
function gloFreq(gloChannels, prn, band) {
|
|
246
|
+
if (band === "3" || band === "4" || band === "6") return FREQ.R[band];
|
|
245
247
|
const k = gloChannels[prn];
|
|
246
248
|
if (k === void 0) return void 0;
|
|
247
249
|
if (band === "1") return GLO_F1_BASE + k * GLO_F1_STEP;
|
|
248
250
|
if (band === "2") return GLO_F2_BASE + k * GLO_F2_STEP;
|
|
249
|
-
if (band === "3") return GLO_F3;
|
|
250
251
|
return void 0;
|
|
251
252
|
}
|
|
252
253
|
function getFreq(gloChannels, prn, band) {
|