gnss-js 2.11.0 → 2.12.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 +15 -0
- package/dist/analysis.cjs +24 -25
- package/dist/analysis.js +2 -2
- package/dist/{clk-DGVBGRzA.d.cts → bias-sinex-OGMw9xEZ.d.cts} +66 -1
- package/dist/{clk-DGVBGRzA.d.ts → bias-sinex-OGMw9xEZ.d.ts} +66 -1
- package/dist/{chunk-MDO77CCC.js → chunk-2DJ4XENO.js} +45 -0
- package/dist/{chunk-IQHQHUOB.js → chunk-2KQMCJ5Z.js} +5 -3
- package/dist/chunk-E3Y6YKQM.js +65 -0
- package/dist/{chunk-3U5AX7PY.js → chunk-FEABDV5P.js} +24 -25
- package/dist/{chunk-RFPR4LKM.js → chunk-HWHD5E6V.js} +19 -75
- package/dist/{chunk-KUSUN7DP.js → chunk-MFCPYUEI.js} +1 -1
- package/dist/{chunk-SSWFX3P3.js → chunk-NIJ6WFQJ.js} +6 -321
- package/dist/{chunk-UMINQTMK.js → chunk-RWFJEVLJ.js} +589 -295
- package/dist/chunk-TWGZTRBL.js +323 -0
- package/dist/index.cjs +655 -316
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -9
- package/dist/osnma.cjs +1336 -0
- package/dist/osnma.d.cts +273 -0
- package/dist/osnma.d.ts +273 -0
- package/dist/osnma.js +1216 -0
- package/dist/positioning.cjs +585 -291
- package/dist/positioning.d.cts +114 -4
- package/dist/positioning.d.ts +114 -4
- package/dist/positioning.js +1 -1
- package/dist/rinex.cjs +70 -25
- package/dist/rinex.d.cts +2 -50
- package/dist/rinex.d.ts +2 -50
- package/dist/rinex.js +4 -2
- package/dist/sbf.js +7 -4
- package/dist/ubx.js +3 -2
- package/package.json +6 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
crc24q
|
|
3
|
+
} from "./chunk-HUXQABJI.js";
|
|
4
|
+
import {
|
|
5
|
+
GPS_PI,
|
|
6
|
+
getBitS,
|
|
7
|
+
getBitU
|
|
8
|
+
} from "./chunk-V2D5KUKH.js";
|
|
9
|
+
|
|
10
|
+
// src/navbits/gal.ts
|
|
11
|
+
var GPS_EPOCH_MS = Date.UTC(1980, 0, 6);
|
|
12
|
+
var SEC_PER_WEEK = 7 * 86400;
|
|
13
|
+
var HALF_WEEK = 302400;
|
|
14
|
+
var GST_GPS_WEEK_OFFSET = 1024;
|
|
15
|
+
function galInavPageCrcOk(page) {
|
|
16
|
+
if (page.length < 28) return false;
|
|
17
|
+
return crc24q(page, 196) === getBitU(page, 196, 24);
|
|
18
|
+
}
|
|
19
|
+
function galFnavPageCrcOk(page) {
|
|
20
|
+
if (page.length < 30) return false;
|
|
21
|
+
return crc24q(page, 214) === getBitU(page, 214, 24);
|
|
22
|
+
}
|
|
23
|
+
function gpsDate(week, sec) {
|
|
24
|
+
return new Date(GPS_EPOCH_MS + (week * SEC_PER_WEEK + sec) * 1e3);
|
|
25
|
+
}
|
|
26
|
+
function weekOfToe(week, tow, toe) {
|
|
27
|
+
if (toe - tow > HALF_WEEK) return week - 1;
|
|
28
|
+
if (toe - tow < -HALF_WEEK) return week + 1;
|
|
29
|
+
return week;
|
|
30
|
+
}
|
|
31
|
+
var two = (n) => String(n).padStart(2, "0");
|
|
32
|
+
function decodeGalInavWords(words) {
|
|
33
|
+
if (words.length < 96) return null;
|
|
34
|
+
const b = words;
|
|
35
|
+
let i = 128;
|
|
36
|
+
const type1 = getBitU(b, i, 6);
|
|
37
|
+
i += 6;
|
|
38
|
+
const iodNav1 = getBitU(b, i, 10);
|
|
39
|
+
i += 10;
|
|
40
|
+
const toes = getBitU(b, i, 14) * 60;
|
|
41
|
+
i += 14;
|
|
42
|
+
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
43
|
+
i += 32;
|
|
44
|
+
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
45
|
+
i += 32;
|
|
46
|
+
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
47
|
+
i = 128 * 2;
|
|
48
|
+
const type2 = getBitU(b, i, 6);
|
|
49
|
+
i += 6;
|
|
50
|
+
const iodNav2 = getBitU(b, i, 10);
|
|
51
|
+
i += 10;
|
|
52
|
+
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
53
|
+
i += 32;
|
|
54
|
+
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
55
|
+
i += 32;
|
|
56
|
+
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
57
|
+
i += 32;
|
|
58
|
+
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
59
|
+
i = 128 * 3;
|
|
60
|
+
const type3 = getBitU(b, i, 6);
|
|
61
|
+
i += 6;
|
|
62
|
+
const iodNav3 = getBitU(b, i, 10);
|
|
63
|
+
i += 10;
|
|
64
|
+
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
65
|
+
i += 24;
|
|
66
|
+
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
67
|
+
i += 16;
|
|
68
|
+
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
69
|
+
i += 16;
|
|
70
|
+
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
71
|
+
i += 16;
|
|
72
|
+
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
73
|
+
i += 16;
|
|
74
|
+
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
75
|
+
i = 128 * 4;
|
|
76
|
+
const type4 = getBitU(b, i, 6);
|
|
77
|
+
i += 6;
|
|
78
|
+
const iodNav4 = getBitU(b, i, 10);
|
|
79
|
+
i += 10;
|
|
80
|
+
const svid = getBitU(b, i, 6);
|
|
81
|
+
i += 6;
|
|
82
|
+
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
83
|
+
i += 16;
|
|
84
|
+
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
85
|
+
i += 16;
|
|
86
|
+
const tocs = getBitU(b, i, 14) * 60;
|
|
87
|
+
i += 14;
|
|
88
|
+
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
89
|
+
i += 31;
|
|
90
|
+
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
91
|
+
i += 21;
|
|
92
|
+
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
93
|
+
i = 128 * 5;
|
|
94
|
+
const type5 = getBitU(b, i, 6);
|
|
95
|
+
i += 6 + 11 + 11 + 14 + 5;
|
|
96
|
+
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
97
|
+
i += 10;
|
|
98
|
+
i += 10;
|
|
99
|
+
const e5bHs = getBitU(b, i, 2);
|
|
100
|
+
i += 2;
|
|
101
|
+
const e1bHs = getBitU(b, i, 2);
|
|
102
|
+
i += 2;
|
|
103
|
+
const e5bDvs = getBitU(b, i, 1);
|
|
104
|
+
i += 1;
|
|
105
|
+
const e1bDvs = getBitU(b, i, 1);
|
|
106
|
+
i += 1;
|
|
107
|
+
const gstWeek = getBitU(b, i, 12);
|
|
108
|
+
i += 12;
|
|
109
|
+
const tow = getBitU(b, i, 20);
|
|
110
|
+
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4 || type5 !== 5)
|
|
111
|
+
return null;
|
|
112
|
+
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
113
|
+
return null;
|
|
114
|
+
if (svid < 1 || svid > 36) return null;
|
|
115
|
+
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
116
|
+
const tocDate = gpsDate(week, tocs);
|
|
117
|
+
return {
|
|
118
|
+
system: "E",
|
|
119
|
+
prn: `E${two(svid)}`,
|
|
120
|
+
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK,
|
|
121
|
+
tocDate,
|
|
122
|
+
af0,
|
|
123
|
+
af1,
|
|
124
|
+
af2,
|
|
125
|
+
iode: iodNav1,
|
|
126
|
+
crs,
|
|
127
|
+
deltaN,
|
|
128
|
+
m0,
|
|
129
|
+
cuc,
|
|
130
|
+
e,
|
|
131
|
+
cus,
|
|
132
|
+
sqrtA,
|
|
133
|
+
toe: toes,
|
|
134
|
+
cic,
|
|
135
|
+
omega0,
|
|
136
|
+
cis,
|
|
137
|
+
i0,
|
|
138
|
+
crc,
|
|
139
|
+
omega,
|
|
140
|
+
omegaDot,
|
|
141
|
+
idot,
|
|
142
|
+
week,
|
|
143
|
+
svHealth: e5bHs << 7 | e5bDvs << 6 | e1bHs << 1 | e1bDvs,
|
|
144
|
+
tgd: bgdE5a
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function decodeGalFnavPages(pages) {
|
|
148
|
+
if (pages.length < 124) return null;
|
|
149
|
+
const b = pages;
|
|
150
|
+
let i = 0;
|
|
151
|
+
const type1 = getBitU(b, i, 6);
|
|
152
|
+
i += 6;
|
|
153
|
+
const svid = getBitU(b, i, 6);
|
|
154
|
+
i += 6;
|
|
155
|
+
const iodNav1 = getBitU(b, i, 10);
|
|
156
|
+
i += 10;
|
|
157
|
+
const tocs = getBitU(b, i, 14) * 60;
|
|
158
|
+
i += 14;
|
|
159
|
+
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
160
|
+
i += 31;
|
|
161
|
+
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
162
|
+
i += 21;
|
|
163
|
+
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
164
|
+
i += 6;
|
|
165
|
+
i += 8 + 11 + 11 + 14 + 5;
|
|
166
|
+
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
167
|
+
i += 10;
|
|
168
|
+
const e5aHs = getBitU(b, i, 2);
|
|
169
|
+
i += 2;
|
|
170
|
+
const gstWeek = getBitU(b, i, 12);
|
|
171
|
+
i += 12;
|
|
172
|
+
const tow = getBitU(b, i, 20);
|
|
173
|
+
i += 20;
|
|
174
|
+
const e5aDvs = getBitU(b, i, 1);
|
|
175
|
+
i = 31 * 8;
|
|
176
|
+
const type2 = getBitU(b, i, 6);
|
|
177
|
+
i += 6;
|
|
178
|
+
const iodNav2 = getBitU(b, i, 10);
|
|
179
|
+
i += 10;
|
|
180
|
+
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
181
|
+
i += 32;
|
|
182
|
+
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
183
|
+
i += 24;
|
|
184
|
+
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
185
|
+
i += 32;
|
|
186
|
+
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
187
|
+
i += 32;
|
|
188
|
+
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
189
|
+
i += 32;
|
|
190
|
+
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
191
|
+
i = 62 * 8;
|
|
192
|
+
const type3 = getBitU(b, i, 6);
|
|
193
|
+
i += 6;
|
|
194
|
+
const iodNav3 = getBitU(b, i, 10);
|
|
195
|
+
i += 10;
|
|
196
|
+
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
197
|
+
i += 32;
|
|
198
|
+
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
199
|
+
i += 32;
|
|
200
|
+
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
201
|
+
i += 16;
|
|
202
|
+
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
203
|
+
i += 16;
|
|
204
|
+
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
205
|
+
i += 16;
|
|
206
|
+
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
207
|
+
i += 16;
|
|
208
|
+
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
209
|
+
i += 16;
|
|
210
|
+
const toes = getBitU(b, i, 14) * 60;
|
|
211
|
+
i = 93 * 8;
|
|
212
|
+
const type4 = getBitU(b, i, 6);
|
|
213
|
+
i += 6;
|
|
214
|
+
const iodNav4 = getBitU(b, i, 10);
|
|
215
|
+
i += 10;
|
|
216
|
+
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
217
|
+
i += 16;
|
|
218
|
+
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
219
|
+
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4) return null;
|
|
220
|
+
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
221
|
+
return null;
|
|
222
|
+
if (svid < 1 || svid > 36) return null;
|
|
223
|
+
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
224
|
+
const tocDate = gpsDate(week, tocs);
|
|
225
|
+
return {
|
|
226
|
+
system: "E",
|
|
227
|
+
prn: `E${two(svid)}`,
|
|
228
|
+
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK,
|
|
229
|
+
tocDate,
|
|
230
|
+
af0,
|
|
231
|
+
af1,
|
|
232
|
+
af2,
|
|
233
|
+
iode: iodNav1,
|
|
234
|
+
crs,
|
|
235
|
+
deltaN,
|
|
236
|
+
m0,
|
|
237
|
+
cuc,
|
|
238
|
+
e,
|
|
239
|
+
cus,
|
|
240
|
+
sqrtA,
|
|
241
|
+
toe: toes,
|
|
242
|
+
cic,
|
|
243
|
+
omega0,
|
|
244
|
+
cis,
|
|
245
|
+
i0,
|
|
246
|
+
crc,
|
|
247
|
+
omega,
|
|
248
|
+
omegaDot,
|
|
249
|
+
idot,
|
|
250
|
+
week,
|
|
251
|
+
svHealth: e5aHs << 4 | e5aDvs << 3,
|
|
252
|
+
tgd: bgdE5a
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var dedupKey = (eph) => `${eph.iode}:${eph.toe}:${eph.tocDate.getTime()}`;
|
|
256
|
+
var GalInavAssembler = class {
|
|
257
|
+
sats = /* @__PURE__ */ new Map();
|
|
258
|
+
/**
|
|
259
|
+
* Push one I/NAV page pair for satellite `prn` (1-36): the 234-bit
|
|
260
|
+
* even+odd concatenation, even part first with its 6 tail bits
|
|
261
|
+
* removed, bit 0 = the even part's Even/Odd bit (≥ 17 bytes).
|
|
262
|
+
* Returns the newly completed ephemeris, or null. Pages that are
|
|
263
|
+
* not an even/odd nominal pair, alert pages and word types outside
|
|
264
|
+
* 1-5 are ignored.
|
|
265
|
+
*/
|
|
266
|
+
push(prn, page) {
|
|
267
|
+
if (prn < 1 || prn > 36 || page.length < 17) return null;
|
|
268
|
+
if (getBitU(page, 0, 1) !== 0 || getBitU(page, 114, 1) !== 1) return null;
|
|
269
|
+
if (getBitU(page, 1, 1) === 1 || getBitU(page, 115, 1) === 1) return null;
|
|
270
|
+
const type = getBitU(page, 2, 6);
|
|
271
|
+
if (type < 1 || type > 5) return null;
|
|
272
|
+
let sat = this.sats.get(prn);
|
|
273
|
+
if (!sat) {
|
|
274
|
+
sat = { words: new Uint8Array(96) };
|
|
275
|
+
this.sats.set(prn, sat);
|
|
276
|
+
}
|
|
277
|
+
for (let k = 0; k < 14; k++)
|
|
278
|
+
sat.words[type * 16 + k] = getBitU(page, 2 + 8 * k, 8);
|
|
279
|
+
sat.words[type * 16 + 14] = getBitU(page, 116, 8);
|
|
280
|
+
sat.words[type * 16 + 15] = getBitU(page, 124, 8);
|
|
281
|
+
if (type !== 5) return null;
|
|
282
|
+
const eph = decodeGalInavWords(sat.words);
|
|
283
|
+
if (!eph || eph.prn !== `E${two(prn)}`) return null;
|
|
284
|
+
const key = dedupKey(eph);
|
|
285
|
+
if (key === sat.lastKey) return null;
|
|
286
|
+
sat.lastKey = key;
|
|
287
|
+
return eph;
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
var GalFnavAssembler = class {
|
|
291
|
+
sats = /* @__PURE__ */ new Map();
|
|
292
|
+
/**
|
|
293
|
+
* Push one F/NAV page for satellite `prn` (1-36): 244 bits with the
|
|
294
|
+
* sync field stripped, bit 0 = first page-type bit (≥ 31 bytes).
|
|
295
|
+
* Returns the newly completed ephemeris, or null. Dummy pages
|
|
296
|
+
* (type 63) and page types outside 1-4 are ignored.
|
|
297
|
+
*/
|
|
298
|
+
push(prn, page) {
|
|
299
|
+
if (prn < 1 || prn > 36 || page.length < 31) return null;
|
|
300
|
+
const type = getBitU(page, 0, 6);
|
|
301
|
+
if (type < 1 || type > 4) return null;
|
|
302
|
+
let sat = this.sats.get(prn);
|
|
303
|
+
if (!sat) {
|
|
304
|
+
sat = { words: new Uint8Array(124) };
|
|
305
|
+
this.sats.set(prn, sat);
|
|
306
|
+
}
|
|
307
|
+
sat.words.set(page.subarray(0, 31), (type - 1) * 31);
|
|
308
|
+
if (type !== 4) return null;
|
|
309
|
+
const eph = decodeGalFnavPages(sat.words);
|
|
310
|
+
if (!eph || eph.prn !== `E${two(prn)}`) return null;
|
|
311
|
+
const key = dedupKey(eph);
|
|
312
|
+
if (key === sat.lastKey) return null;
|
|
313
|
+
sat.lastKey = key;
|
|
314
|
+
return eph;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export {
|
|
319
|
+
galInavPageCrcOk,
|
|
320
|
+
galFnavPageCrcOk,
|
|
321
|
+
GalInavAssembler,
|
|
322
|
+
GalFnavAssembler
|
|
323
|
+
};
|