gnss-js 1.21.0 → 1.23.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/chunk-CUWF56ST.js +966 -0
- package/dist/{chunk-DLXTTHRK.js → chunk-MCAVU3XL.js} +118 -9
- package/dist/{chunk-JNFV5BYB.js → chunk-MHGNKSSH.js} +2 -3
- package/dist/{chunk-K3V3NHWL.js → chunk-PZNVFCKJ.js} +25 -766
- package/dist/chunk-VTX3VCL4.js +769 -0
- package/dist/index.cjs +1906 -1099
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -5
- package/dist/orbit.cjs +2 -3
- package/dist/orbit.js +1 -1
- package/dist/positioning.cjs +734 -9
- package/dist/positioning.d.cts +238 -1
- package/dist/positioning.d.ts +238 -1
- package/dist/positioning.js +10 -4
- package/dist/sbf.js +2 -1
- package/dist/ubx.cjs +809 -10
- package/dist/ubx.d.cts +111 -1
- package/dist/ubx.d.ts +111 -1
- package/dist/ubx.js +6 -1
- package/package.json +1 -1
- package/dist/chunk-B5LU4746.js +0 -262
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GPS_PI,
|
|
3
|
+
crc24q,
|
|
4
|
+
getBitS,
|
|
5
|
+
getBitU
|
|
6
|
+
} from "./chunk-WZDFZ76K.js";
|
|
7
|
+
import {
|
|
8
|
+
getUtcDate
|
|
9
|
+
} from "./chunk-HVXYFUCB.js";
|
|
10
|
+
|
|
11
|
+
// src/navbits/bds.ts
|
|
12
|
+
var BDT_EPOCH_MS = Date.UTC(2006, 0, 1);
|
|
13
|
+
var SEC_PER_WEEK = 7 * 86400;
|
|
14
|
+
var MS_PER_WEEK = SEC_PER_WEEK * 1e3;
|
|
15
|
+
var HALF_WEEK = 302400;
|
|
16
|
+
var sowOf = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK;
|
|
17
|
+
var BDS_SUBFRAME_BYTES = 38;
|
|
18
|
+
function getBitU2(b, p1, l1, p2, l2) {
|
|
19
|
+
return getBitU(b, p1, l1) * 2 ** l2 + getBitU(b, p2, l2);
|
|
20
|
+
}
|
|
21
|
+
function getBitS2(b, p1, l1, p2, l2) {
|
|
22
|
+
return getBitS(b, p1, l1) * 2 ** l2 + getBitU(b, p2, l2);
|
|
23
|
+
}
|
|
24
|
+
function getBitU3(b, p1, l1, p2, l2, p3, l3) {
|
|
25
|
+
return getBitU(b, p1, l1) * 2 ** (l2 + l3) + getBitU(b, p2, l2) * 2 ** l3 + getBitU(b, p3, l3);
|
|
26
|
+
}
|
|
27
|
+
function getBitS3(b, p1, l1, p2, l2, p3, l3) {
|
|
28
|
+
return getBitS(b, p1, l1) * 2 ** (l2 + l3) + getBitU(b, p2, l2) * 2 ** l3 + getBitU(b, p3, l3);
|
|
29
|
+
}
|
|
30
|
+
var mergeS = (hi, lo, n) => hi * 2 ** n + lo;
|
|
31
|
+
function bchOk(cw) {
|
|
32
|
+
for (let i = 14; i >= 4; i--) {
|
|
33
|
+
if (cw & 1 << i) cw ^= 19 << i - 4;
|
|
34
|
+
}
|
|
35
|
+
return cw === 0;
|
|
36
|
+
}
|
|
37
|
+
function bdsSubframeParityOk(subframe) {
|
|
38
|
+
if (subframe.length < BDS_SUBFRAME_BYTES) return false;
|
|
39
|
+
if (!bchOk(getBitU(subframe, 15, 15))) return false;
|
|
40
|
+
for (let w = 1; w < 10; w++) {
|
|
41
|
+
const base = 30 * w;
|
|
42
|
+
const cw1 = getBitU(subframe, base, 11) * 16 + getBitU(subframe, base + 22, 4);
|
|
43
|
+
const cw2 = getBitU(subframe, base + 11, 11) * 16 + getBitU(subframe, base + 26, 4);
|
|
44
|
+
if (!bchOk(cw1) || !bchOk(cw2)) return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
function buildBdsEphemeris(prn, f) {
|
|
49
|
+
let week = f.week;
|
|
50
|
+
if (f.toes < f.sow - HALF_WEEK) week++;
|
|
51
|
+
else if (f.toes > f.sow + HALF_WEEK) week--;
|
|
52
|
+
const tocDate = new Date(BDT_EPOCH_MS + week * MS_PER_WEEK + f.tocSec * 1e3);
|
|
53
|
+
return {
|
|
54
|
+
system: "C",
|
|
55
|
+
prn,
|
|
56
|
+
toc: sowOf(tocDate.getTime()),
|
|
57
|
+
tocDate,
|
|
58
|
+
af0: f.af0,
|
|
59
|
+
af1: f.af1,
|
|
60
|
+
af2: f.af2,
|
|
61
|
+
// AODE is not in the ephemeris subframes; RTKLIB derives the RINEX
|
|
62
|
+
// IODE/AODE slot from toc per the BDS ICD update schedule.
|
|
63
|
+
iode: Math.floor(f.tocSec / 720) % 240,
|
|
64
|
+
crs: f.crs,
|
|
65
|
+
deltaN: f.deltaN,
|
|
66
|
+
m0: f.m0,
|
|
67
|
+
cuc: f.cuc,
|
|
68
|
+
e: f.e,
|
|
69
|
+
cus: f.cus,
|
|
70
|
+
sqrtA: f.sqrtA,
|
|
71
|
+
toe: f.toes,
|
|
72
|
+
cic: f.cic,
|
|
73
|
+
omega0: f.omega0,
|
|
74
|
+
cis: f.cis,
|
|
75
|
+
i0: f.i0,
|
|
76
|
+
crc: f.crc,
|
|
77
|
+
omega: f.omega,
|
|
78
|
+
omegaDot: f.omegaDot,
|
|
79
|
+
idot: f.idot,
|
|
80
|
+
week,
|
|
81
|
+
// RINEX BDS week field is the BDT week of toe
|
|
82
|
+
svHealth: f.svh,
|
|
83
|
+
// SatH1
|
|
84
|
+
tgd: f.tgd1
|
|
85
|
+
// TGD1 (B1) — RINEX slot
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function decodeBdsD1Frame(subframes, opts = {}) {
|
|
89
|
+
if (subframes.length < 3 * BDS_SUBFRAME_BYTES) return null;
|
|
90
|
+
const b = subframes;
|
|
91
|
+
let i = 8 * 38 * 0;
|
|
92
|
+
const frn1 = getBitU(b, i + 15, 3);
|
|
93
|
+
const sow1 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
94
|
+
const svh = getBitU(b, i + 42, 1);
|
|
95
|
+
const week = getBitU(b, i + 60, 13);
|
|
96
|
+
const tocSec = getBitU2(b, i + 73, 9, i + 90, 8) * 8;
|
|
97
|
+
const tgd1 = getBitS(b, i + 98, 10) * 0.1 * 1e-9;
|
|
98
|
+
const af2 = getBitS(b, i + 214, 11) * 2 ** -66;
|
|
99
|
+
const af0 = getBitS2(b, i + 225, 7, i + 240, 17) * 2 ** -33;
|
|
100
|
+
const af1 = getBitS2(b, i + 257, 5, i + 270, 17) * 2 ** -50;
|
|
101
|
+
i = 8 * 38 * 1;
|
|
102
|
+
const frn2 = getBitU(b, i + 15, 3);
|
|
103
|
+
const sow2 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
104
|
+
const deltaN = getBitS2(b, i + 42, 10, i + 60, 6) * 2 ** -43 * GPS_PI;
|
|
105
|
+
const cuc = getBitS2(b, i + 66, 16, i + 90, 2) * 2 ** -31;
|
|
106
|
+
const m0 = getBitS2(b, i + 92, 20, i + 120, 12) * 2 ** -31 * GPS_PI;
|
|
107
|
+
const e = getBitU2(b, i + 132, 10, i + 150, 22) * 2 ** -33;
|
|
108
|
+
const cus = getBitS(b, i + 180, 18) * 2 ** -31;
|
|
109
|
+
const crc = getBitS2(b, i + 198, 4, i + 210, 14) * 2 ** -6;
|
|
110
|
+
const crs = getBitS2(b, i + 224, 8, i + 240, 10) * 2 ** -6;
|
|
111
|
+
const sqrtA = getBitU2(b, i + 250, 12, i + 270, 20) * 2 ** -19;
|
|
112
|
+
const toe1 = getBitU(b, i + 290, 2);
|
|
113
|
+
i = 8 * 38 * 2;
|
|
114
|
+
const frn3 = getBitU(b, i + 15, 3);
|
|
115
|
+
const sow3 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
116
|
+
const toe2 = getBitU2(b, i + 42, 10, i + 60, 5);
|
|
117
|
+
const i0 = getBitS2(b, i + 65, 17, i + 90, 15) * 2 ** -31 * GPS_PI;
|
|
118
|
+
const cic = getBitS2(b, i + 105, 7, i + 120, 11) * 2 ** -31;
|
|
119
|
+
const omegaDot = getBitS2(b, i + 131, 11, i + 150, 13) * 2 ** -43 * GPS_PI;
|
|
120
|
+
const cis = getBitS2(b, i + 163, 9, i + 180, 9) * 2 ** -31;
|
|
121
|
+
const idot = getBitS2(b, i + 189, 13, i + 210, 1) * 2 ** -43 * GPS_PI;
|
|
122
|
+
const omega0 = getBitS2(b, i + 211, 21, i + 240, 11) * 2 ** -31 * GPS_PI;
|
|
123
|
+
const omega = getBitS2(b, i + 251, 11, i + 270, 21) * 2 ** -31 * GPS_PI;
|
|
124
|
+
const toes = (toe1 * 2 ** 15 + toe2) * 8;
|
|
125
|
+
if (frn1 !== 1 || frn2 !== 2 || frn3 !== 3) return null;
|
|
126
|
+
if (sow2 !== sow1 + 6 || sow3 !== sow2 + 6) return null;
|
|
127
|
+
if (tocSec !== toes) return null;
|
|
128
|
+
return buildBdsEphemeris(opts.prn ?? "C00", {
|
|
129
|
+
week,
|
|
130
|
+
sow: sow1,
|
|
131
|
+
toes,
|
|
132
|
+
tocSec,
|
|
133
|
+
svh,
|
|
134
|
+
tgd1,
|
|
135
|
+
af0,
|
|
136
|
+
af1,
|
|
137
|
+
af2,
|
|
138
|
+
crs,
|
|
139
|
+
deltaN,
|
|
140
|
+
m0,
|
|
141
|
+
cuc,
|
|
142
|
+
e,
|
|
143
|
+
cus,
|
|
144
|
+
sqrtA,
|
|
145
|
+
cic,
|
|
146
|
+
omega0,
|
|
147
|
+
cis,
|
|
148
|
+
i0,
|
|
149
|
+
crc,
|
|
150
|
+
omega,
|
|
151
|
+
omegaDot,
|
|
152
|
+
idot
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function decodeBdsD2Frame(pages, opts = {}) {
|
|
156
|
+
if (pages.length < 10 * BDS_SUBFRAME_BYTES) return null;
|
|
157
|
+
const b = pages;
|
|
158
|
+
let i = 8 * 38 * 0;
|
|
159
|
+
const pgn1 = getBitU(b, i + 42, 4);
|
|
160
|
+
const sow1 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
161
|
+
const svh = getBitU(b, i + 46, 1);
|
|
162
|
+
const week = getBitU(b, i + 64, 13);
|
|
163
|
+
const tocSec = getBitU2(b, i + 77, 5, i + 90, 12) * 8;
|
|
164
|
+
const tgd1 = getBitS(b, i + 102, 10) * 0.1 * 1e-9;
|
|
165
|
+
i = 8 * 38 * 2;
|
|
166
|
+
const pgn3 = getBitU(b, i + 42, 4);
|
|
167
|
+
const sow3 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
168
|
+
const af0 = getBitS2(b, i + 100, 12, i + 120, 12) * 2 ** -33;
|
|
169
|
+
const af1p3 = getBitS(b, i + 132, 4);
|
|
170
|
+
i = 8 * 38 * 3;
|
|
171
|
+
const pgn4 = getBitU(b, i + 42, 4);
|
|
172
|
+
const sow4 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
173
|
+
const af1p4 = getBitU2(b, i + 46, 6, i + 60, 12);
|
|
174
|
+
const af2 = getBitS2(b, i + 72, 10, i + 90, 1) * 2 ** -66;
|
|
175
|
+
const deltaN = getBitS(b, i + 96, 16) * 2 ** -43 * GPS_PI;
|
|
176
|
+
const cucp4 = getBitS(b, i + 120, 14);
|
|
177
|
+
i = 8 * 38 * 4;
|
|
178
|
+
const pgn5 = getBitU(b, i + 42, 4);
|
|
179
|
+
const sow5 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
180
|
+
const cucp5 = getBitU(b, i + 46, 4);
|
|
181
|
+
const m0 = getBitS3(b, i + 50, 2, i + 60, 22, i + 90, 8) * 2 ** -31 * GPS_PI;
|
|
182
|
+
const cus = getBitS2(b, i + 98, 14, i + 120, 4) * 2 ** -31;
|
|
183
|
+
const ep5 = getBitS(b, i + 124, 10);
|
|
184
|
+
i = 8 * 38 * 5;
|
|
185
|
+
const pgn6 = getBitU(b, i + 42, 4);
|
|
186
|
+
const sow6 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
187
|
+
const ep6 = getBitU2(b, i + 46, 6, i + 60, 16);
|
|
188
|
+
const sqrtA = getBitU3(b, i + 76, 6, i + 90, 22, i + 120, 4) * 2 ** -19;
|
|
189
|
+
const cicp6 = getBitS(b, i + 124, 10);
|
|
190
|
+
i = 8 * 38 * 6;
|
|
191
|
+
const pgn7 = getBitU(b, i + 42, 4);
|
|
192
|
+
const sow7 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
193
|
+
const cicp7 = getBitU2(b, i + 46, 6, i + 60, 2);
|
|
194
|
+
const cis = getBitS(b, i + 62, 18) * 2 ** -31;
|
|
195
|
+
const toes = getBitU2(b, i + 80, 2, i + 90, 15) * 8;
|
|
196
|
+
const i0p7 = getBitS2(b, i + 105, 7, i + 120, 14);
|
|
197
|
+
i = 8 * 38 * 7;
|
|
198
|
+
const pgn8 = getBitU(b, i + 42, 4);
|
|
199
|
+
const sow8 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
200
|
+
const i0p8 = getBitU2(b, i + 46, 6, i + 60, 5);
|
|
201
|
+
const crc = getBitS2(b, i + 65, 17, i + 90, 1) * 2 ** -6;
|
|
202
|
+
const crs = getBitS(b, i + 91, 18) * 2 ** -6;
|
|
203
|
+
const omegaDotP8 = getBitS2(b, i + 109, 3, i + 120, 16);
|
|
204
|
+
i = 8 * 38 * 8;
|
|
205
|
+
const pgn9 = getBitU(b, i + 42, 4);
|
|
206
|
+
const sow9 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
207
|
+
const omegaDotP9 = getBitU(b, i + 46, 5);
|
|
208
|
+
const omega0 = getBitS3(b, i + 51, 1, i + 60, 22, i + 90, 9) * 2 ** -31 * GPS_PI;
|
|
209
|
+
const omegaP9 = getBitS2(b, i + 99, 13, i + 120, 14);
|
|
210
|
+
i = 8 * 38 * 9;
|
|
211
|
+
const pgn10 = getBitU(b, i + 42, 4);
|
|
212
|
+
const sow10 = getBitU2(b, i + 18, 8, i + 30, 12);
|
|
213
|
+
const omegaP10 = getBitU(b, i + 46, 5);
|
|
214
|
+
const idot = getBitS2(b, i + 51, 1, i + 60, 13) * 2 ** -43 * GPS_PI;
|
|
215
|
+
if (pgn1 !== 1 || pgn3 !== 3 || pgn4 !== 4 || pgn5 !== 5 || pgn6 !== 6 || pgn7 !== 7 || pgn8 !== 8 || pgn9 !== 9 || pgn10 !== 10) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
if (sow3 !== sow1 + 6 || sow4 !== sow3 + 3 || sow5 !== sow4 + 3 || sow6 !== sow5 + 3 || sow7 !== sow6 + 3 || sow8 !== sow7 + 3 || sow9 !== sow8 + 3 || sow10 !== sow9 + 3) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
if (tocSec !== toes) return null;
|
|
222
|
+
return buildBdsEphemeris(opts.prn ?? "C00", {
|
|
223
|
+
week,
|
|
224
|
+
sow: sow1,
|
|
225
|
+
toes,
|
|
226
|
+
tocSec,
|
|
227
|
+
svh,
|
|
228
|
+
tgd1,
|
|
229
|
+
af0,
|
|
230
|
+
af1: mergeS(af1p3, af1p4, 18) * 2 ** -50,
|
|
231
|
+
af2,
|
|
232
|
+
crs,
|
|
233
|
+
deltaN,
|
|
234
|
+
m0,
|
|
235
|
+
cuc: mergeS(cucp4, cucp5, 4) * 2 ** -31,
|
|
236
|
+
e: mergeS(ep5, ep6, 22) * 2 ** -33,
|
|
237
|
+
cus,
|
|
238
|
+
sqrtA,
|
|
239
|
+
cic: mergeS(cicp6, cicp7, 8) * 2 ** -31,
|
|
240
|
+
omega0,
|
|
241
|
+
cis,
|
|
242
|
+
i0: mergeS(i0p7, i0p8, 11) * 2 ** -31 * GPS_PI,
|
|
243
|
+
crc,
|
|
244
|
+
omega: mergeS(omegaP9, omegaP10, 5) * 2 ** -31 * GPS_PI,
|
|
245
|
+
omegaDot: mergeS(omegaDotP8, omegaDotP9, 5) * 2 ** -43 * GPS_PI,
|
|
246
|
+
idot
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function isBdsGeoPrn(prn) {
|
|
250
|
+
return prn < 6 || prn > 58;
|
|
251
|
+
}
|
|
252
|
+
var BdsAssembler = class {
|
|
253
|
+
sats = /* @__PURE__ */ new Map();
|
|
254
|
+
/**
|
|
255
|
+
* Push one 300-bit subframe (38+ bytes, bit 0 = first bit of the
|
|
256
|
+
* preamble) for the satellite `prn` ("C06"). Returns the newly
|
|
257
|
+
* completed ephemeris, or null.
|
|
258
|
+
*/
|
|
259
|
+
push(prn, subframe) {
|
|
260
|
+
if (subframe.length < BDS_SUBFRAME_BYTES) return null;
|
|
261
|
+
const num = parseInt(prn.slice(1), 10);
|
|
262
|
+
if (!Number.isFinite(num) || num < 1 || num > 63) return null;
|
|
263
|
+
const id = getBitU(subframe, 15, 3);
|
|
264
|
+
if (id < 1 || id > 5) return null;
|
|
265
|
+
let sat = this.sats.get(prn);
|
|
266
|
+
if (!sat) {
|
|
267
|
+
sat = { buf: new Uint8Array(10 * BDS_SUBFRAME_BYTES) };
|
|
268
|
+
this.sats.set(prn, sat);
|
|
269
|
+
}
|
|
270
|
+
let eph = null;
|
|
271
|
+
if (!isBdsGeoPrn(num)) {
|
|
272
|
+
sat.buf.set(subframe.subarray(0, BDS_SUBFRAME_BYTES), (id - 1) * 38);
|
|
273
|
+
if (id === 3) eph = decodeBdsD1Frame(sat.buf, { prn });
|
|
274
|
+
} else {
|
|
275
|
+
if (id !== 1) return null;
|
|
276
|
+
const pgn = getBitU(subframe, 42, 4);
|
|
277
|
+
if (pgn < 1 || pgn > 10) return null;
|
|
278
|
+
sat.buf.set(subframe.subarray(0, BDS_SUBFRAME_BYTES), (pgn - 1) * 38);
|
|
279
|
+
if (pgn === 10) eph = decodeBdsD2Frame(sat.buf, { prn });
|
|
280
|
+
}
|
|
281
|
+
if (!eph) return null;
|
|
282
|
+
const key = `${eph.week}:${eph.toe}`;
|
|
283
|
+
if (key === sat.lastKey) return null;
|
|
284
|
+
sat.lastKey = key;
|
|
285
|
+
return eph;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// src/navbits/gal.ts
|
|
290
|
+
var GPS_EPOCH_MS = Date.UTC(1980, 0, 6);
|
|
291
|
+
var SEC_PER_WEEK2 = 7 * 86400;
|
|
292
|
+
var HALF_WEEK2 = 302400;
|
|
293
|
+
var GST_GPS_WEEK_OFFSET = 1024;
|
|
294
|
+
function galInavPageCrcOk(page) {
|
|
295
|
+
if (page.length < 28) return false;
|
|
296
|
+
return crc24q(page, 196) === getBitU(page, 196, 24);
|
|
297
|
+
}
|
|
298
|
+
function galFnavPageCrcOk(page) {
|
|
299
|
+
if (page.length < 30) return false;
|
|
300
|
+
return crc24q(page, 214) === getBitU(page, 214, 24);
|
|
301
|
+
}
|
|
302
|
+
function gpsDate(week, sec) {
|
|
303
|
+
return new Date(GPS_EPOCH_MS + (week * SEC_PER_WEEK2 + sec) * 1e3);
|
|
304
|
+
}
|
|
305
|
+
function weekOfToe(week, tow, toe) {
|
|
306
|
+
if (toe - tow > HALF_WEEK2) return week - 1;
|
|
307
|
+
if (toe - tow < -HALF_WEEK2) return week + 1;
|
|
308
|
+
return week;
|
|
309
|
+
}
|
|
310
|
+
var two = (n) => String(n).padStart(2, "0");
|
|
311
|
+
function decodeGalInavWords(words) {
|
|
312
|
+
if (words.length < 96) return null;
|
|
313
|
+
const b = words;
|
|
314
|
+
let i = 128;
|
|
315
|
+
const type1 = getBitU(b, i, 6);
|
|
316
|
+
i += 6;
|
|
317
|
+
const iodNav1 = getBitU(b, i, 10);
|
|
318
|
+
i += 10;
|
|
319
|
+
const toes = getBitU(b, i, 14) * 60;
|
|
320
|
+
i += 14;
|
|
321
|
+
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
322
|
+
i += 32;
|
|
323
|
+
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
324
|
+
i += 32;
|
|
325
|
+
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
326
|
+
i = 128 * 2;
|
|
327
|
+
const type2 = getBitU(b, i, 6);
|
|
328
|
+
i += 6;
|
|
329
|
+
const iodNav2 = getBitU(b, i, 10);
|
|
330
|
+
i += 10;
|
|
331
|
+
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
332
|
+
i += 32;
|
|
333
|
+
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
334
|
+
i += 32;
|
|
335
|
+
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
336
|
+
i += 32;
|
|
337
|
+
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
338
|
+
i = 128 * 3;
|
|
339
|
+
const type3 = getBitU(b, i, 6);
|
|
340
|
+
i += 6;
|
|
341
|
+
const iodNav3 = getBitU(b, i, 10);
|
|
342
|
+
i += 10;
|
|
343
|
+
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
344
|
+
i += 24;
|
|
345
|
+
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
346
|
+
i += 16;
|
|
347
|
+
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
348
|
+
i += 16;
|
|
349
|
+
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
350
|
+
i += 16;
|
|
351
|
+
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
352
|
+
i += 16;
|
|
353
|
+
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
354
|
+
i = 128 * 4;
|
|
355
|
+
const type4 = getBitU(b, i, 6);
|
|
356
|
+
i += 6;
|
|
357
|
+
const iodNav4 = getBitU(b, i, 10);
|
|
358
|
+
i += 10;
|
|
359
|
+
const svid = getBitU(b, i, 6);
|
|
360
|
+
i += 6;
|
|
361
|
+
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
362
|
+
i += 16;
|
|
363
|
+
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
364
|
+
i += 16;
|
|
365
|
+
const tocs = getBitU(b, i, 14) * 60;
|
|
366
|
+
i += 14;
|
|
367
|
+
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
368
|
+
i += 31;
|
|
369
|
+
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
370
|
+
i += 21;
|
|
371
|
+
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
372
|
+
i = 128 * 5;
|
|
373
|
+
const type5 = getBitU(b, i, 6);
|
|
374
|
+
i += 6 + 11 + 11 + 14 + 5;
|
|
375
|
+
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
376
|
+
i += 10;
|
|
377
|
+
i += 10;
|
|
378
|
+
const e5bHs = getBitU(b, i, 2);
|
|
379
|
+
i += 2;
|
|
380
|
+
const e1bHs = getBitU(b, i, 2);
|
|
381
|
+
i += 2;
|
|
382
|
+
const e5bDvs = getBitU(b, i, 1);
|
|
383
|
+
i += 1;
|
|
384
|
+
const e1bDvs = getBitU(b, i, 1);
|
|
385
|
+
i += 1;
|
|
386
|
+
const gstWeek = getBitU(b, i, 12);
|
|
387
|
+
i += 12;
|
|
388
|
+
const tow = getBitU(b, i, 20);
|
|
389
|
+
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4 || type5 !== 5)
|
|
390
|
+
return null;
|
|
391
|
+
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
392
|
+
return null;
|
|
393
|
+
if (svid < 1 || svid > 36) return null;
|
|
394
|
+
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
395
|
+
const tocDate = gpsDate(week, tocs);
|
|
396
|
+
return {
|
|
397
|
+
system: "E",
|
|
398
|
+
prn: `E${two(svid)}`,
|
|
399
|
+
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK2,
|
|
400
|
+
tocDate,
|
|
401
|
+
af0,
|
|
402
|
+
af1,
|
|
403
|
+
af2,
|
|
404
|
+
iode: iodNav1,
|
|
405
|
+
crs,
|
|
406
|
+
deltaN,
|
|
407
|
+
m0,
|
|
408
|
+
cuc,
|
|
409
|
+
e,
|
|
410
|
+
cus,
|
|
411
|
+
sqrtA,
|
|
412
|
+
toe: toes,
|
|
413
|
+
cic,
|
|
414
|
+
omega0,
|
|
415
|
+
cis,
|
|
416
|
+
i0,
|
|
417
|
+
crc,
|
|
418
|
+
omega,
|
|
419
|
+
omegaDot,
|
|
420
|
+
idot,
|
|
421
|
+
week,
|
|
422
|
+
svHealth: e5bHs << 7 | e5bDvs << 6 | e1bHs << 1 | e1bDvs,
|
|
423
|
+
tgd: bgdE5a
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function decodeGalFnavPages(pages) {
|
|
427
|
+
if (pages.length < 124) return null;
|
|
428
|
+
const b = pages;
|
|
429
|
+
let i = 0;
|
|
430
|
+
const type1 = getBitU(b, i, 6);
|
|
431
|
+
i += 6;
|
|
432
|
+
const svid = getBitU(b, i, 6);
|
|
433
|
+
i += 6;
|
|
434
|
+
const iodNav1 = getBitU(b, i, 10);
|
|
435
|
+
i += 10;
|
|
436
|
+
const tocs = getBitU(b, i, 14) * 60;
|
|
437
|
+
i += 14;
|
|
438
|
+
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
439
|
+
i += 31;
|
|
440
|
+
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
441
|
+
i += 21;
|
|
442
|
+
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
443
|
+
i += 6;
|
|
444
|
+
i += 8 + 11 + 11 + 14 + 5;
|
|
445
|
+
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
446
|
+
i += 10;
|
|
447
|
+
const e5aHs = getBitU(b, i, 2);
|
|
448
|
+
i += 2;
|
|
449
|
+
const gstWeek = getBitU(b, i, 12);
|
|
450
|
+
i += 12;
|
|
451
|
+
const tow = getBitU(b, i, 20);
|
|
452
|
+
i += 20;
|
|
453
|
+
const e5aDvs = getBitU(b, i, 1);
|
|
454
|
+
i = 31 * 8;
|
|
455
|
+
const type2 = getBitU(b, i, 6);
|
|
456
|
+
i += 6;
|
|
457
|
+
const iodNav2 = getBitU(b, i, 10);
|
|
458
|
+
i += 10;
|
|
459
|
+
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
460
|
+
i += 32;
|
|
461
|
+
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
462
|
+
i += 24;
|
|
463
|
+
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
464
|
+
i += 32;
|
|
465
|
+
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
466
|
+
i += 32;
|
|
467
|
+
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
468
|
+
i += 32;
|
|
469
|
+
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
470
|
+
i = 62 * 8;
|
|
471
|
+
const type3 = getBitU(b, i, 6);
|
|
472
|
+
i += 6;
|
|
473
|
+
const iodNav3 = getBitU(b, i, 10);
|
|
474
|
+
i += 10;
|
|
475
|
+
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
476
|
+
i += 32;
|
|
477
|
+
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
478
|
+
i += 32;
|
|
479
|
+
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
480
|
+
i += 16;
|
|
481
|
+
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
482
|
+
i += 16;
|
|
483
|
+
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
484
|
+
i += 16;
|
|
485
|
+
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
486
|
+
i += 16;
|
|
487
|
+
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
488
|
+
i += 16;
|
|
489
|
+
const toes = getBitU(b, i, 14) * 60;
|
|
490
|
+
i = 93 * 8;
|
|
491
|
+
const type4 = getBitU(b, i, 6);
|
|
492
|
+
i += 6;
|
|
493
|
+
const iodNav4 = getBitU(b, i, 10);
|
|
494
|
+
i += 10;
|
|
495
|
+
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
496
|
+
i += 16;
|
|
497
|
+
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
498
|
+
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4) return null;
|
|
499
|
+
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
500
|
+
return null;
|
|
501
|
+
if (svid < 1 || svid > 36) return null;
|
|
502
|
+
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
503
|
+
const tocDate = gpsDate(week, tocs);
|
|
504
|
+
return {
|
|
505
|
+
system: "E",
|
|
506
|
+
prn: `E${two(svid)}`,
|
|
507
|
+
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK2,
|
|
508
|
+
tocDate,
|
|
509
|
+
af0,
|
|
510
|
+
af1,
|
|
511
|
+
af2,
|
|
512
|
+
iode: iodNav1,
|
|
513
|
+
crs,
|
|
514
|
+
deltaN,
|
|
515
|
+
m0,
|
|
516
|
+
cuc,
|
|
517
|
+
e,
|
|
518
|
+
cus,
|
|
519
|
+
sqrtA,
|
|
520
|
+
toe: toes,
|
|
521
|
+
cic,
|
|
522
|
+
omega0,
|
|
523
|
+
cis,
|
|
524
|
+
i0,
|
|
525
|
+
crc,
|
|
526
|
+
omega,
|
|
527
|
+
omegaDot,
|
|
528
|
+
idot,
|
|
529
|
+
week,
|
|
530
|
+
svHealth: e5aHs << 4 | e5aDvs << 3,
|
|
531
|
+
tgd: bgdE5a
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
var dedupKey = (eph) => `${eph.iode}:${eph.toe}:${eph.tocDate.getTime()}`;
|
|
535
|
+
var GalInavAssembler = class {
|
|
536
|
+
sats = /* @__PURE__ */ new Map();
|
|
537
|
+
/**
|
|
538
|
+
* Push one I/NAV page pair for satellite `prn` (1-36): the 234-bit
|
|
539
|
+
* even+odd concatenation, even part first with its 6 tail bits
|
|
540
|
+
* removed, bit 0 = the even part's Even/Odd bit (≥ 17 bytes).
|
|
541
|
+
* Returns the newly completed ephemeris, or null. Pages that are
|
|
542
|
+
* not an even/odd nominal pair, alert pages and word types outside
|
|
543
|
+
* 1-5 are ignored.
|
|
544
|
+
*/
|
|
545
|
+
push(prn, page) {
|
|
546
|
+
if (prn < 1 || prn > 36 || page.length < 17) return null;
|
|
547
|
+
if (getBitU(page, 0, 1) !== 0 || getBitU(page, 114, 1) !== 1) return null;
|
|
548
|
+
if (getBitU(page, 1, 1) === 1 || getBitU(page, 115, 1) === 1) return null;
|
|
549
|
+
const type = getBitU(page, 2, 6);
|
|
550
|
+
if (type < 1 || type > 5) return null;
|
|
551
|
+
let sat = this.sats.get(prn);
|
|
552
|
+
if (!sat) {
|
|
553
|
+
sat = { words: new Uint8Array(96) };
|
|
554
|
+
this.sats.set(prn, sat);
|
|
555
|
+
}
|
|
556
|
+
for (let k = 0; k < 14; k++)
|
|
557
|
+
sat.words[type * 16 + k] = getBitU(page, 2 + 8 * k, 8);
|
|
558
|
+
sat.words[type * 16 + 14] = getBitU(page, 116, 8);
|
|
559
|
+
sat.words[type * 16 + 15] = getBitU(page, 124, 8);
|
|
560
|
+
if (type !== 5) return null;
|
|
561
|
+
const eph = decodeGalInavWords(sat.words);
|
|
562
|
+
if (!eph || eph.prn !== `E${two(prn)}`) return null;
|
|
563
|
+
const key = dedupKey(eph);
|
|
564
|
+
if (key === sat.lastKey) return null;
|
|
565
|
+
sat.lastKey = key;
|
|
566
|
+
return eph;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
var GalFnavAssembler = class {
|
|
570
|
+
sats = /* @__PURE__ */ new Map();
|
|
571
|
+
/**
|
|
572
|
+
* Push one F/NAV page for satellite `prn` (1-36): 244 bits with the
|
|
573
|
+
* sync field stripped, bit 0 = first page-type bit (≥ 31 bytes).
|
|
574
|
+
* Returns the newly completed ephemeris, or null. Dummy pages
|
|
575
|
+
* (type 63) and page types outside 1-4 are ignored.
|
|
576
|
+
*/
|
|
577
|
+
push(prn, page) {
|
|
578
|
+
if (prn < 1 || prn > 36 || page.length < 31) return null;
|
|
579
|
+
const type = getBitU(page, 0, 6);
|
|
580
|
+
if (type < 1 || type > 4) return null;
|
|
581
|
+
let sat = this.sats.get(prn);
|
|
582
|
+
if (!sat) {
|
|
583
|
+
sat = { words: new Uint8Array(124) };
|
|
584
|
+
this.sats.set(prn, sat);
|
|
585
|
+
}
|
|
586
|
+
sat.words.set(page.subarray(0, 31), (type - 1) * 31);
|
|
587
|
+
if (type !== 4) return null;
|
|
588
|
+
const eph = decodeGalFnavPages(sat.words);
|
|
589
|
+
if (!eph || eph.prn !== `E${two(prn)}`) return null;
|
|
590
|
+
const key = dedupKey(eph);
|
|
591
|
+
if (key === sat.lastKey) return null;
|
|
592
|
+
sat.lastKey = key;
|
|
593
|
+
return eph;
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// src/navbits/glo.ts
|
|
598
|
+
var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
|
|
599
|
+
var SEC_PER_WEEK3 = 7 * 86400;
|
|
600
|
+
var SEC_PER_DAY = 86400;
|
|
601
|
+
var GLO_STRING_BYTES = 10;
|
|
602
|
+
function getBitG(b, pos, len) {
|
|
603
|
+
const value = getBitU(b, pos + 1, len - 1);
|
|
604
|
+
return getBitU(b, pos, 1) && value !== 0 ? -value : value;
|
|
605
|
+
}
|
|
606
|
+
var HAMMING_MASKS = [
|
|
607
|
+
[85, 85, 90, 170, 170, 170, 181, 85, 106, 216, 8],
|
|
608
|
+
[102, 102, 108, 204, 204, 204, 217, 153, 179, 104, 16],
|
|
609
|
+
[135, 135, 143, 15, 15, 15, 30, 30, 60, 112, 32],
|
|
610
|
+
[7, 248, 15, 240, 15, 240, 31, 224, 63, 128, 64],
|
|
611
|
+
[248, 0, 15, 255, 240, 0, 31, 255, 192, 0, 128],
|
|
612
|
+
[0, 0, 15, 255, 255, 255, 224, 0, 0, 1, 0],
|
|
613
|
+
[255, 255, 240, 0, 0, 0, 0, 0, 0, 2, 0],
|
|
614
|
+
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248]
|
|
615
|
+
];
|
|
616
|
+
function testGloString(buff) {
|
|
617
|
+
if (buff.length < 11) return false;
|
|
618
|
+
let n = 0;
|
|
619
|
+
let cs = 0;
|
|
620
|
+
for (const mask of HAMMING_MASKS) {
|
|
621
|
+
cs = 0;
|
|
622
|
+
for (let j = 0; j < 11; j++) {
|
|
623
|
+
let x = buff[j] & mask[j];
|
|
624
|
+
x ^= x >> 4;
|
|
625
|
+
x ^= x >> 2;
|
|
626
|
+
x ^= x >> 1;
|
|
627
|
+
cs ^= x & 1;
|
|
628
|
+
}
|
|
629
|
+
if (cs) n++;
|
|
630
|
+
}
|
|
631
|
+
return n === 0 || n === 2 && cs === 1;
|
|
632
|
+
}
|
|
633
|
+
function decodeGloStrings(strings, refDate, opts = {}) {
|
|
634
|
+
if (strings.length < 4 * GLO_STRING_BYTES) return null;
|
|
635
|
+
const b = strings;
|
|
636
|
+
let i = 1;
|
|
637
|
+
const frn1 = getBitU(b, i, 4);
|
|
638
|
+
i += 4 + 2;
|
|
639
|
+
i += 2;
|
|
640
|
+
const tkH = getBitU(b, i, 5);
|
|
641
|
+
i += 5;
|
|
642
|
+
const tkM = getBitU(b, i, 6);
|
|
643
|
+
i += 6;
|
|
644
|
+
const tkS = getBitU(b, i, 1) * 30;
|
|
645
|
+
i += 1;
|
|
646
|
+
const xDot = getBitG(b, i, 24) * 2 ** -20;
|
|
647
|
+
i += 24;
|
|
648
|
+
const xAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
649
|
+
i += 5;
|
|
650
|
+
const x = getBitG(b, i, 27) * 2 ** -11;
|
|
651
|
+
i = 80 + 1;
|
|
652
|
+
const frn2 = getBitU(b, i, 4);
|
|
653
|
+
i += 4;
|
|
654
|
+
const bn = getBitU(b, i, 1);
|
|
655
|
+
i += 1 + 2;
|
|
656
|
+
i += 1;
|
|
657
|
+
const tb = getBitU(b, i, 7);
|
|
658
|
+
i += 7 + 5;
|
|
659
|
+
const yDot = getBitG(b, i, 24) * 2 ** -20;
|
|
660
|
+
i += 24;
|
|
661
|
+
const yAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
662
|
+
i += 5;
|
|
663
|
+
const y = getBitG(b, i, 27) * 2 ** -11;
|
|
664
|
+
i = 160 + 1;
|
|
665
|
+
const frn3 = getBitU(b, i, 4);
|
|
666
|
+
i += 4;
|
|
667
|
+
i += 1;
|
|
668
|
+
const gammaN = getBitG(b, i, 11) * 2 ** -40;
|
|
669
|
+
i += 11 + 1;
|
|
670
|
+
i += 2;
|
|
671
|
+
i += 1;
|
|
672
|
+
const zDot = getBitG(b, i, 24) * 2 ** -20;
|
|
673
|
+
i += 24;
|
|
674
|
+
const zAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
675
|
+
i += 5;
|
|
676
|
+
const z = getBitG(b, i, 27) * 2 ** -11;
|
|
677
|
+
i = 240 + 1;
|
|
678
|
+
const frn4 = getBitU(b, i, 4);
|
|
679
|
+
i += 4;
|
|
680
|
+
const tauN = getBitG(b, i, 22) * 2 ** -30;
|
|
681
|
+
i += 22;
|
|
682
|
+
i += 5;
|
|
683
|
+
i += 5;
|
|
684
|
+
i += 14;
|
|
685
|
+
i += 1;
|
|
686
|
+
i += 4;
|
|
687
|
+
i += 3;
|
|
688
|
+
i += 11;
|
|
689
|
+
const slot = getBitU(b, i, 5);
|
|
690
|
+
if (frn1 !== 1 || frn2 !== 2 || frn3 !== 3 || frn4 !== 4) return null;
|
|
691
|
+
if (slot < 1 || slot > 27) return null;
|
|
692
|
+
const utcSec = (getUtcDate(refDate).getTime() - GPS_EPOCH_MS2) / 1e3;
|
|
693
|
+
const week = Math.floor(utcSec / SEC_PER_WEEK3);
|
|
694
|
+
let tow = utcSec - week * SEC_PER_WEEK3;
|
|
695
|
+
const tod = tow % SEC_PER_DAY;
|
|
696
|
+
tow -= tod;
|
|
697
|
+
let tof = tkH * 3600 + tkM * 60 + tkS - 10800;
|
|
698
|
+
if (tof < tod - 43200) tof += SEC_PER_DAY;
|
|
699
|
+
else if (tof > tod + 43200) tof -= SEC_PER_DAY;
|
|
700
|
+
let toe = tb * 900 - 10800;
|
|
701
|
+
if (toe < tod - 43200) toe += SEC_PER_DAY;
|
|
702
|
+
else if (toe > tod + 43200) toe -= SEC_PER_DAY;
|
|
703
|
+
return {
|
|
704
|
+
system: "R",
|
|
705
|
+
prn: `R${String(slot).padStart(2, "0")}`,
|
|
706
|
+
// RINEX GLONASS epochs are UTC: build the UTC toe Date directly.
|
|
707
|
+
tocDate: new Date(GPS_EPOCH_MS2 + (week * SEC_PER_WEEK3 + tow + toe) * 1e3),
|
|
708
|
+
tauN: -tauN,
|
|
709
|
+
// RINEX stores −τn; the SIS carries τn (ICD sign)
|
|
710
|
+
gammaN,
|
|
711
|
+
// v3 message frame time: seconds of the UTC week (RTKLIB tof).
|
|
712
|
+
messageFrameTime: ((tow + tof) % SEC_PER_WEEK3 + SEC_PER_WEEK3) % SEC_PER_WEEK3,
|
|
713
|
+
x,
|
|
714
|
+
xDot,
|
|
715
|
+
xAcc,
|
|
716
|
+
y,
|
|
717
|
+
yDot,
|
|
718
|
+
yAcc,
|
|
719
|
+
z,
|
|
720
|
+
zDot,
|
|
721
|
+
zAcc,
|
|
722
|
+
// MSB of the 3-bit Bn word — the unhealthy flag RINEX carries
|
|
723
|
+
health: bn,
|
|
724
|
+
freqNum: opts.freqNum ?? 0
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
var GloStringAssembler = class {
|
|
728
|
+
sats = /* @__PURE__ */ new Map();
|
|
729
|
+
/**
|
|
730
|
+
* Push one navigation string (10+ bytes, bit 0 = string bit 85) for
|
|
731
|
+
* the satellite `prn` ("R09"), received at the GPS-scale `time`.
|
|
732
|
+
* Returns the newly completed ephemeris, or null. The decoded
|
|
733
|
+
* string-4 slot number must match `prn`, or nothing is emitted.
|
|
734
|
+
*/
|
|
735
|
+
push(prn, str, time, freqNum = 0) {
|
|
736
|
+
if (str.length < GLO_STRING_BYTES) return null;
|
|
737
|
+
const m = getBitU(str, 1, 4);
|
|
738
|
+
if (m < 1) return null;
|
|
739
|
+
const sec = Math.floor(time.getTime() / 1e3);
|
|
740
|
+
let sat = this.sats.get(prn);
|
|
741
|
+
if (!sat) {
|
|
742
|
+
sat = { buf: new Uint8Array(4 * GLO_STRING_BYTES), batchSec: sec };
|
|
743
|
+
this.sats.set(prn, sat);
|
|
744
|
+
} else if (Math.abs(sec - sat.batchSec) > 30) {
|
|
745
|
+
sat.buf.fill(0);
|
|
746
|
+
sat.batchSec = sec;
|
|
747
|
+
}
|
|
748
|
+
if (m > 4) return null;
|
|
749
|
+
sat.buf.set(str.subarray(0, GLO_STRING_BYTES), (m - 1) * 10);
|
|
750
|
+
if (m !== 4) return null;
|
|
751
|
+
const eph = decodeGloStrings(sat.buf, time, { freqNum });
|
|
752
|
+
if (!eph || eph.prn !== prn) return null;
|
|
753
|
+
const key = `${eph.tocDate.getTime()}:${eph.health}`;
|
|
754
|
+
if (key === sat.lastKey) return null;
|
|
755
|
+
sat.lastKey = key;
|
|
756
|
+
return eph;
|
|
757
|
+
}
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
export {
|
|
761
|
+
bdsSubframeParityOk,
|
|
762
|
+
BdsAssembler,
|
|
763
|
+
galInavPageCrcOk,
|
|
764
|
+
galFnavPageCrcOk,
|
|
765
|
+
GalInavAssembler,
|
|
766
|
+
GalFnavAssembler,
|
|
767
|
+
testGloString,
|
|
768
|
+
GloStringAssembler
|
|
769
|
+
};
|