gnss-js 1.0.0 → 1.0.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.
@@ -21,8 +21,20 @@ var C_LIGHT = 299792458;
21
21
  var FREQ = {
22
22
  G: { "1": 157542e4, "2": 12276e5, "5": 117645e4 },
23
23
  R: { "3": 1202025e3 },
24
- E: { "1": 157542e4, "5": 117645e4, "6": 127875e4, "7": 120714e4, "8": 1191795e3 },
25
- C: { "1": 157542e4, "2": 1561098e3, "5": 117645e4, "6": 126852e4, "7": 120714e4 },
24
+ E: {
25
+ "1": 157542e4,
26
+ "5": 117645e4,
27
+ "6": 127875e4,
28
+ "7": 120714e4,
29
+ "8": 1191795e3
30
+ },
31
+ C: {
32
+ "1": 157542e4,
33
+ "2": 1561098e3,
34
+ "5": 117645e4,
35
+ "6": 126852e4,
36
+ "7": 120714e4
37
+ },
26
38
  J: { "1": 157542e4, "2": 12276e5, "5": 117645e4, "6": 127875e4 },
27
39
  I: { "5": 117645e4, "9": 2492028e3 },
28
40
  S: { "1": 157542e4, "5": 117645e4 }
@@ -37,11 +49,28 @@ var BAND_LABELS = {
37
49
  S: { "1": "L1", "5": "L5" }
38
50
  };
39
51
  var DUAL_FREQ_PAIRS = {
40
- G: [["1", "2"], ["1", "5"]],
41
- R: [["1", "2"], ["1", "3"]],
42
- E: [["1", "5"], ["1", "7"], ["1", "6"]],
43
- C: [["2", "7"], ["2", "6"], ["1", "5"]],
44
- J: [["1", "2"], ["1", "5"]],
52
+ G: [
53
+ ["1", "2"],
54
+ ["1", "5"]
55
+ ],
56
+ R: [
57
+ ["1", "2"],
58
+ ["1", "3"]
59
+ ],
60
+ E: [
61
+ ["1", "5"],
62
+ ["1", "7"],
63
+ ["1", "6"]
64
+ ],
65
+ C: [
66
+ ["2", "7"],
67
+ ["2", "6"],
68
+ ["1", "5"]
69
+ ],
70
+ J: [
71
+ ["1", "2"],
72
+ ["1", "5"]
73
+ ],
45
74
  I: [["5", "9"]],
46
75
  S: [["1", "5"]]
47
76
  };
@@ -63,7 +63,10 @@ function vincenty(lat1, lon1, lat2, lon2) {
63
63
  const cosLat2 = Math.cos(lat2), sinLat2 = Math.sin(lat2);
64
64
  const dLon = lon2 - lon1;
65
65
  sigma = Math.acos(
66
- Math.min(1, Math.max(-1, sinLat1 * sinLat2 + cosLat1 * cosLat2 * Math.cos(dLon)))
66
+ Math.min(
67
+ 1,
68
+ Math.max(-1, sinLat1 * sinLat2 + cosLat1 * cosLat2 * Math.cos(dLon))
69
+ )
67
70
  );
68
71
  const distance2 = WGS84_SEMI_MAJOR_AXIS * sigma;
69
72
  const ib = Math.atan2(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseRinexStream
3
- } from "./chunk-CB6EOOLA.js";
3
+ } from "./chunk-HBLU2EJ4.js";
4
4
  import {
5
5
  ARC_GAP_FACTOR,
6
6
  BAND_LABELS,
@@ -11,7 +11,7 @@ import {
11
11
  buildGloChannelMap,
12
12
  buildObsIndices,
13
13
  getFreq
14
- } from "./chunk-354IRDOG.js";
14
+ } from "./chunk-LWNTWBHB.js";
15
15
 
16
16
  // src/analysis/multipath.ts
17
17
  var MIN_ARC_LENGTH = 10;
@@ -99,8 +99,18 @@ var MultipathAccumulator = class {
99
99
  time: t,
100
100
  mp: arc.rawMp[i] - mean
101
101
  }));
102
- const rms = Math.sqrt(points.reduce((s, p) => s + p.mp * p.mp, 0) / points.length);
103
- this.results.push({ prn, system: sys, band, refBand, label, points, rms });
102
+ const rms = Math.sqrt(
103
+ points.reduce((s, p) => s + p.mp * p.mp, 0) / points.length
104
+ );
105
+ this.results.push({
106
+ prn,
107
+ system: sys,
108
+ band,
109
+ refBand,
110
+ label,
111
+ points,
112
+ rms
113
+ });
104
114
  }
105
115
  state.arc = { times: [], rawMp: [] };
106
116
  }
@@ -254,10 +264,20 @@ var CycleSlipAccumulator = class {
254
264
  const sigKey = `${sys}:${signal}`;
255
265
  this.countEpoch(sigKey);
256
266
  const stddev = mwSmoothStddev(prevSmooth);
257
- const threshold = Math.max(MW_MIN_THRESHOLD, MW_SIGMA_FACTOR * stddev);
267
+ const threshold = Math.max(
268
+ MW_MIN_THRESHOLD,
269
+ MW_SIGMA_FACTOR * stddev
270
+ );
258
271
  const deviation = Math.abs(mw - prevSmooth.mean);
259
272
  if (deviation > threshold) {
260
- this.recordSlip(sigKey, time, prn, signal, deviation, /* @__PURE__ */ new Set([b1, b2]));
273
+ this.recordSlip(
274
+ sigKey,
275
+ time,
276
+ prn,
277
+ signal,
278
+ deviation,
279
+ /* @__PURE__ */ new Set([b1, b2])
280
+ );
261
281
  mwSmooth.set(pairKey, mwSmoothInit(mw));
262
282
  } else {
263
283
  mwSmooth.set(pairKey, mwSmoothUpdate(prevSmooth, mw));
@@ -312,7 +332,13 @@ var CycleSlipAccumulator = class {
312
332
  }
313
333
  }
314
334
  }
315
- this.prev.set(prn, { time, mwSmooth, gf: gfMap, phase: phaseM, code: codeM });
335
+ this.prev.set(prn, {
336
+ time,
337
+ mwSmooth,
338
+ gf: gfMap,
339
+ phase: phaseM,
340
+ code: codeM
341
+ });
316
342
  };
317
343
  finalize() {
318
344
  const satSlipCounts = {};
@@ -320,7 +346,10 @@ var CycleSlipAccumulator = class {
320
346
  satSlipCounts[ev.prn] = (satSlipCounts[ev.prn] ?? 0) + 1;
321
347
  }
322
348
  const signalStats = [];
323
- const allKeys = /* @__PURE__ */ new Set([...this.signalEpochs.keys(), ...this.signalSlips.keys()]);
349
+ const allKeys = /* @__PURE__ */ new Set([
350
+ ...this.signalEpochs.keys(),
351
+ ...this.signalSlips.keys()
352
+ ]);
324
353
  for (const sigKey of allKeys) {
325
354
  const [sys, ...rest] = sigKey.split(":");
326
355
  const signal = rest.join(":");
@@ -39,10 +39,18 @@ var WarningAccumulator = class {
39
39
  );
40
40
  }
41
41
  if (!header.antType) {
42
- this.add("MISSING_ANT_TYPE", "info", "Missing antenna type (ANT # / TYPE)");
42
+ this.add(
43
+ "MISSING_ANT_TYPE",
44
+ "info",
45
+ "Missing antenna type (ANT # / TYPE)"
46
+ );
43
47
  }
44
48
  if (!header.receiverType) {
45
- this.add("MISSING_REC_TYPE", "info", "Missing receiver type (REC # / TYPE / VERS)");
49
+ this.add(
50
+ "MISSING_REC_TYPE",
51
+ "info",
52
+ "Missing receiver type (REC # / TYPE / VERS)"
53
+ );
46
54
  }
47
55
  if (!header.markerName) {
48
56
  this.add("MISSING_MARKER", "info", "Missing marker name (MARKER NAME)");
@@ -51,7 +59,11 @@ var WarningAccumulator = class {
51
59
  this.add("MISSING_INTERVAL", "info", "No observation interval in header");
52
60
  }
53
61
  if (Object.keys(header.obsTypes).length === 0) {
54
- this.add("NO_OBS_TYPES", "error", "No observation types defined in header");
62
+ this.add(
63
+ "NO_OBS_TYPES",
64
+ "error",
65
+ "No observation types defined in header"
66
+ );
55
67
  }
56
68
  }
57
69
  setInterval(intervalMs) {
@@ -118,7 +130,12 @@ var WarningAccumulator = class {
118
130
  };
119
131
  const range = ranges[sys];
120
132
  if (!range) {
121
- this.add("UNKNOWN_SYSTEM", "info", "Unknown satellite system letter", prn);
133
+ this.add(
134
+ "UNKNOWN_SYSTEM",
135
+ "info",
136
+ "Unknown satellite system letter",
137
+ prn
138
+ );
122
139
  } else if (num < range[0] || num > range[1]) {
123
140
  this.add(
124
141
  "PRN_OUT_OF_RANGE",
@@ -208,7 +225,15 @@ var R4_MSG_LINES = {
208
225
  EOP: 3,
209
226
  ION: 3
210
227
  };
211
- var SUPPORTED_EPH_MSGS = /* @__PURE__ */ new Set(["LNAV", "INAV", "FNAV", "D1", "D2", "SBAS", "FDMA"]);
228
+ var SUPPORTED_EPH_MSGS = /* @__PURE__ */ new Set([
229
+ "LNAV",
230
+ "INAV",
231
+ "FNAV",
232
+ "D1",
233
+ "D2",
234
+ "SBAS",
235
+ "FDMA"
236
+ ]);
212
237
  function parseFloat19(s) {
213
238
  return parseFloat(s.trim().replace(/[dD]/g, "E"));
214
239
  }
@@ -415,9 +440,25 @@ function parseNavFile(text) {
415
440
  }
416
441
  if (dataLines2.length === numDataLines2) {
417
442
  if (sys2 === "R" || sys2 === "S") {
418
- ephemerides.push(buildStateVectorEphemeris(sys2, prn2, parsed.date, parsed.values, dataLines2));
443
+ ephemerides.push(
444
+ buildStateVectorEphemeris(
445
+ sys2,
446
+ prn2,
447
+ parsed.date,
448
+ parsed.values,
449
+ dataLines2
450
+ )
451
+ );
419
452
  } else if (sys2 === "G" || sys2 === "E" || sys2 === "C" || sys2 === "J" || sys2 === "I") {
420
- ephemerides.push(buildKeplerEphemeris(sys2, prn2, parsed.date, parsed.values, dataLines2));
453
+ ephemerides.push(
454
+ buildKeplerEphemeris(
455
+ sys2,
456
+ prn2,
457
+ parsed.date,
458
+ parsed.values,
459
+ dataLines2
460
+ )
461
+ );
421
462
  }
422
463
  }
423
464
  i++;
@@ -453,9 +494,13 @@ function parseNavFile(text) {
453
494
  }
454
495
  if (dataLines.length === numDataLines) {
455
496
  if (sys === "R" || sys === "S") {
456
- ephemerides.push(buildStateVectorEphemeris(sys, prn, date, epochVals, dataLines));
497
+ ephemerides.push(
498
+ buildStateVectorEphemeris(sys, prn, date, epochVals, dataLines)
499
+ );
457
500
  } else if (sys === "G" || sys === "E" || sys === "C" || sys === "J" || sys === "I") {
458
- ephemerides.push(buildKeplerEphemeris(sys, prn, date, epochVals, dataLines));
501
+ ephemerides.push(
502
+ buildKeplerEphemeris(sys, prn, date, epochVals, dataLines)
503
+ );
459
504
  }
460
505
  }
461
506
  i++;
@@ -4,7 +4,7 @@ import {
4
4
  GLO_F1_STEP,
5
5
  GLO_F2_BASE,
6
6
  GLO_F2_STEP
7
- } from "./chunk-354IRDOG.js";
7
+ } from "./chunk-LWNTWBHB.js";
8
8
 
9
9
  // src/rtcm3/decoder.ts
10
10
  var BitReader = class {
@@ -13,21 +13,18 @@ var BitReader = class {
13
13
  constructor(data) {
14
14
  this.data = data;
15
15
  }
16
- /** Read `n` bits as unsigned integer (max 32). */
16
+ /** Read `n` bits as unsigned integer (max 53). */
17
17
  readU(n) {
18
18
  if (n === 0) return 0;
19
19
  let val = 0;
20
20
  for (let i = 0; i < n; i++) {
21
21
  const byteIdx = this.bitPos + i >> 3;
22
22
  const bitIdx = 7 - (this.bitPos + i & 7);
23
- if (byteIdx < this.data.length) {
24
- val = val << 1 | this.data[byteIdx] >> bitIdx & 1;
25
- } else {
26
- val <<= 1;
27
- }
23
+ const bit = byteIdx < this.data.length ? this.data[byteIdx] >> bitIdx & 1 : 0;
24
+ val = val * 2 + bit;
28
25
  }
29
26
  this.bitPos += n;
30
- return val >>> 0;
27
+ return val;
31
28
  }
32
29
  /** Read `n` bits as signed (two's complement) integer. */
33
30
  readS(n) {
@@ -38,9 +35,9 @@ var BitReader = class {
38
35
  /** Read `n` bits as sign-magnitude integer (MSB = sign, rest = magnitude). */
39
36
  readSM(n) {
40
37
  const val = this.readU(n);
41
- const sign = val >> n - 1;
42
- const mag = val & (1 << n - 1) - 1;
43
- return sign ? -mag : mag;
38
+ const half = 2 ** (n - 1);
39
+ const mag = val % half;
40
+ return val >= half ? -mag : mag;
44
41
  }
45
42
  /** Skip `n` bits. */
46
43
  skip(n) {
@@ -827,17 +824,14 @@ var BitReader2 = class {
827
824
  this.data = data;
828
825
  this.pos = startBit;
829
826
  }
830
- /** Read unsigned value of numBits bits */
827
+ /** Read unsigned value of numBits bits (max 53) */
831
828
  u(numBits) {
832
829
  let val = 0;
833
830
  for (let i = 0; i < numBits; i++) {
834
831
  const byteIdx = this.pos + i >>> 3;
835
832
  const bitIdx = 7 - (this.pos + i & 7);
836
- if (byteIdx < this.data.length) {
837
- val = val << 1 | this.data[byteIdx] >>> bitIdx & 1;
838
- } else {
839
- val <<= 1;
840
- }
833
+ const bit = byteIdx < this.data.length ? this.data[byteIdx] >>> bitIdx & 1 : 0;
834
+ val = val * 2 + bit;
841
835
  }
842
836
  this.pos += numBits;
843
837
  return val;
@@ -845,8 +839,8 @@ var BitReader2 = class {
845
839
  /** Read signed value (two's complement) */
846
840
  s(numBits) {
847
841
  const raw = this.u(numBits);
848
- const sign = 1 << numBits - 1;
849
- return (raw & sign - 1) - (raw & sign);
842
+ const half = 2 ** (numBits - 1);
843
+ return raw >= half ? raw - 2 ** numBits : raw;
850
844
  }
851
845
  /** Skip bits */
852
846
  skip(n) {
@@ -981,7 +975,6 @@ function decodeMsmFull(frame) {
981
975
  const rdop = new Float64Array(numSat);
982
976
  if (variant === 4 || variant === 6) {
983
977
  for (let j = 0; j < numSat; j++) rrint[j] = bits.u(8);
984
- for (let j = 0; j < numSat; j++) extsat[j] = bits.u(4);
985
978
  for (let j = 0; j < numSat; j++) rrmod[j] = bits.u(10) / 1024;
986
979
  } else {
987
980
  for (let j = 0; j < numSat; j++) rrint[j] = bits.u(8);
@@ -1007,27 +1000,27 @@ function decodeMsmFull(frame) {
1007
1000
  cp.fill(-1e30);
1008
1001
  dop.fill(-1e30);
1009
1002
  if (variant === 4) {
1010
- for (let i = 0; i < activeCells; i++) psr[i] = bits.s(15) / (1 << 24);
1011
- for (let i = 0; i < activeCells; i++) cp[i] = bits.s(22) / (1 << 29);
1003
+ for (let i = 0; i < activeCells; i++) psr[i] = bits.s(15) / 2 ** 24;
1004
+ for (let i = 0; i < activeCells; i++) cp[i] = bits.s(22) / 2 ** 29;
1012
1005
  for (let i = 0; i < activeCells; i++) ll[i] = bits.u(4);
1013
1006
  for (let i = 0; i < activeCells; i++) hc[i] = bits.u(1);
1014
1007
  for (let i = 0; i < activeCells; i++) cnr[i] = bits.u(6);
1015
1008
  } else if (variant === 5) {
1016
- for (let i = 0; i < activeCells; i++) psr[i] = bits.s(15) / (1 << 24);
1017
- for (let i = 0; i < activeCells; i++) cp[i] = bits.s(22) / (1 << 29);
1009
+ for (let i = 0; i < activeCells; i++) psr[i] = bits.s(15) / 2 ** 24;
1010
+ for (let i = 0; i < activeCells; i++) cp[i] = bits.s(22) / 2 ** 29;
1018
1011
  for (let i = 0; i < activeCells; i++) ll[i] = bits.u(4);
1019
1012
  for (let i = 0; i < activeCells; i++) hc[i] = bits.u(1);
1020
1013
  for (let i = 0; i < activeCells; i++) cnr[i] = bits.u(6);
1021
1014
  for (let i = 0; i < activeCells; i++) dop[i] = bits.s(15) * 1e-4;
1022
1015
  } else if (variant === 6) {
1023
- for (let i = 0; i < activeCells; i++) psr[i] = bits.s(20) / (1 << 29);
1024
- for (let i = 0; i < activeCells; i++) cp[i] = bits.s(24) / (1 << 31);
1016
+ for (let i = 0; i < activeCells; i++) psr[i] = bits.s(20) / 2 ** 29;
1017
+ for (let i = 0; i < activeCells; i++) cp[i] = bits.s(24) / 2 ** 31;
1025
1018
  for (let i = 0; i < activeCells; i++) ll[i] = bits.u(10);
1026
1019
  for (let i = 0; i < activeCells; i++) hc[i] = bits.u(1);
1027
1020
  for (let i = 0; i < activeCells; i++) cnr[i] = bits.u(10) / 16;
1028
1021
  } else {
1029
- for (let i = 0; i < activeCells; i++) psr[i] = bits.s(20) / (1 << 29);
1030
- for (let i = 0; i < activeCells; i++) cp[i] = bits.s(24) / (1 << 31);
1022
+ for (let i = 0; i < activeCells; i++) psr[i] = bits.s(20) / 2 ** 29;
1023
+ for (let i = 0; i < activeCells; i++) cp[i] = bits.s(24) / 2 ** 31;
1031
1024
  for (let i = 0; i < activeCells; i++) ll[i] = bits.u(10);
1032
1025
  for (let i = 0; i < activeCells; i++) hc[i] = bits.u(1);
1033
1026
  for (let i = 0; i < activeCells; i++) cnr[i] = bits.u(10) / 16;
@@ -149,8 +149,20 @@ var C_LIGHT = 299792458;
149
149
  var FREQ = {
150
150
  G: { "1": 157542e4, "2": 12276e5, "5": 117645e4 },
151
151
  R: { "3": 1202025e3 },
152
- E: { "1": 157542e4, "5": 117645e4, "6": 127875e4, "7": 120714e4, "8": 1191795e3 },
153
- C: { "1": 157542e4, "2": 1561098e3, "5": 117645e4, "6": 126852e4, "7": 120714e4 },
152
+ E: {
153
+ "1": 157542e4,
154
+ "5": 117645e4,
155
+ "6": 127875e4,
156
+ "7": 120714e4,
157
+ "8": 1191795e3
158
+ },
159
+ C: {
160
+ "1": 157542e4,
161
+ "2": 1561098e3,
162
+ "5": 117645e4,
163
+ "6": 126852e4,
164
+ "7": 120714e4
165
+ },
154
166
  J: { "1": 157542e4, "2": 12276e5, "5": 117645e4, "6": 127875e4 },
155
167
  I: { "5": 117645e4, "9": 2492028e3 },
156
168
  S: { "1": 157542e4, "5": 117645e4 }
@@ -165,11 +177,28 @@ var BAND_LABELS = {
165
177
  S: { "1": "L1", "5": "L5" }
166
178
  };
167
179
  var DUAL_FREQ_PAIRS = {
168
- G: [["1", "2"], ["1", "5"]],
169
- R: [["1", "2"], ["1", "3"]],
170
- E: [["1", "5"], ["1", "7"], ["1", "6"]],
171
- C: [["2", "7"], ["2", "6"], ["1", "5"]],
172
- J: [["1", "2"], ["1", "5"]],
180
+ G: [
181
+ ["1", "2"],
182
+ ["1", "5"]
183
+ ],
184
+ R: [
185
+ ["1", "2"],
186
+ ["1", "3"]
187
+ ],
188
+ E: [
189
+ ["1", "5"],
190
+ ["1", "7"],
191
+ ["1", "6"]
192
+ ],
193
+ C: [
194
+ ["2", "7"],
195
+ ["2", "6"],
196
+ ["1", "5"]
197
+ ],
198
+ J: [
199
+ ["1", "2"],
200
+ ["1", "5"]
201
+ ],
173
202
  I: [["5", "9"]],
174
203
  S: [["1", "5"]]
175
204
  };
package/dist/constants.js CHANGED
@@ -45,7 +45,7 @@ import {
45
45
  formatUTCTime,
46
46
  getFreq,
47
47
  gloFreq
48
- } from "./chunk-354IRDOG.js";
48
+ } from "./chunk-LWNTWBHB.js";
49
49
  import {
50
50
  WGS84_ECCENTRICITY_SQUARED,
51
51
  WGS84_FLATTENING,
@@ -156,7 +156,10 @@ function vincenty(lat1, lon1, lat2, lon2) {
156
156
  const cosLat2 = Math.cos(lat2), sinLat2 = Math.sin(lat2);
157
157
  const dLon = lon2 - lon1;
158
158
  sigma = Math.acos(
159
- Math.min(1, Math.max(-1, sinLat1 * sinLat2 + cosLat1 * cosLat2 * Math.cos(dLon)))
159
+ Math.min(
160
+ 1,
161
+ Math.max(-1, sinLat1 * sinLat2 + cosLat1 * cosLat2 * Math.cos(dLon))
162
+ )
160
163
  );
161
164
  const distance2 = WGS84_SEMI_MAJOR_AXIS * sigma;
162
165
  const ib = Math.atan2(
@@ -10,7 +10,7 @@ import {
10
10
  rad2deg,
11
11
  rhumbLine,
12
12
  vincenty
13
- } from "./chunk-K7WZQFBV.js";
13
+ } from "./chunk-MIIM4LDY.js";
14
14
  import {
15
15
  clampUnit,
16
16
  ecefToGeodetic,
@@ -12,7 +12,7 @@ declare class BitReader {
12
12
  private data;
13
13
  private bitPos;
14
14
  constructor(data: Uint8Array);
15
- /** Read `n` bits as unsigned integer (max 32). */
15
+ /** Read `n` bits as unsigned integer (max 53). */
16
16
  readU(n: number): number;
17
17
  /** Read `n` bits as signed (two's complement) integer. */
18
18
  readS(n: number): number;
@@ -12,7 +12,7 @@ declare class BitReader {
12
12
  private data;
13
13
  private bitPos;
14
14
  constructor(data: Uint8Array);
15
- /** Read `n` bits as unsigned integer (max 32). */
15
+ /** Read `n` bits as unsigned integer (max 53). */
16
16
  readU(n: number): number;
17
17
  /** Read `n` bits as signed (two's complement) integer. */
18
18
  readS(n: number): number;