gnss-js 1.64.0 → 1.66.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.
@@ -6,7 +6,7 @@ import {
6
6
  computeSatPosition,
7
7
  ecefToAzEl,
8
8
  selectEphemeris
9
- } from "./chunk-MHGNKSSH.js";
9
+ } from "./chunk-JYWYQ7DW.js";
10
10
  import {
11
11
  ecefToGeodetic,
12
12
  getAer,
@@ -5,7 +5,7 @@ import {
5
5
  bdsSubframeParityOk,
6
6
  galInavPageCrcOk,
7
7
  testGloString
8
- } from "./chunk-FA2UTLEQ.js";
8
+ } from "./chunk-3KSDL3CO.js";
9
9
  import {
10
10
  decodeSbasGeoNav,
11
11
  sbasCrcOk
@@ -1531,6 +1531,30 @@ function isSsrMessage(messageType) {
1531
1531
  return messageType in SSR_KIND;
1532
1532
  }
1533
1533
 
1534
+ // src/rtcm3/system-params.ts
1535
+ function decodeSystemParams(frame) {
1536
+ if (frame.messageType !== 1013) return null;
1537
+ const r = new BitReader(frame.payload);
1538
+ r.readU(12);
1539
+ const referenceStationId = r.readU(12);
1540
+ const mjd = r.readU(16);
1541
+ const secondsOfDay = r.readU(17);
1542
+ const nm = r.readU(5);
1543
+ const leapSeconds = r.readU(8);
1544
+ const messages = [];
1545
+ for (let i = 0; i < nm; i++) {
1546
+ messages.push({
1547
+ messageId: r.readU(12),
1548
+ // DF055
1549
+ sync: r.readU(1) === 1,
1550
+ // DF056
1551
+ intervalS: r.readU(16) * 0.1
1552
+ // DF057 (0.1 s)
1553
+ });
1554
+ }
1555
+ return { referenceStationId, mjd, secondsOfDay, leapSeconds, messages };
1556
+ }
1557
+
1534
1558
  // src/rtcm3/station.ts
1535
1559
  function createStationMeta() {
1536
1560
  return {
@@ -1544,7 +1568,8 @@ function createStationMeta() {
1544
1568
  receiverType: null,
1545
1569
  receiverFirmware: null,
1546
1570
  receiverSerial: null,
1547
- description: null
1571
+ description: null,
1572
+ physicalRefStationId: null
1548
1573
  };
1549
1574
  }
1550
1575
  function decodeStationARP(payload, msgType, meta) {
@@ -1567,6 +1592,18 @@ function decodeStationARP(payload, msgType, meta) {
1567
1592
  meta.antennaHeight = r.readU(16) * 1e-4;
1568
1593
  }
1569
1594
  }
1595
+ function decodeStation1032(payload, meta) {
1596
+ if (payload.length < 19) return;
1597
+ const r = new BitReader(payload);
1598
+ r.skip(12);
1599
+ meta.stationId = r.readU(12);
1600
+ meta.physicalRefStationId = r.readU(12);
1601
+ meta.itrf = r.readU(6);
1602
+ const x = r.readS(38) * 1e-4;
1603
+ const y = r.readS(38) * 1e-4;
1604
+ const z = r.readS(38) * 1e-4;
1605
+ if (x !== 0 || y !== 0 || z !== 0) meta.position = [x, y, z];
1606
+ }
1570
1607
  function decodeAntennaDescriptor(payload, msgType, meta) {
1571
1608
  if (payload.length < 5) return;
1572
1609
  const r = new BitReader(payload);
@@ -1647,6 +1684,9 @@ function updateStationMeta(meta, frame) {
1647
1684
  case 1006:
1648
1685
  decodeStationARP(frame.payload, frame.messageType, meta);
1649
1686
  return true;
1687
+ case 1032:
1688
+ decodeStation1032(frame.payload, meta);
1689
+ return true;
1650
1690
  case 1007:
1651
1691
  case 1008:
1652
1692
  decodeAntennaDescriptor(frame.payload, frame.messageType, meta);
@@ -1889,6 +1929,7 @@ export {
1889
1929
  resetGloFreqCache,
1890
1930
  decodeSsr,
1891
1931
  isSsrMessage,
1932
+ decodeSystemParams,
1892
1933
  createStationMeta,
1893
1934
  updateStationMeta,
1894
1935
  RTCM3_MESSAGE_NAMES,
@@ -0,0 +1,269 @@
1
+ // src/rtcm2/index.ts
2
+ var RTCM2_PREAMBLE = 102;
3
+ var HAMMING = [
4
+ 3139384448,
5
+ 1569692224,
6
+ 2932329728,
7
+ 1466164864,
8
+ 1806824256,
9
+ 2340063680
10
+ ];
11
+ function getbitu(buff, pos, len) {
12
+ let v = 0;
13
+ for (let i = pos; i < pos + len; i++)
14
+ v = v * 2 + (buff[i >> 3] >> 7 - (i & 7) & 1);
15
+ return v >>> 0;
16
+ }
17
+ function getbits(buff, pos, len) {
18
+ const v = getbitu(buff, pos, len);
19
+ return v & 1 << len - 1 ? v - 2 ** len : v;
20
+ }
21
+ function decodeWord(w) {
22
+ let word = w >>> 0;
23
+ if (word & 1073741824) word = (word ^ 1073741760) >>> 0;
24
+ let parity = 0;
25
+ for (let i = 0; i < 6; i++) {
26
+ parity <<= 1;
27
+ let x = (word & HAMMING[i]) >>> 6;
28
+ while (x) {
29
+ parity ^= x & 1;
30
+ x >>>= 1;
31
+ }
32
+ }
33
+ if (parity >>> 0 !== (word & 63)) return null;
34
+ return [word >>> 22 & 255, word >>> 14 & 255, word >>> 6 & 255];
35
+ }
36
+ var Rtcm2Decoder = class {
37
+ word = 0;
38
+ nbyte = 0;
39
+ nbit = 0;
40
+ len = 0;
41
+ buff = new Uint8Array(256);
42
+ /** Reset the framer (e.g. after a stream reconnect). */
43
+ reset() {
44
+ this.word = 0;
45
+ this.nbyte = 0;
46
+ this.nbit = 0;
47
+ this.len = 0;
48
+ }
49
+ decode(bytes) {
50
+ const frames = [];
51
+ for (const raw of bytes) {
52
+ if ((raw & 192) !== 64) continue;
53
+ let data = raw;
54
+ for (let i = 0; i < 6; i++, data >>= 1) {
55
+ this.word = (this.word << 1 | data & 1) >>> 0;
56
+ if (this.nbyte === 0) {
57
+ let preamb = this.word >>> 22 & 255;
58
+ if (this.word & 1073741824) preamb ^= 255;
59
+ if (preamb !== RTCM2_PREAMBLE) continue;
60
+ const d2 = decodeWord(this.word);
61
+ if (!d2) continue;
62
+ this.buff[0] = d2[0];
63
+ this.buff[1] = d2[1];
64
+ this.buff[2] = d2[2];
65
+ this.nbyte = 3;
66
+ this.nbit = 0;
67
+ continue;
68
+ }
69
+ if (++this.nbit < 30) continue;
70
+ this.nbit = 0;
71
+ const d = decodeWord(this.word);
72
+ if (!d) {
73
+ this.nbyte = 0;
74
+ this.word &= 3;
75
+ continue;
76
+ }
77
+ this.buff[this.nbyte] = d[0];
78
+ this.buff[this.nbyte + 1] = d[1];
79
+ this.buff[this.nbyte + 2] = d[2];
80
+ this.nbyte += 3;
81
+ if (this.nbyte === 6) this.len = (this.buff[5] >> 3) * 3 + 6;
82
+ if (this.nbyte < this.len) continue;
83
+ frames.push(this.readHeader(this.buff.slice(0, this.len)));
84
+ this.nbyte = 0;
85
+ this.word &= 3;
86
+ }
87
+ }
88
+ return frames;
89
+ }
90
+ readHeader(payload) {
91
+ return {
92
+ messageType: getbitu(payload, 8, 6),
93
+ stationId: getbitu(payload, 14, 10),
94
+ zcountSec: getbitu(payload, 24, 13) * 0.6,
95
+ sequenceNo: getbitu(payload, 37, 3),
96
+ lengthWords: payload[5] >> 3,
97
+ health: getbitu(payload, 45, 3),
98
+ payload
99
+ };
100
+ }
101
+ };
102
+ function rtcm2Station(frame) {
103
+ const p = frame.payload;
104
+ const nbit = frame.lengthWords * 24;
105
+ if (frame.messageType === 3) {
106
+ if (nbit < 96) return null;
107
+ return {
108
+ position: [
109
+ getbits(p, 48, 32) * 0.01,
110
+ getbits(p, 80, 32) * 0.01,
111
+ getbits(p, 112, 32) * 0.01
112
+ ]
113
+ };
114
+ }
115
+ if (frame.messageType === 22) {
116
+ if (nbit < 24) return null;
117
+ const l1 = [
118
+ getbits(p, 48, 8) / 25600,
119
+ getbits(p, 56, 8) / 25600,
120
+ getbits(p, 64, 8) / 25600
121
+ ];
122
+ let height;
123
+ if (nbit >= 48) {
124
+ const noh = getbits(p, 48 + 24 + 5, 1);
125
+ height = noh ? 0 : getbitu(p, 48 + 24 + 6, 18) / 25600;
126
+ }
127
+ return { l1Offset: l1, height };
128
+ }
129
+ return null;
130
+ }
131
+ function rtcm2Observation(frame) {
132
+ const t = frame.messageType;
133
+ if (t !== 18 && t !== 19) return null;
134
+ const p = frame.payload;
135
+ const nbit = frame.lengthWords * 24 + 48;
136
+ let i = 48;
137
+ if (i + 24 > nbit) return null;
138
+ const fRaw = getbitu(p, i, 2);
139
+ i += 4;
140
+ const microSec = getbitu(p, i, 20);
141
+ i += 20;
142
+ if (fRaw & 1) return null;
143
+ const freq = fRaw >> 1;
144
+ let sync = false;
145
+ const records = [];
146
+ while (i + 48 <= nbit) {
147
+ sync = getbitu(p, i, 1) === 1;
148
+ i += 1;
149
+ const code = getbitu(p, i, 1);
150
+ i += 1;
151
+ const sys = getbitu(p, i, 1);
152
+ i += 1;
153
+ let prn = getbitu(p, i, 5);
154
+ i += 5;
155
+ let loss;
156
+ if (t === 18) {
157
+ i += 3;
158
+ loss = getbitu(p, i, 5);
159
+ i += 5;
160
+ } else {
161
+ i += 8;
162
+ }
163
+ const val = t === 18 ? getbits(p, i, 32) : getbitu(p, i, 32);
164
+ i += 32;
165
+ if (prn === 0) prn = 32;
166
+ const system = sys ? "R" : "G";
167
+ const rec = {
168
+ prn: `${system}${String(prn).padStart(2, "0")}`,
169
+ system,
170
+ freq,
171
+ code: code ? "P" : "C/A",
172
+ lossOfLock: loss
173
+ };
174
+ if (t === 18)
175
+ rec.phaseCycles = -val / 256;
176
+ else rec.pseudorangeM = val * 0.02;
177
+ records.push(rec);
178
+ }
179
+ return { freq, sync, microSec, records };
180
+ }
181
+ function rtcm2Dgps(frame) {
182
+ const t = frame.messageType;
183
+ if (t !== 1 && t !== 9 && t !== 31) return null;
184
+ const system = t === 31 ? "R" : "G";
185
+ const p = frame.payload;
186
+ const nbit = frame.lengthWords * 24 + 48;
187
+ let i = 48;
188
+ const corrections = [];
189
+ while (i + 40 <= nbit) {
190
+ const fact = getbitu(p, i, 1);
191
+ i += 1;
192
+ const udre = getbitu(p, i, 2);
193
+ i += 2;
194
+ let prn = getbitu(p, i, 5);
195
+ i += 5;
196
+ const prc = getbits(p, i, 16);
197
+ i += 16;
198
+ const rrc = getbits(p, i, 8);
199
+ i += 8;
200
+ const iod = getbits(p, i, 8);
201
+ i += 8;
202
+ if (prn === 0) prn = 32;
203
+ corrections.push({
204
+ prn: `${system}${String(prn).padStart(2, "0")}`,
205
+ prc: prc * (fact ? 0.32 : 0.02),
206
+ rrc: rrc * (fact ? 0.032 : 2e-3),
207
+ iod,
208
+ udre
209
+ });
210
+ }
211
+ return { system, corrections };
212
+ }
213
+ function rtcm2Time(frame) {
214
+ if (frame.messageType !== 14) return null;
215
+ const p = frame.payload;
216
+ if (frame.lengthWords * 24 < 24) return null;
217
+ return {
218
+ zcountSec: getbitu(p, 24, 13) * 0.6,
219
+ week: getbitu(p, 48, 10),
220
+ hour: getbitu(p, 58, 8),
221
+ leapSeconds: getbitu(p, 66, 6)
222
+ };
223
+ }
224
+ function rtcm2Text(frame) {
225
+ if (frame.messageType !== 16) return null;
226
+ const p = frame.payload;
227
+ const nbit = frame.lengthWords * 24 + 48;
228
+ let s = "";
229
+ for (let i = 48; i + 8 <= nbit; i += 8) {
230
+ const c = getbitu(p, i, 8);
231
+ if (c === 0) break;
232
+ s += String.fromCharCode(c);
233
+ }
234
+ return s;
235
+ }
236
+ var RTCM2_MESSAGE_NAMES = {
237
+ 1: "GPS differential corrections",
238
+ 3: "Reference station parameters (ARP)",
239
+ 9: "GPS partial correction set",
240
+ 14: "GPS time of week",
241
+ 16: "GPS special message (text)",
242
+ 17: "GPS ephemerides",
243
+ 18: "RTK uncorrected carrier phase",
244
+ 19: "RTK uncorrected pseudorange",
245
+ 22: "Extended reference station parameters",
246
+ 23: "Antenna type definition",
247
+ 24: "Antenna reference point (ARP)",
248
+ 31: "GLONASS differential corrections",
249
+ 32: "GLONASS reference station parameters",
250
+ 34: "GLONASS partial correction set",
251
+ 36: "GLONASS special message"
252
+ };
253
+ function looksLikeRtcm2(bytes) {
254
+ const n = Math.min(bytes.length, 4096);
255
+ if (n < 12) return false;
256
+ for (let i = 0; i < n; i++) if ((bytes[i] & 192) !== 64) return false;
257
+ return new Rtcm2Decoder().decode(bytes.subarray(0, n)).length >= 2;
258
+ }
259
+
260
+ export {
261
+ Rtcm2Decoder,
262
+ rtcm2Station,
263
+ rtcm2Observation,
264
+ rtcm2Dgps,
265
+ rtcm2Time,
266
+ rtcm2Text,
267
+ RTCM2_MESSAGE_NAMES,
268
+ looksLikeRtcm2
269
+ };
@@ -7,11 +7,14 @@ import {
7
7
  galFnavPageCrcOk,
8
8
  galInavPageCrcOk,
9
9
  testGloString
10
- } from "./chunk-FA2UTLEQ.js";
10
+ } from "./chunk-3KSDL3CO.js";
11
11
  import {
12
12
  decodeSbasGeoNav,
13
13
  sbasCrcOk
14
14
  } from "./chunk-WQX354KD.js";
15
+ import {
16
+ getGpsLeap
17
+ } from "./chunk-HVXYFUCB.js";
15
18
  import {
16
19
  geodeticToEcef
17
20
  } from "./chunk-37QNKGTC.js";
@@ -26,9 +29,6 @@ import {
26
29
  getBitU,
27
30
  setBitU
28
31
  } from "./chunk-V2D5KUKH.js";
29
- import {
30
- getGpsLeap
31
- } from "./chunk-HVXYFUCB.js";
32
32
 
33
33
  // src/sbf/frame.ts
34
34
  var CRC_TABLE = (() => {
package/dist/constants.js CHANGED
@@ -1,10 +1,4 @@
1
1
  import "./chunk-5S5MONFK.js";
2
- import {
3
- WGS84_ECCENTRICITY_SQUARED,
4
- WGS84_FLATTENING,
5
- WGS84_SEMI_MAJOR_AXIS,
6
- WGS84_SEMI_MINOR_AXIS
7
- } from "./chunk-6FAL6P4G.js";
8
2
  import {
9
3
  DAYS_MJD2000_MJD,
10
4
  DAYS_MJD_JULIAN,
@@ -30,6 +24,12 @@ import {
30
24
  START_TAI_TIME,
31
25
  START_UNIX_TIME
32
26
  } from "./chunk-LEEU5OIO.js";
27
+ import {
28
+ WGS84_ECCENTRICITY_SQUARED,
29
+ WGS84_FLATTENING,
30
+ WGS84_SEMI_MAJOR_AXIS,
31
+ WGS84_SEMI_MINOR_AXIS
32
+ } from "./chunk-6FAL6P4G.js";
33
33
  import {
34
34
  ARC_GAP_FACTOR,
35
35
  BAND_LABELS,