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
|
@@ -1,8 +1,446 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CNAV_A_REF,
|
|
3
|
-
CNAV_OMEGA_DOT_REF
|
|
3
|
+
CNAV_OMEGA_DOT_REF
|
|
4
|
+
} from "./chunk-726LQBGM.js";
|
|
5
|
+
import {
|
|
4
6
|
GPS_PI
|
|
5
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IQ5OIMQD.js";
|
|
8
|
+
|
|
9
|
+
// src/rinex/crx-writer.ts
|
|
10
|
+
var ARC_ORDER = 3;
|
|
11
|
+
function emptyData() {
|
|
12
|
+
return { u: [0, 0, 0, 0], l: [0, 0, 0, 0], order: -1 };
|
|
13
|
+
}
|
|
14
|
+
function cAtol(s) {
|
|
15
|
+
let i = 0;
|
|
16
|
+
while (i < s.length && (s[i] === " " || s[i] === " ")) i++;
|
|
17
|
+
let sign = 1;
|
|
18
|
+
if (s[i] === "+" || s[i] === "-") {
|
|
19
|
+
if (s[i] === "-") sign = -1;
|
|
20
|
+
i++;
|
|
21
|
+
}
|
|
22
|
+
let n = 0;
|
|
23
|
+
let any = false;
|
|
24
|
+
while (i < s.length && s[i] >= "0" && s[i] <= "9") {
|
|
25
|
+
n = n * 10 + (s.charCodeAt(i) - 48);
|
|
26
|
+
i++;
|
|
27
|
+
any = true;
|
|
28
|
+
}
|
|
29
|
+
return any ? sign * n : 0;
|
|
30
|
+
}
|
|
31
|
+
function strdiff(s1, s2) {
|
|
32
|
+
let ds = "";
|
|
33
|
+
const n = Math.min(s1.length, s2.length);
|
|
34
|
+
let i = 0;
|
|
35
|
+
for (; i < n; i++) {
|
|
36
|
+
if (s2[i] === s1[i]) ds += " ";
|
|
37
|
+
else if (s2[i] === " ") ds += "&";
|
|
38
|
+
else ds += s2[i];
|
|
39
|
+
}
|
|
40
|
+
if (s1.length > s2.length) {
|
|
41
|
+
for (let k = i; k < s1.length; k++) ds += s1[k] === " " ? " " : "&";
|
|
42
|
+
} else if (s2.length > s1.length) {
|
|
43
|
+
ds += s2.slice(i);
|
|
44
|
+
}
|
|
45
|
+
let end = ds.length;
|
|
46
|
+
while (end > 0 && ds[end - 1] === " ") end--;
|
|
47
|
+
return ds.slice(0, end);
|
|
48
|
+
}
|
|
49
|
+
function readValue(field14) {
|
|
50
|
+
const c = field14.padEnd(14, " ").split("");
|
|
51
|
+
const p7 = c[7];
|
|
52
|
+
c[10] = c[9];
|
|
53
|
+
c[9] = c[8];
|
|
54
|
+
let l = cAtol(c.slice(9, 14).join(""));
|
|
55
|
+
let u;
|
|
56
|
+
if (p7 === " ") {
|
|
57
|
+
u = 0;
|
|
58
|
+
} else if (p7 === "-") {
|
|
59
|
+
u = 0;
|
|
60
|
+
l = -l;
|
|
61
|
+
} else {
|
|
62
|
+
c[8] = ".";
|
|
63
|
+
u = cAtol(c.slice(0, 14).join(""));
|
|
64
|
+
if (u < 0) l = -l;
|
|
65
|
+
}
|
|
66
|
+
return { u, l };
|
|
67
|
+
}
|
|
68
|
+
function putdiff(dddu, dddl) {
|
|
69
|
+
dddu += Math.trunc(dddl / 1e5);
|
|
70
|
+
dddl %= 1e5;
|
|
71
|
+
if (dddu < 0 && dddl > 0) {
|
|
72
|
+
dddu++;
|
|
73
|
+
dddl -= 1e5;
|
|
74
|
+
} else if (dddu > 0 && dddl < 0) {
|
|
75
|
+
dddu--;
|
|
76
|
+
dddl += 1e5;
|
|
77
|
+
}
|
|
78
|
+
if (dddu === 0) return String(dddl);
|
|
79
|
+
return `${dddu}${String(Math.abs(dddl)).padStart(5, "0")}`;
|
|
80
|
+
}
|
|
81
|
+
function putClock(du, dl, cOrder) {
|
|
82
|
+
du += Math.trunc(dl / 1e8);
|
|
83
|
+
dl %= 1e8;
|
|
84
|
+
if (du < 0 && dl > 0) {
|
|
85
|
+
du++;
|
|
86
|
+
dl -= 1e8;
|
|
87
|
+
} else if (du > 0 && dl < 0) {
|
|
88
|
+
du--;
|
|
89
|
+
dl += 1e8;
|
|
90
|
+
}
|
|
91
|
+
let out = "";
|
|
92
|
+
if (cOrder === 0) out += `${ARC_ORDER}&`;
|
|
93
|
+
if (du === 0) out += String(dl);
|
|
94
|
+
else out += `${du}${String(Math.abs(dl)).padStart(8, "0")}`;
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
function chop(line) {
|
|
98
|
+
let end = line.length;
|
|
99
|
+
if (end > 0 && line[end - 1] === "\r") end--;
|
|
100
|
+
while (end > 0 && line[end - 1] === " ") end--;
|
|
101
|
+
return line.slice(0, end);
|
|
102
|
+
}
|
|
103
|
+
function readSat(lines, cursor, rinexVersion, ntype, ntypeGnss) {
|
|
104
|
+
let line = chop(lines[cursor.li++] ?? "");
|
|
105
|
+
let maxField;
|
|
106
|
+
let ntypeRec;
|
|
107
|
+
let firstRec;
|
|
108
|
+
let satId = "";
|
|
109
|
+
if (rinexVersion === 2) {
|
|
110
|
+
maxField = 5;
|
|
111
|
+
ntypeRec = ntype;
|
|
112
|
+
firstRec = 0;
|
|
113
|
+
} else {
|
|
114
|
+
satId = line.slice(0, 3);
|
|
115
|
+
const sys = line[0];
|
|
116
|
+
maxField = ntypeRec = ntypeGnss[sys] ?? -1;
|
|
117
|
+
if (maxField < 0) return null;
|
|
118
|
+
firstRec = 3;
|
|
119
|
+
}
|
|
120
|
+
const data = [];
|
|
121
|
+
let flag = "";
|
|
122
|
+
for (let i = 0; i < ntypeRec; i += maxField) {
|
|
123
|
+
const nfield = Math.min(ntypeRec - i, maxField);
|
|
124
|
+
const need = firstRec + 16 * nfield;
|
|
125
|
+
let body = line;
|
|
126
|
+
if (body.length < need) body = body.padEnd(need, " ");
|
|
127
|
+
for (let j = 0; j < nfield; j++) {
|
|
128
|
+
const p = firstRec + j * 16;
|
|
129
|
+
const rec = body.slice(p, p + 16);
|
|
130
|
+
const d = emptyData();
|
|
131
|
+
if (rec[10] === ".") {
|
|
132
|
+
flag += rec[14] ?? " ";
|
|
133
|
+
flag += rec[15] ?? " ";
|
|
134
|
+
const v = readValue(rec.slice(0, 14));
|
|
135
|
+
d.u[0] = v.u;
|
|
136
|
+
d.l[0] = v.l;
|
|
137
|
+
d.order = 0;
|
|
138
|
+
} else if (rec.slice(0, 14).trim() === "") {
|
|
139
|
+
flag += rec[14] ?? " ";
|
|
140
|
+
flag += rec[15] ?? " ";
|
|
141
|
+
d.order = -1;
|
|
142
|
+
} else {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
data.push(d);
|
|
146
|
+
}
|
|
147
|
+
if (i + maxField < ntypeRec) {
|
|
148
|
+
line = chop(lines[cursor.li++] ?? "");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { sat: { data, flag, ntypeRec }, satId };
|
|
152
|
+
}
|
|
153
|
+
var MONTHS = [
|
|
154
|
+
"Jan",
|
|
155
|
+
"Feb",
|
|
156
|
+
"Mar",
|
|
157
|
+
"Apr",
|
|
158
|
+
"May",
|
|
159
|
+
"Jun",
|
|
160
|
+
"Jul",
|
|
161
|
+
"Aug",
|
|
162
|
+
"Sep",
|
|
163
|
+
"Oct",
|
|
164
|
+
"Nov",
|
|
165
|
+
"Dec"
|
|
166
|
+
];
|
|
167
|
+
function crinexDate() {
|
|
168
|
+
const d = /* @__PURE__ */ new Date();
|
|
169
|
+
const dd = String(d.getUTCDate()).padStart(2, "0");
|
|
170
|
+
const mon = MONTHS[d.getUTCMonth()];
|
|
171
|
+
const yy = String(d.getUTCFullYear() % 100).padStart(2, "0");
|
|
172
|
+
const hh = String(d.getUTCHours()).padStart(2, "0");
|
|
173
|
+
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
174
|
+
return `${dd}-${mon}-${yy} ${hh}:${mm}`;
|
|
175
|
+
}
|
|
176
|
+
function writeCrx(rinexText, opts = {}) {
|
|
177
|
+
const rawLines = rinexText.split("\n");
|
|
178
|
+
const cursor = { li: 0 };
|
|
179
|
+
const out = [];
|
|
180
|
+
const firstLine = chop(rawLines[cursor.li++] ?? "");
|
|
181
|
+
if (firstLine.slice(60, 80) !== "RINEX VERSION / TYPE" || firstLine[20] !== "O") {
|
|
182
|
+
throw new Error("writeCrx: not a RINEX observation file");
|
|
183
|
+
}
|
|
184
|
+
const rinexVersion = parseInt(firstLine, 10);
|
|
185
|
+
const rinexVersionFull = readVersionFull(firstLine);
|
|
186
|
+
if (rinexVersionFull < 0) throw new Error("writeCrx: invalid RINEX version");
|
|
187
|
+
const crxVersion = rinexVersionFull >= 402 ? "3.1" : rinexVersion === 2 ? "1.0" : "3.0";
|
|
188
|
+
out.push(
|
|
189
|
+
`${crxVersion.padEnd(20)}${"COMPACT RINEX FORMAT".padEnd(40)}${"CRINEX VERS / TYPE".padEnd(20)}`
|
|
190
|
+
);
|
|
191
|
+
const prog = (opts.prog ?? "gnss-js writeCrx").slice(0, 40);
|
|
192
|
+
const date = opts.date ?? crinexDate();
|
|
193
|
+
out.push(`${prog.padEnd(40)}${date.padEnd(20)}CRINEX PROG / DATE`);
|
|
194
|
+
out.push(firstLine);
|
|
195
|
+
let ntype = 0;
|
|
196
|
+
const ntypeGnss = {};
|
|
197
|
+
let line;
|
|
198
|
+
do {
|
|
199
|
+
line = chop(rawLines[cursor.li++] ?? "");
|
|
200
|
+
out.push(line);
|
|
201
|
+
const label = line.slice(60).trimStart();
|
|
202
|
+
if (label.startsWith("# / TYPES OF OBSERV") && line[5] !== " ") {
|
|
203
|
+
ntype = parseInt(line, 10);
|
|
204
|
+
} else if (label.startsWith("SYS / # / OBS TYPES") && line[0] !== " ") {
|
|
205
|
+
ntypeGnss[line[0]] = parseInt(line.slice(3), 10);
|
|
206
|
+
}
|
|
207
|
+
if (cursor.li >= rawLines.length) break;
|
|
208
|
+
} while (!line.slice(60).trimStart().startsWith("END OF HEADER"));
|
|
209
|
+
const v2 = rinexVersion === 2;
|
|
210
|
+
const off = v2 ? { event: 28, nsat: 29, satlst: 32, clock: 68, satOld: 32, shiftClk: 1 } : {
|
|
211
|
+
event: 31,
|
|
212
|
+
nsat: 32,
|
|
213
|
+
satlst: 41,
|
|
214
|
+
clock: 41,
|
|
215
|
+
satOld: 41,
|
|
216
|
+
shiftClk: 4,
|
|
217
|
+
psec: 57
|
|
218
|
+
};
|
|
219
|
+
let oldline = "&";
|
|
220
|
+
let nsatOld = 0;
|
|
221
|
+
let clk0 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
222
|
+
let dy0 = [];
|
|
223
|
+
let flag0 = [];
|
|
224
|
+
let oldpsec = "";
|
|
225
|
+
let clkOrderPrev = -1;
|
|
226
|
+
const resetArcs = () => {
|
|
227
|
+
oldline = "&";
|
|
228
|
+
nsatOld = 0;
|
|
229
|
+
clkOrderPrev = -1;
|
|
230
|
+
};
|
|
231
|
+
for (; ; ) {
|
|
232
|
+
if (cursor.li >= rawLines.length) break;
|
|
233
|
+
let epoch = rawLines[cursor.li];
|
|
234
|
+
if (epoch === void 0) break;
|
|
235
|
+
if (epoch === "" && cursor.li === rawLines.length - 1) break;
|
|
236
|
+
cursor.li++;
|
|
237
|
+
epoch = chop(epoch);
|
|
238
|
+
if (epoch === "") continue;
|
|
239
|
+
let newline;
|
|
240
|
+
if (v2) {
|
|
241
|
+
newline = epoch;
|
|
242
|
+
} else {
|
|
243
|
+
newline = epoch.length < 41 ? epoch.padEnd(41, " ") : epoch;
|
|
244
|
+
}
|
|
245
|
+
const eventFlag = parseInt(newline[off.event] ?? "0", 10) || 0;
|
|
246
|
+
if (eventFlag > 1) {
|
|
247
|
+
putEventData(rawLines, cursor, v2, newline, out, ntypeGnss, (n) => {
|
|
248
|
+
ntype = n;
|
|
249
|
+
});
|
|
250
|
+
resetArcs();
|
|
251
|
+
clk0 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
252
|
+
dy0 = [];
|
|
253
|
+
flag0 = [];
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
let newpsec = "";
|
|
257
|
+
if (rinexVersionFull >= 402 && newline.length === 62) {
|
|
258
|
+
const psec = newline.slice(off.psec, off.psec + 5);
|
|
259
|
+
if (/^\d{5}$/.test(psec)) newpsec = psec;
|
|
260
|
+
newline = newline.slice(0, off.psec).replace(/\s+$/, "");
|
|
261
|
+
}
|
|
262
|
+
let clkOrder = -1;
|
|
263
|
+
const clk1 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
264
|
+
if (newline.length > off.clock) {
|
|
265
|
+
clkOrder = readClock(
|
|
266
|
+
newline.slice(off.clock),
|
|
267
|
+
off.shiftClk,
|
|
268
|
+
clk1,
|
|
269
|
+
clkOrderPrev
|
|
270
|
+
);
|
|
271
|
+
if (clkOrder > -1) {
|
|
272
|
+
newline = newline.slice(0, off.clock).replace(/\s+$/, "");
|
|
273
|
+
if (!v2 && newline.length < 41) newline = newline.padEnd(41, " ");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
clkOrderPrev = clkOrder;
|
|
277
|
+
const nsat = parseInt((newline.slice(off.nsat) || "0").trim(), 10) || 0;
|
|
278
|
+
if (v2 && nsat > 12) {
|
|
279
|
+
newline = readMoreSat(rawLines, cursor, nsat, newline);
|
|
280
|
+
}
|
|
281
|
+
const sats = [];
|
|
282
|
+
const satIds = [];
|
|
283
|
+
let bad = false;
|
|
284
|
+
let satlist = v2 ? newline.slice(off.satlst, off.satlst + nsat * 3) : "";
|
|
285
|
+
for (let i = 0; i < nsat; i++) {
|
|
286
|
+
const r = readSat(rawLines, cursor, rinexVersion, ntype, ntypeGnss);
|
|
287
|
+
if (!r) {
|
|
288
|
+
bad = true;
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
sats.push(r.sat);
|
|
292
|
+
satIds.push(v2 ? satlist.slice(i * 3, i * 3 + 3) : r.satId);
|
|
293
|
+
}
|
|
294
|
+
if (bad) continue;
|
|
295
|
+
if (!v2) satlist = satIds.join("");
|
|
296
|
+
const fullNew = v2 ? newline : newline.slice(0, 41) + satlist;
|
|
297
|
+
const oldSatList = v2 ? oldline.slice(off.satOld, off.satOld + nsatOld * 3) : oldline.slice(off.satOld);
|
|
298
|
+
const sattbl = [];
|
|
299
|
+
const dup = /* @__PURE__ */ new Set();
|
|
300
|
+
for (let i = 0; i < nsat; i++) {
|
|
301
|
+
const id = satIds[i];
|
|
302
|
+
if (dup.has(id)) {
|
|
303
|
+
bad = true;
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
dup.add(id);
|
|
307
|
+
let found = -1;
|
|
308
|
+
for (let j = 0; j < nsatOld; j++) {
|
|
309
|
+
if (oldSatList.slice(j * 3, j * 3 + 3) === id) {
|
|
310
|
+
found = j;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
sattbl.push(found);
|
|
315
|
+
}
|
|
316
|
+
if (bad) continue;
|
|
317
|
+
out.push(strdiff(oldline, fullNew));
|
|
318
|
+
let clockLine = "";
|
|
319
|
+
if (clkOrder > -1) {
|
|
320
|
+
if (clkOrder > 0) processClock(clk1, clk0, clkOrder);
|
|
321
|
+
clockLine += putClock(clk1.u[clkOrder], clk1.l[clkOrder], clkOrder);
|
|
322
|
+
}
|
|
323
|
+
if (newpsec.length === 5) {
|
|
324
|
+
clockLine += " " + strdiff(oldpsec, newpsec);
|
|
325
|
+
}
|
|
326
|
+
out.push(clockLine);
|
|
327
|
+
const dataLines = buildData(sats, sattbl, dy0, flag0, rinexVersion);
|
|
328
|
+
for (const dl of dataLines) out.push(dl);
|
|
329
|
+
oldline = fullNew;
|
|
330
|
+
nsatOld = nsat;
|
|
331
|
+
clk0 = clk1;
|
|
332
|
+
oldpsec = newpsec;
|
|
333
|
+
dy0 = sats.map((s) => s.data);
|
|
334
|
+
flag0 = sats.map((s) => s.flag);
|
|
335
|
+
}
|
|
336
|
+
return out.join("\n") + "\n";
|
|
337
|
+
}
|
|
338
|
+
function readClock(field, shiftClk, clk1, prevOrder) {
|
|
339
|
+
const c = field.split("");
|
|
340
|
+
if (c[2] !== ".") return -1;
|
|
341
|
+
for (let k = 0; k < shiftClk; k++) c[2 + k] = c[3 + k];
|
|
342
|
+
c[2 + shiftClk] = ".";
|
|
343
|
+
const s = c.join("");
|
|
344
|
+
const m = /(-?\d+)\.(\d+)/.exec(s);
|
|
345
|
+
if (!m) return -1;
|
|
346
|
+
clk1.u[0] = parseInt(m[1], 10);
|
|
347
|
+
clk1.l[0] = parseInt(m[2], 10);
|
|
348
|
+
if (c[0] === "-" || c[1] === "-") clk1.l[0] = -clk1.l[0];
|
|
349
|
+
return Math.min(prevOrder + 1, ARC_ORDER);
|
|
350
|
+
}
|
|
351
|
+
function processClock(clk1, clk0, clkOrder) {
|
|
352
|
+
for (let i = 0; i < clkOrder; i++) {
|
|
353
|
+
clk1.u[i + 1] = clk1.u[i] - clk0.u[i];
|
|
354
|
+
clk1.l[i + 1] = clk1.l[i] - clk0.l[i];
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function takeDiff(py1, py0) {
|
|
358
|
+
py1.order = py0.order;
|
|
359
|
+
if (py1.order < ARC_ORDER) py1.order++;
|
|
360
|
+
for (let k = 0; k < py1.order; k++) {
|
|
361
|
+
py1.u[k + 1] = py1.u[k] - py0.u[k];
|
|
362
|
+
py1.l[k + 1] = py1.l[k] - py0.l[k];
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
function buildData(sats, sattbl, dy0, flag0, rinexVersion) {
|
|
366
|
+
const lines = [];
|
|
367
|
+
for (let i = 0; i < sats.length; i++) {
|
|
368
|
+
const sat = sats[i];
|
|
369
|
+
const i0 = sattbl[i];
|
|
370
|
+
const prevFlag = (i0 >= 0 ? flag0[i0] ?? "" : "").split("");
|
|
371
|
+
let line = "";
|
|
372
|
+
for (let j = 0; j < sat.ntypeRec; j++) {
|
|
373
|
+
const py1 = sat.data[j];
|
|
374
|
+
if (py1.order >= 0) {
|
|
375
|
+
if (i0 < 0 || dy0[i0]?.[j]?.order === -1) {
|
|
376
|
+
py1.order = 0;
|
|
377
|
+
line += `${ARC_ORDER}&`;
|
|
378
|
+
} else {
|
|
379
|
+
takeDiff(py1, dy0[i0][j]);
|
|
380
|
+
if (Math.abs(py1.u[py1.order]) > 1e5) {
|
|
381
|
+
py1.order = 0;
|
|
382
|
+
line += `${ARC_ORDER}&`;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
line += putdiff(py1.u[py1.order], py1.l[py1.order]);
|
|
386
|
+
} else if (i0 >= 0 && rinexVersion === 2) {
|
|
387
|
+
prevFlag[j * 2] = " ";
|
|
388
|
+
prevFlag[j * 2 + 1] = " ";
|
|
389
|
+
}
|
|
390
|
+
line += " ";
|
|
391
|
+
}
|
|
392
|
+
if (i0 < 0 && rinexVersion !== 2) {
|
|
393
|
+
for (const ch of sat.flag) line += ch === " " ? "&" : ch;
|
|
394
|
+
} else {
|
|
395
|
+
line += i0 < 0 ? strdiff("", sat.flag) : strdiff(prevFlag.join(""), sat.flag);
|
|
396
|
+
line = line.replace(/ +$/, "");
|
|
397
|
+
}
|
|
398
|
+
lines.push(line);
|
|
399
|
+
}
|
|
400
|
+
return lines;
|
|
401
|
+
}
|
|
402
|
+
function putEventData(lines, cursor, v2, epochLine, out, ntypeGnss, setNtype) {
|
|
403
|
+
if (v2) {
|
|
404
|
+
out.push("&" + epochLine.slice(1));
|
|
405
|
+
if (epochLine.length > 29) {
|
|
406
|
+
const n = parseInt(epochLine.slice(29), 10) || 0;
|
|
407
|
+
for (let i = 0; i < n; i++) {
|
|
408
|
+
const l = chop(lines[cursor.li++] ?? "");
|
|
409
|
+
out.push(l);
|
|
410
|
+
if (l.slice(60).trimStart().startsWith("# / TYPES OF OBSERV") && l[5] !== " ") {
|
|
411
|
+
setNtype(parseInt(l, 10));
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} else {
|
|
416
|
+
out.push(epochLine.replace(/\s+$/, ""));
|
|
417
|
+
const n = parseInt(epochLine.slice(32), 10) || 0;
|
|
418
|
+
for (let i = 0; i < n; i++) {
|
|
419
|
+
const l = chop(lines[cursor.li++] ?? "");
|
|
420
|
+
out.push(l);
|
|
421
|
+
if (l.slice(60).trimStart().startsWith("SYS / # / OBS TYPES") && l[0] !== " ") {
|
|
422
|
+
ntypeGnss[l[0]] = parseInt(l.slice(3), 10);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function readMoreSat(lines, cursor, n, epochLine) {
|
|
428
|
+
let result = epochLine;
|
|
429
|
+
let remaining = n;
|
|
430
|
+
while (remaining > 12) {
|
|
431
|
+
const l = lines[cursor.li++] ?? "";
|
|
432
|
+
const chopped = chop(l);
|
|
433
|
+
result += chopped[2] === " " ? chopped.slice(32) : chopped;
|
|
434
|
+
remaining -= 12;
|
|
435
|
+
}
|
|
436
|
+
return result;
|
|
437
|
+
}
|
|
438
|
+
function readVersionFull(line) {
|
|
439
|
+
if (line[5] === "2" && line[6] === " ") return 200;
|
|
440
|
+
const d = (c) => c !== void 0 && c >= "0" && c <= "9";
|
|
441
|
+
if (!d(line[5]) || line[6] !== "." || !d(line[7]) || !d(line[8])) return -1;
|
|
442
|
+
return (line.charCodeAt(5) - 48) * 100 + (line.charCodeAt(7) - 48) * 10 + (line.charCodeAt(8) - 48);
|
|
443
|
+
}
|
|
6
444
|
|
|
7
445
|
// src/rinex/format.ts
|
|
8
446
|
function padL(s, w) {
|
|
@@ -1470,6 +1908,7 @@ function writeRinex4ObsBlob(header, epochs, obsTypes) {
|
|
|
1470
1908
|
}
|
|
1471
1909
|
|
|
1472
1910
|
export {
|
|
1911
|
+
writeCrx,
|
|
1473
1912
|
padL,
|
|
1474
1913
|
padR,
|
|
1475
1914
|
fmtF,
|