gnss-js 1.25.0 → 1.27.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/binex.cjs +799 -0
- package/dist/binex.d.cts +189 -0
- package/dist/binex.d.ts +189 -0
- package/dist/binex.js +19 -0
- package/dist/{chunk-VTX3VCL4.js → chunk-5AUK42AL.js} +4 -2
- package/dist/{chunk-WZDFZ76K.js → chunk-726LQBGM.js} +8 -148
- package/dist/{chunk-PZNVFCKJ.js → chunk-AFEDNWXI.js} +5 -3
- package/dist/chunk-CKRNXZHT.js +424 -0
- package/dist/{chunk-7RKLWE6R.js → chunk-F4CM6Q4F.js} +4 -2
- package/dist/{chunk-MCAVU3XL.js → chunk-FEOMYZEU.js} +5 -3
- package/dist/chunk-IQ5OIMQD.js +148 -0
- package/dist/chunk-OK4GGNOO.js +756 -0
- package/dist/{chunk-NOQAAUGY.js → chunk-QVNNHACQ.js} +441 -2
- package/dist/index.cjs +1635 -17
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +43 -16
- package/dist/novatel.js +3 -2
- package/dist/rinex.cjs +438 -0
- package/dist/rinex.d.cts +27 -1
- package/dist/rinex.d.ts +27 -1
- package/dist/rinex.js +5 -2
- package/dist/sbf.js +4 -3
- package/dist/trimble.cjs +452 -0
- package/dist/trimble.d.cts +147 -0
- package/dist/trimble.d.ts +147 -0
- package/dist/trimble.js +10 -0
- package/dist/ubx.js +4 -3
- package/package.json +11 -1
package/dist/rinex.d.cts
CHANGED
|
@@ -49,6 +49,32 @@ declare function crxDecompress(prev: DiffState | null, field: CrxField): {
|
|
|
49
49
|
result: number;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Compact RINEX (Hatanaka / CRX) *compression* — the inverse of crx.ts.
|
|
54
|
+
*
|
|
55
|
+
* This is a faithful TypeScript port of RNXCMP's `rnx2crx.c` (v4.2.0,
|
|
56
|
+
* Y. Hatanaka / GSI Japan), operating on RINEX text in and CRINEX text
|
|
57
|
+
* out. It reproduces the reference compressor byte-for-byte in the data
|
|
58
|
+
* section (the CRINEX header's PROG/DATE line carries a timestamp, so it
|
|
59
|
+
* is the only line that legitimately differs from a given run of the C
|
|
60
|
+
* tool). Validated against the `rnx2crx`/`crx2rnx` oracles on real
|
|
61
|
+
* multi-GNSS RINEX 3.03/3.04 observation files.
|
|
62
|
+
*
|
|
63
|
+
* Supports RINEX 2.x (CRINEX 1.0) and RINEX 3.x / 4.0x (CRINEX 3.0).
|
|
64
|
+
* The RINEX 4.02 pico-second epoch record (CRINEX 3.1) is handled too.
|
|
65
|
+
*/
|
|
66
|
+
interface WriteCrxOptions {
|
|
67
|
+
/** CRINEX PROG / DATE program label (≤20 chars). */
|
|
68
|
+
prog?: string;
|
|
69
|
+
/** CRINEX PROG / DATE timestamp (as `dd-MMM-yy HH:mm`). Defaults to now (UTC). */
|
|
70
|
+
date?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compress a full RINEX observation file (text) to Compact RINEX (text).
|
|
74
|
+
* The inverse of the crx.ts decoder. Throws on structurally invalid input.
|
|
75
|
+
*/
|
|
76
|
+
declare function writeCrx(rinexText: string, opts?: WriteCrxOptions): string;
|
|
77
|
+
|
|
52
78
|
/**
|
|
53
79
|
* Shared RINEX formatting helpers.
|
|
54
80
|
*
|
|
@@ -284,4 +310,4 @@ declare function createGzipLineSink(): {
|
|
|
284
310
|
*/
|
|
285
311
|
declare function stationHeaderLines(header: RinexHeader): string[];
|
|
286
312
|
|
|
287
|
-
export { type CompactEpoch, type CrxField, type DiffState, EMPTY_WARNINGS, Ephemeris, type Nav4Input, NavHeader, NavResult, RinexCnavEphemeris, RinexHeader, type RinexWarning, type RinexWarnings, type Sp3File, type Sp3Sample, WarningAccumulator, type WarningSeverity, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob };
|
|
313
|
+
export { type CompactEpoch, type CrxField, type DiffState, EMPTY_WARNINGS, Ephemeris, type Nav4Input, NavHeader, NavResult, RinexCnavEphemeris, RinexHeader, type RinexWarning, type RinexWarnings, type Sp3File, type Sp3Sample, WarningAccumulator, type WarningSeverity, type WriteCrxOptions, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeCrx, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob };
|
package/dist/rinex.d.ts
CHANGED
|
@@ -49,6 +49,32 @@ declare function crxDecompress(prev: DiffState | null, field: CrxField): {
|
|
|
49
49
|
result: number;
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Compact RINEX (Hatanaka / CRX) *compression* — the inverse of crx.ts.
|
|
54
|
+
*
|
|
55
|
+
* This is a faithful TypeScript port of RNXCMP's `rnx2crx.c` (v4.2.0,
|
|
56
|
+
* Y. Hatanaka / GSI Japan), operating on RINEX text in and CRINEX text
|
|
57
|
+
* out. It reproduces the reference compressor byte-for-byte in the data
|
|
58
|
+
* section (the CRINEX header's PROG/DATE line carries a timestamp, so it
|
|
59
|
+
* is the only line that legitimately differs from a given run of the C
|
|
60
|
+
* tool). Validated against the `rnx2crx`/`crx2rnx` oracles on real
|
|
61
|
+
* multi-GNSS RINEX 3.03/3.04 observation files.
|
|
62
|
+
*
|
|
63
|
+
* Supports RINEX 2.x (CRINEX 1.0) and RINEX 3.x / 4.0x (CRINEX 3.0).
|
|
64
|
+
* The RINEX 4.02 pico-second epoch record (CRINEX 3.1) is handled too.
|
|
65
|
+
*/
|
|
66
|
+
interface WriteCrxOptions {
|
|
67
|
+
/** CRINEX PROG / DATE program label (≤20 chars). */
|
|
68
|
+
prog?: string;
|
|
69
|
+
/** CRINEX PROG / DATE timestamp (as `dd-MMM-yy HH:mm`). Defaults to now (UTC). */
|
|
70
|
+
date?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compress a full RINEX observation file (text) to Compact RINEX (text).
|
|
74
|
+
* The inverse of the crx.ts decoder. Throws on structurally invalid input.
|
|
75
|
+
*/
|
|
76
|
+
declare function writeCrx(rinexText: string, opts?: WriteCrxOptions): string;
|
|
77
|
+
|
|
52
78
|
/**
|
|
53
79
|
* Shared RINEX formatting helpers.
|
|
54
80
|
*
|
|
@@ -284,4 +310,4 @@ declare function createGzipLineSink(): {
|
|
|
284
310
|
*/
|
|
285
311
|
declare function stationHeaderLines(header: RinexHeader): string[];
|
|
286
312
|
|
|
287
|
-
export { type CompactEpoch, type CrxField, type DiffState, EMPTY_WARNINGS, Ephemeris, type Nav4Input, NavHeader, NavResult, RinexCnavEphemeris, RinexHeader, type RinexWarning, type RinexWarnings, type Sp3File, type Sp3Sample, WarningAccumulator, type WarningSeverity, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob };
|
|
313
|
+
export { type CompactEpoch, type CrxField, type DiffState, EMPTY_WARNINGS, Ephemeris, type Nav4Input, NavHeader, NavResult, RinexCnavEphemeris, RinexHeader, type RinexWarning, type RinexWarnings, type Sp3File, type Sp3Sample, WarningAccumulator, type WarningSeverity, type WriteCrxOptions, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeCrx, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob };
|
package/dist/rinex.js
CHANGED
|
@@ -12,14 +12,16 @@ import {
|
|
|
12
12
|
parseSp3,
|
|
13
13
|
sp3Position,
|
|
14
14
|
stationHeaderLines,
|
|
15
|
+
writeCrx,
|
|
15
16
|
writeModernObsBlob,
|
|
16
17
|
writeRinex2ObsBlob,
|
|
17
18
|
writeRinex4ObsBlob,
|
|
18
19
|
writeRinexNav,
|
|
19
20
|
writeRinexNav4,
|
|
20
21
|
writeRinexObsBlob
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-QVNNHACQ.js";
|
|
23
|
+
import "./chunk-726LQBGM.js";
|
|
24
|
+
import "./chunk-IQ5OIMQD.js";
|
|
23
25
|
import {
|
|
24
26
|
SYSTEM_ORDER,
|
|
25
27
|
crxDecompress,
|
|
@@ -51,6 +53,7 @@ export {
|
|
|
51
53
|
stationHeaderLines,
|
|
52
54
|
systemCmp,
|
|
53
55
|
systemName,
|
|
56
|
+
writeCrx,
|
|
54
57
|
writeModernObsBlob,
|
|
55
58
|
writeRinex2ObsBlob,
|
|
56
59
|
writeRinex4ObsBlob,
|
package/dist/sbf.js
CHANGED
|
@@ -10,9 +10,10 @@ import {
|
|
|
10
10
|
parseSbfMeas,
|
|
11
11
|
parseSbfNav,
|
|
12
12
|
scanSbfFrames
|
|
13
|
-
} from "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
13
|
+
} from "./chunk-AFEDNWXI.js";
|
|
14
|
+
import "./chunk-5AUK42AL.js";
|
|
15
|
+
import "./chunk-726LQBGM.js";
|
|
16
|
+
import "./chunk-IQ5OIMQD.js";
|
|
16
17
|
import "./chunk-HVXYFUCB.js";
|
|
17
18
|
import "./chunk-LEEU5OIO.js";
|
|
18
19
|
export {
|
package/dist/trimble.cjs
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/trimble/index.ts
|
|
21
|
+
var trimble_exports = {};
|
|
22
|
+
__export(trimble_exports, {
|
|
23
|
+
parseTrimble: () => parseTrimble,
|
|
24
|
+
parseTrimbleNav: () => parseTrimbleNav,
|
|
25
|
+
trimbleFrames: () => trimbleFrames
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(trimble_exports);
|
|
28
|
+
|
|
29
|
+
// src/trimble/frame.ts
|
|
30
|
+
var STX = 2;
|
|
31
|
+
var ETX = 3;
|
|
32
|
+
var RAWDATA = 87;
|
|
33
|
+
var RETSVDATA = 85;
|
|
34
|
+
function* trimbleFrames(data, stats) {
|
|
35
|
+
let i = 0;
|
|
36
|
+
while (i + 6 <= data.length) {
|
|
37
|
+
if (data[i] !== STX) {
|
|
38
|
+
i++;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const len = data[i + 3];
|
|
42
|
+
const total = 4 + len + 2;
|
|
43
|
+
if (i + total > data.length) {
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (data[i + total - 1] !== ETX) {
|
|
48
|
+
i++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
let cs = 0;
|
|
52
|
+
for (let k = 1; k <= 3 + len; k++) cs = cs + data[i + k] & 255;
|
|
53
|
+
if (cs !== data[i + 4 + len]) {
|
|
54
|
+
stats.badChecksum++;
|
|
55
|
+
i++;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
yield {
|
|
59
|
+
start: i,
|
|
60
|
+
status: data[i + 1],
|
|
61
|
+
type: data[i + 2],
|
|
62
|
+
len,
|
|
63
|
+
payload: i + 4
|
|
64
|
+
};
|
|
65
|
+
i += total;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/trimble/nav.ts
|
|
70
|
+
var GPS_EPOCH_MS = Date.UTC(1980, 0, 6);
|
|
71
|
+
var SEC_PER_WEEK = 7 * 86400;
|
|
72
|
+
var MS_PER_WEEK = SEC_PER_WEEK * 1e3;
|
|
73
|
+
var GPS_PI = 3.1415926535898;
|
|
74
|
+
var gpsMs = (week, sec) => GPS_EPOCH_MS + week * MS_PER_WEEK + sec * 1e3;
|
|
75
|
+
var sowOf = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK;
|
|
76
|
+
var SUB_GPS_EPHEMERIS = 1;
|
|
77
|
+
var SUB_ION_UTC = 3;
|
|
78
|
+
function decodeGpsEphemeris(data, view, base) {
|
|
79
|
+
const prn = data[base + 5];
|
|
80
|
+
if (prn < 1 || prn > 32) return null;
|
|
81
|
+
const week = view.getUint16(base + 6, false);
|
|
82
|
+
const iode = data[base + 11];
|
|
83
|
+
const toc = view.getInt32(base + 16, false);
|
|
84
|
+
const toe = view.getUint32(base + 20, false);
|
|
85
|
+
const tgd = view.getFloat64(base + 24, false);
|
|
86
|
+
const af2 = view.getFloat64(base + 32, false);
|
|
87
|
+
const af1 = view.getFloat64(base + 40, false);
|
|
88
|
+
const af0 = view.getFloat64(base + 48, false);
|
|
89
|
+
const crs = view.getFloat64(base + 56, false);
|
|
90
|
+
const deltaN = view.getFloat64(base + 64, false) * GPS_PI;
|
|
91
|
+
const m0 = view.getFloat64(base + 72, false) * GPS_PI;
|
|
92
|
+
const cuc = view.getFloat64(base + 80, false) * GPS_PI;
|
|
93
|
+
const e = view.getFloat64(base + 88, false);
|
|
94
|
+
const cus = view.getFloat64(base + 96, false) * GPS_PI;
|
|
95
|
+
const sqrtA = view.getFloat64(base + 104, false);
|
|
96
|
+
const cic = view.getFloat64(base + 112, false) * GPS_PI;
|
|
97
|
+
const omega0 = view.getFloat64(base + 120, false) * GPS_PI;
|
|
98
|
+
const cis = view.getFloat64(base + 128, false) * GPS_PI;
|
|
99
|
+
const i0 = view.getFloat64(base + 136, false) * GPS_PI;
|
|
100
|
+
const crc = view.getFloat64(base + 144, false);
|
|
101
|
+
const omega = view.getFloat64(base + 152, false) * GPS_PI;
|
|
102
|
+
const omegaDot = view.getFloat64(base + 160, false) * GPS_PI;
|
|
103
|
+
const idot = view.getFloat64(base + 168, false) * GPS_PI;
|
|
104
|
+
const flags = view.getUint32(base + 176, false);
|
|
105
|
+
return {
|
|
106
|
+
system: "G",
|
|
107
|
+
prn: `G${String(prn).padStart(2, "0")}`,
|
|
108
|
+
toc: sowOf(gpsMs(week, toc)),
|
|
109
|
+
tocDate: new Date(gpsMs(week, toc)),
|
|
110
|
+
af0,
|
|
111
|
+
af1,
|
|
112
|
+
af2,
|
|
113
|
+
iode,
|
|
114
|
+
crs,
|
|
115
|
+
deltaN,
|
|
116
|
+
m0,
|
|
117
|
+
cuc,
|
|
118
|
+
e,
|
|
119
|
+
cus,
|
|
120
|
+
sqrtA,
|
|
121
|
+
toe,
|
|
122
|
+
cic,
|
|
123
|
+
omega0,
|
|
124
|
+
cis,
|
|
125
|
+
i0,
|
|
126
|
+
crc,
|
|
127
|
+
omega,
|
|
128
|
+
omegaDot,
|
|
129
|
+
idot,
|
|
130
|
+
week,
|
|
131
|
+
svHealth: flags >>> 4 & 127,
|
|
132
|
+
tgd
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function parseTrimbleNav(data) {
|
|
136
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
137
|
+
const stats = { badChecksum: 0 };
|
|
138
|
+
const ephemerides = [];
|
|
139
|
+
const ionoCorrections = {};
|
|
140
|
+
const retsvCounts = {};
|
|
141
|
+
let leapSeconds = null;
|
|
142
|
+
const lastIode = /* @__PURE__ */ new Map();
|
|
143
|
+
for (const f of trimbleFrames(data, stats)) {
|
|
144
|
+
if (f.type !== RETSVDATA) continue;
|
|
145
|
+
const sub = data[f.payload];
|
|
146
|
+
retsvCounts[sub] = (retsvCounts[sub] ?? 0) + 1;
|
|
147
|
+
if (sub === SUB_GPS_EPHEMERIS && f.len >= 178) {
|
|
148
|
+
const eph = decodeGpsEphemeris(data, view, f.start);
|
|
149
|
+
if (!eph) continue;
|
|
150
|
+
if (lastIode.get(eph.prn) === eph.iode) continue;
|
|
151
|
+
lastIode.set(eph.prn, eph.iode);
|
|
152
|
+
ephemerides.push(eph);
|
|
153
|
+
} else if (sub === SUB_ION_UTC && f.len >= 125) {
|
|
154
|
+
const p = f.start;
|
|
155
|
+
const alpha = [];
|
|
156
|
+
const beta = [];
|
|
157
|
+
for (let i = 0; i < 4; i++) {
|
|
158
|
+
alpha.push(view.getFloat64(p + 6 + i * 8, false));
|
|
159
|
+
beta.push(view.getFloat64(p + 38 + i * 8, false));
|
|
160
|
+
}
|
|
161
|
+
ionoCorrections["GPSA"] = alpha;
|
|
162
|
+
ionoCorrections["GPSB"] = beta;
|
|
163
|
+
leapSeconds = Math.trunc(view.getFloat64(p + 94, false));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
ephemerides,
|
|
168
|
+
ionoCorrections,
|
|
169
|
+
leapSeconds,
|
|
170
|
+
retsvCounts,
|
|
171
|
+
badChecksum: stats.badChecksum
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/trimble/index.ts
|
|
176
|
+
var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
|
|
177
|
+
var MS_PER_WEEK2 = 7 * 864e5;
|
|
178
|
+
var REC_TYPE_27 = 6;
|
|
179
|
+
var SYS = {
|
|
180
|
+
0: "G",
|
|
181
|
+
// GPS
|
|
182
|
+
1: "S",
|
|
183
|
+
// SBAS
|
|
184
|
+
2: "R",
|
|
185
|
+
// GLONASS
|
|
186
|
+
3: "E",
|
|
187
|
+
// Galileo
|
|
188
|
+
4: "J",
|
|
189
|
+
// QZSS
|
|
190
|
+
5: "C",
|
|
191
|
+
// BeiDou (pre-ICD numbering)
|
|
192
|
+
7: "C",
|
|
193
|
+
// BeiDou (ICD numbering)
|
|
194
|
+
9: "I",
|
|
195
|
+
// NavIC / IRNSS
|
|
196
|
+
10: "C"
|
|
197
|
+
// BeiDou
|
|
198
|
+
};
|
|
199
|
+
var CODES = {
|
|
200
|
+
"G0-0": "1C",
|
|
201
|
+
"G0-20": "1L",
|
|
202
|
+
"G1-2": "2W",
|
|
203
|
+
"G1-5": "2L",
|
|
204
|
+
"G2-6": "5I",
|
|
205
|
+
"G2-7": "5Q",
|
|
206
|
+
"G2-8": "5X",
|
|
207
|
+
"R0-0": "1C",
|
|
208
|
+
"R0-1": "1P",
|
|
209
|
+
"R1-0": "2C",
|
|
210
|
+
"R1-1": "2P",
|
|
211
|
+
"E0-23": "1C",
|
|
212
|
+
"E2-11": "5Q",
|
|
213
|
+
"E3-11": "7Q",
|
|
214
|
+
"E4-14": "8Q",
|
|
215
|
+
"E5-36": "6C",
|
|
216
|
+
"C0-20": "1P",
|
|
217
|
+
"C2-8": "5P",
|
|
218
|
+
"C3-6": "7D",
|
|
219
|
+
"C6-26": "2I",
|
|
220
|
+
"C7-29": "6I",
|
|
221
|
+
"S0-0": "1C",
|
|
222
|
+
"S2-6": "5I",
|
|
223
|
+
"J0-0": "1C"
|
|
224
|
+
};
|
|
225
|
+
var BAND_DIGIT = {
|
|
226
|
+
0: "1",
|
|
227
|
+
// L1 / E1 / B1C (1575.42)
|
|
228
|
+
1: "2",
|
|
229
|
+
// L2 / G2 (1227.6)
|
|
230
|
+
2: "5",
|
|
231
|
+
// L5 / E5a (1176.45)
|
|
232
|
+
3: "7",
|
|
233
|
+
// E5b / B2b (1207.14)
|
|
234
|
+
4: "8",
|
|
235
|
+
// E5 AltBOC (1191.795)
|
|
236
|
+
5: "6",
|
|
237
|
+
// E6 (1278.75)
|
|
238
|
+
6: "2",
|
|
239
|
+
// B1I (1561.098)
|
|
240
|
+
7: "6",
|
|
241
|
+
// B3I (1268.52)
|
|
242
|
+
8: "1",
|
|
243
|
+
// BeiDou E1 (1589.742)
|
|
244
|
+
9: "3",
|
|
245
|
+
// GLONASS G3 CDMA (1202.025)
|
|
246
|
+
11: "9"
|
|
247
|
+
// NavIC S-band (2492.028)
|
|
248
|
+
};
|
|
249
|
+
function rinexCode(sys, band, track) {
|
|
250
|
+
const key = `${sys}${band}-${track}`;
|
|
251
|
+
return CODES[key] ?? `${BAND_DIGIT[band] ?? "?"}X`;
|
|
252
|
+
}
|
|
253
|
+
function rinexPrn(sys, svid) {
|
|
254
|
+
let n = svid;
|
|
255
|
+
if (sys === "S")
|
|
256
|
+
n = svid - 100;
|
|
257
|
+
else if (sys === "J" && svid >= 193) n = svid - 192;
|
|
258
|
+
return `${sys}${String(n).padStart(2, "0")}`;
|
|
259
|
+
}
|
|
260
|
+
var readS16 = (dv, o) => dv.getInt16(o, false);
|
|
261
|
+
function readS24(d, o) {
|
|
262
|
+
const v = d[o] << 16 | d[o + 1] << 8 | d[o + 2];
|
|
263
|
+
return v & 8388608 ? v - 16777216 : v;
|
|
264
|
+
}
|
|
265
|
+
function readS48(d, dv, o) {
|
|
266
|
+
const hi = d[o] << 8 | d[o + 1];
|
|
267
|
+
const lo = dv.getUint32(o + 2, false);
|
|
268
|
+
const v = hi * 4294967296 + lo;
|
|
269
|
+
return hi & 32768 ? v - 281474976710656 : v;
|
|
270
|
+
}
|
|
271
|
+
function parseTrimble(data) {
|
|
272
|
+
const stats = { badChecksum: 0 };
|
|
273
|
+
const epochs = [];
|
|
274
|
+
const obsCodes = {};
|
|
275
|
+
const recordCounts = {};
|
|
276
|
+
const retsvCounts = {};
|
|
277
|
+
let pages = [];
|
|
278
|
+
let msgReply = -1;
|
|
279
|
+
let lastPage = 0;
|
|
280
|
+
let msgPages = 0;
|
|
281
|
+
let epoch = null;
|
|
282
|
+
const finalize = () => {
|
|
283
|
+
if (epoch) decodeEpoch(epoch, epochs, obsCodes);
|
|
284
|
+
epoch = null;
|
|
285
|
+
};
|
|
286
|
+
const onMessage = (content, reply) => {
|
|
287
|
+
if (epoch && reply === epoch.reply) {
|
|
288
|
+
epoch.chunks.push(content);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
finalize();
|
|
292
|
+
if (content.length < 12) return;
|
|
293
|
+
const dv = new DataView(
|
|
294
|
+
content.buffer,
|
|
295
|
+
content.byteOffset,
|
|
296
|
+
content.byteLength
|
|
297
|
+
);
|
|
298
|
+
const headerLen = content[0];
|
|
299
|
+
const week = dv.getUint16(1, false);
|
|
300
|
+
const towMs = dv.getUint32(3, false);
|
|
301
|
+
const nsv = content[10];
|
|
302
|
+
const eflags = content[11];
|
|
303
|
+
if (week < 1024 || week > 4096 || headerLen < 12 || nsv === 0) return;
|
|
304
|
+
let svStart = headerLen;
|
|
305
|
+
if (eflags & 32 && svStart < content.length) svStart += content[svStart];
|
|
306
|
+
epoch = {
|
|
307
|
+
reply,
|
|
308
|
+
week,
|
|
309
|
+
towMs,
|
|
310
|
+
nsv,
|
|
311
|
+
chunks: [content.subarray(svStart)]
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
const completeMessage = () => {
|
|
315
|
+
const total = pages.reduce((a, c) => a + c.length, 0);
|
|
316
|
+
const content = new Uint8Array(total);
|
|
317
|
+
let o = 0;
|
|
318
|
+
for (const c of pages) {
|
|
319
|
+
content.set(c, o);
|
|
320
|
+
o += c.length;
|
|
321
|
+
}
|
|
322
|
+
const reply = msgReply;
|
|
323
|
+
pages = [];
|
|
324
|
+
onMessage(content, reply);
|
|
325
|
+
};
|
|
326
|
+
for (const f of trimbleFrames(data, stats)) {
|
|
327
|
+
if (f.type !== RAWDATA) {
|
|
328
|
+
if (f.type === 85) {
|
|
329
|
+
const sub = data[f.payload];
|
|
330
|
+
retsvCounts[sub] = (retsvCounts[sub] ?? 0) + 1;
|
|
331
|
+
}
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const recType = data[f.payload];
|
|
335
|
+
recordCounts[recType] = (recordCounts[recType] ?? 0) + 1;
|
|
336
|
+
if (recType !== REC_TYPE_27) continue;
|
|
337
|
+
const pageByte = data[f.payload + 1];
|
|
338
|
+
const page = pageByte >> 4;
|
|
339
|
+
const pagesTotal = pageByte & 15;
|
|
340
|
+
const reply = data[f.payload + 2];
|
|
341
|
+
const content = data.subarray(f.payload + 4, f.payload + f.len);
|
|
342
|
+
if (page === 1) {
|
|
343
|
+
pages = [content];
|
|
344
|
+
msgReply = reply;
|
|
345
|
+
msgPages = pagesTotal;
|
|
346
|
+
lastPage = 1;
|
|
347
|
+
} else if (reply === msgReply && page === lastPage + 1) {
|
|
348
|
+
pages.push(content);
|
|
349
|
+
lastPage = page;
|
|
350
|
+
} else {
|
|
351
|
+
pages = [];
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (lastPage === msgPages) completeMessage();
|
|
355
|
+
}
|
|
356
|
+
finalize();
|
|
357
|
+
return {
|
|
358
|
+
epochs,
|
|
359
|
+
obsCodes,
|
|
360
|
+
recordCounts,
|
|
361
|
+
retsvCounts,
|
|
362
|
+
badChecksum: stats.badChecksum
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function decodeEpoch(epoch, epochs, obsCodes) {
|
|
366
|
+
const total = epoch.chunks.reduce((a, c) => a + c.length, 0);
|
|
367
|
+
const M = new Uint8Array(total);
|
|
368
|
+
let o = 0;
|
|
369
|
+
for (const c of epoch.chunks) {
|
|
370
|
+
M.set(c, o);
|
|
371
|
+
o += c.length;
|
|
372
|
+
}
|
|
373
|
+
const dv = new DataView(M.buffer, M.byteOffset, M.byteLength);
|
|
374
|
+
const timeMs = GPS_EPOCH_MS2 + epoch.week * MS_PER_WEEK2 + epoch.towMs;
|
|
375
|
+
const meas = [];
|
|
376
|
+
let q = 0;
|
|
377
|
+
for (let sv = 0; sv < epoch.nsv && q + 8 <= M.length; sv++) {
|
|
378
|
+
const svLen = M[q];
|
|
379
|
+
if (svLen < 8 || q + svLen > M.length) break;
|
|
380
|
+
const svid = M[q + 1];
|
|
381
|
+
const sys = SYS[M[q + 2] & 63];
|
|
382
|
+
const chan = M[q + 3] << 24 >> 24;
|
|
383
|
+
const nblk = M[q + 4];
|
|
384
|
+
const prn = sys ? rinexPrn(sys, svid) : null;
|
|
385
|
+
const gloChannel = sys === "R" ? chan : null;
|
|
386
|
+
let r = q + svLen;
|
|
387
|
+
let pr0 = 0;
|
|
388
|
+
for (let b = 0; b < nblk; b++) {
|
|
389
|
+
if (r + 5 > M.length) break;
|
|
390
|
+
const mLen = M[r];
|
|
391
|
+
if (mLen < 5 || r + mLen > M.length) break;
|
|
392
|
+
const band = M[r + 1];
|
|
393
|
+
const track = M[r + 2];
|
|
394
|
+
const cn0 = dv.getUint16(r + 3, false) / 10;
|
|
395
|
+
let p = r + 5;
|
|
396
|
+
let pr;
|
|
397
|
+
if (b === 0) {
|
|
398
|
+
const scale = sys === "S" || sys === "J" ? 64 : 128;
|
|
399
|
+
pr = dv.getUint32(p, false) / scale;
|
|
400
|
+
p += 4;
|
|
401
|
+
pr0 = pr;
|
|
402
|
+
} else {
|
|
403
|
+
pr = pr0 + readS16(dv, p) / 256;
|
|
404
|
+
p += 2;
|
|
405
|
+
}
|
|
406
|
+
const cp = -readS48(M, dv, p) / 32768;
|
|
407
|
+
p += 6;
|
|
408
|
+
const cycleSlipCount = M[p];
|
|
409
|
+
p += 1;
|
|
410
|
+
const mf = M[p];
|
|
411
|
+
p += 1;
|
|
412
|
+
let mf2 = 0;
|
|
413
|
+
if (mf & 128) {
|
|
414
|
+
mf2 = M[p];
|
|
415
|
+
p += 1;
|
|
416
|
+
let f = mf2;
|
|
417
|
+
while (f & 128) {
|
|
418
|
+
f = M[p];
|
|
419
|
+
p += 1;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
if (mf2 & 1) p += 1;
|
|
423
|
+
let doppler = null;
|
|
424
|
+
if (mf & 4) doppler = readS24(M, p) / 256;
|
|
425
|
+
if (prn && sys) {
|
|
426
|
+
const code = rinexCode(sys, band, track);
|
|
427
|
+
meas.push({
|
|
428
|
+
prn,
|
|
429
|
+
code,
|
|
430
|
+
pr: mf & 2 ? pr : null,
|
|
431
|
+
cp: mf & 1 ? cp : null,
|
|
432
|
+
doppler: mf & 1 ? doppler : null,
|
|
433
|
+
cn0,
|
|
434
|
+
cycleSlipCount,
|
|
435
|
+
cycleSlip: (mf & 8) !== 0,
|
|
436
|
+
gloChannel
|
|
437
|
+
});
|
|
438
|
+
const list = obsCodes[sys] ??= [];
|
|
439
|
+
if (!list.includes(code)) list.push(code);
|
|
440
|
+
}
|
|
441
|
+
r += mLen;
|
|
442
|
+
}
|
|
443
|
+
q = r;
|
|
444
|
+
}
|
|
445
|
+
epochs.push({ timeMs, meas });
|
|
446
|
+
}
|
|
447
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
448
|
+
0 && (module.exports = {
|
|
449
|
+
parseTrimble,
|
|
450
|
+
parseTrimbleNav,
|
|
451
|
+
trimbleFrames
|
|
452
|
+
});
|