gnss-js 1.26.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/{chunk-WDUN4BWL.js → chunk-QVNNHACQ.js} +437 -0
- package/dist/index.cjs +438 -0
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/rinex.cjs +438 -0
- package/dist/rinex.d.cts +27 -1
- package/dist/rinex.d.ts +27 -1
- package/dist/rinex.js +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -289,6 +289,7 @@ __export(src_exports, {
|
|
|
289
289
|
updateStreamStats: () => updateStreamStats,
|
|
290
290
|
verifyChecksum: () => verifyChecksum,
|
|
291
291
|
vincenty: () => vincenty,
|
|
292
|
+
writeCrx: () => writeCrx,
|
|
292
293
|
writeModernObsBlob: () => writeModernObsBlob,
|
|
293
294
|
writeRinex2ObsBlob: () => writeRinex2ObsBlob,
|
|
294
295
|
writeRinex4ObsBlob: () => writeRinex4ObsBlob,
|
|
@@ -1319,6 +1320,442 @@ function crxDecompress(prev, field) {
|
|
|
1319
1320
|
};
|
|
1320
1321
|
}
|
|
1321
1322
|
|
|
1323
|
+
// src/rinex/crx-writer.ts
|
|
1324
|
+
var ARC_ORDER = 3;
|
|
1325
|
+
function emptyData() {
|
|
1326
|
+
return { u: [0, 0, 0, 0], l: [0, 0, 0, 0], order: -1 };
|
|
1327
|
+
}
|
|
1328
|
+
function cAtol(s) {
|
|
1329
|
+
let i = 0;
|
|
1330
|
+
while (i < s.length && (s[i] === " " || s[i] === " ")) i++;
|
|
1331
|
+
let sign = 1;
|
|
1332
|
+
if (s[i] === "+" || s[i] === "-") {
|
|
1333
|
+
if (s[i] === "-") sign = -1;
|
|
1334
|
+
i++;
|
|
1335
|
+
}
|
|
1336
|
+
let n = 0;
|
|
1337
|
+
let any = false;
|
|
1338
|
+
while (i < s.length && s[i] >= "0" && s[i] <= "9") {
|
|
1339
|
+
n = n * 10 + (s.charCodeAt(i) - 48);
|
|
1340
|
+
i++;
|
|
1341
|
+
any = true;
|
|
1342
|
+
}
|
|
1343
|
+
return any ? sign * n : 0;
|
|
1344
|
+
}
|
|
1345
|
+
function strdiff(s1, s2) {
|
|
1346
|
+
let ds = "";
|
|
1347
|
+
const n = Math.min(s1.length, s2.length);
|
|
1348
|
+
let i = 0;
|
|
1349
|
+
for (; i < n; i++) {
|
|
1350
|
+
if (s2[i] === s1[i]) ds += " ";
|
|
1351
|
+
else if (s2[i] === " ") ds += "&";
|
|
1352
|
+
else ds += s2[i];
|
|
1353
|
+
}
|
|
1354
|
+
if (s1.length > s2.length) {
|
|
1355
|
+
for (let k = i; k < s1.length; k++) ds += s1[k] === " " ? " " : "&";
|
|
1356
|
+
} else if (s2.length > s1.length) {
|
|
1357
|
+
ds += s2.slice(i);
|
|
1358
|
+
}
|
|
1359
|
+
let end = ds.length;
|
|
1360
|
+
while (end > 0 && ds[end - 1] === " ") end--;
|
|
1361
|
+
return ds.slice(0, end);
|
|
1362
|
+
}
|
|
1363
|
+
function readValue(field14) {
|
|
1364
|
+
const c = field14.padEnd(14, " ").split("");
|
|
1365
|
+
const p7 = c[7];
|
|
1366
|
+
c[10] = c[9];
|
|
1367
|
+
c[9] = c[8];
|
|
1368
|
+
let l = cAtol(c.slice(9, 14).join(""));
|
|
1369
|
+
let u;
|
|
1370
|
+
if (p7 === " ") {
|
|
1371
|
+
u = 0;
|
|
1372
|
+
} else if (p7 === "-") {
|
|
1373
|
+
u = 0;
|
|
1374
|
+
l = -l;
|
|
1375
|
+
} else {
|
|
1376
|
+
c[8] = ".";
|
|
1377
|
+
u = cAtol(c.slice(0, 14).join(""));
|
|
1378
|
+
if (u < 0) l = -l;
|
|
1379
|
+
}
|
|
1380
|
+
return { u, l };
|
|
1381
|
+
}
|
|
1382
|
+
function putdiff(dddu, dddl) {
|
|
1383
|
+
dddu += Math.trunc(dddl / 1e5);
|
|
1384
|
+
dddl %= 1e5;
|
|
1385
|
+
if (dddu < 0 && dddl > 0) {
|
|
1386
|
+
dddu++;
|
|
1387
|
+
dddl -= 1e5;
|
|
1388
|
+
} else if (dddu > 0 && dddl < 0) {
|
|
1389
|
+
dddu--;
|
|
1390
|
+
dddl += 1e5;
|
|
1391
|
+
}
|
|
1392
|
+
if (dddu === 0) return String(dddl);
|
|
1393
|
+
return `${dddu}${String(Math.abs(dddl)).padStart(5, "0")}`;
|
|
1394
|
+
}
|
|
1395
|
+
function putClock(du, dl, cOrder) {
|
|
1396
|
+
du += Math.trunc(dl / 1e8);
|
|
1397
|
+
dl %= 1e8;
|
|
1398
|
+
if (du < 0 && dl > 0) {
|
|
1399
|
+
du++;
|
|
1400
|
+
dl -= 1e8;
|
|
1401
|
+
} else if (du > 0 && dl < 0) {
|
|
1402
|
+
du--;
|
|
1403
|
+
dl += 1e8;
|
|
1404
|
+
}
|
|
1405
|
+
let out = "";
|
|
1406
|
+
if (cOrder === 0) out += `${ARC_ORDER}&`;
|
|
1407
|
+
if (du === 0) out += String(dl);
|
|
1408
|
+
else out += `${du}${String(Math.abs(dl)).padStart(8, "0")}`;
|
|
1409
|
+
return out;
|
|
1410
|
+
}
|
|
1411
|
+
function chop(line) {
|
|
1412
|
+
let end = line.length;
|
|
1413
|
+
if (end > 0 && line[end - 1] === "\r") end--;
|
|
1414
|
+
while (end > 0 && line[end - 1] === " ") end--;
|
|
1415
|
+
return line.slice(0, end);
|
|
1416
|
+
}
|
|
1417
|
+
function readSat(lines, cursor, rinexVersion, ntype, ntypeGnss) {
|
|
1418
|
+
let line = chop(lines[cursor.li++] ?? "");
|
|
1419
|
+
let maxField;
|
|
1420
|
+
let ntypeRec;
|
|
1421
|
+
let firstRec;
|
|
1422
|
+
let satId = "";
|
|
1423
|
+
if (rinexVersion === 2) {
|
|
1424
|
+
maxField = 5;
|
|
1425
|
+
ntypeRec = ntype;
|
|
1426
|
+
firstRec = 0;
|
|
1427
|
+
} else {
|
|
1428
|
+
satId = line.slice(0, 3);
|
|
1429
|
+
const sys = line[0];
|
|
1430
|
+
maxField = ntypeRec = ntypeGnss[sys] ?? -1;
|
|
1431
|
+
if (maxField < 0) return null;
|
|
1432
|
+
firstRec = 3;
|
|
1433
|
+
}
|
|
1434
|
+
const data = [];
|
|
1435
|
+
let flag = "";
|
|
1436
|
+
for (let i = 0; i < ntypeRec; i += maxField) {
|
|
1437
|
+
const nfield = Math.min(ntypeRec - i, maxField);
|
|
1438
|
+
const need = firstRec + 16 * nfield;
|
|
1439
|
+
let body = line;
|
|
1440
|
+
if (body.length < need) body = body.padEnd(need, " ");
|
|
1441
|
+
for (let j = 0; j < nfield; j++) {
|
|
1442
|
+
const p = firstRec + j * 16;
|
|
1443
|
+
const rec = body.slice(p, p + 16);
|
|
1444
|
+
const d = emptyData();
|
|
1445
|
+
if (rec[10] === ".") {
|
|
1446
|
+
flag += rec[14] ?? " ";
|
|
1447
|
+
flag += rec[15] ?? " ";
|
|
1448
|
+
const v = readValue(rec.slice(0, 14));
|
|
1449
|
+
d.u[0] = v.u;
|
|
1450
|
+
d.l[0] = v.l;
|
|
1451
|
+
d.order = 0;
|
|
1452
|
+
} else if (rec.slice(0, 14).trim() === "") {
|
|
1453
|
+
flag += rec[14] ?? " ";
|
|
1454
|
+
flag += rec[15] ?? " ";
|
|
1455
|
+
d.order = -1;
|
|
1456
|
+
} else {
|
|
1457
|
+
return null;
|
|
1458
|
+
}
|
|
1459
|
+
data.push(d);
|
|
1460
|
+
}
|
|
1461
|
+
if (i + maxField < ntypeRec) {
|
|
1462
|
+
line = chop(lines[cursor.li++] ?? "");
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
return { sat: { data, flag, ntypeRec }, satId };
|
|
1466
|
+
}
|
|
1467
|
+
var MONTHS = [
|
|
1468
|
+
"Jan",
|
|
1469
|
+
"Feb",
|
|
1470
|
+
"Mar",
|
|
1471
|
+
"Apr",
|
|
1472
|
+
"May",
|
|
1473
|
+
"Jun",
|
|
1474
|
+
"Jul",
|
|
1475
|
+
"Aug",
|
|
1476
|
+
"Sep",
|
|
1477
|
+
"Oct",
|
|
1478
|
+
"Nov",
|
|
1479
|
+
"Dec"
|
|
1480
|
+
];
|
|
1481
|
+
function crinexDate() {
|
|
1482
|
+
const d = /* @__PURE__ */ new Date();
|
|
1483
|
+
const dd = String(d.getUTCDate()).padStart(2, "0");
|
|
1484
|
+
const mon = MONTHS[d.getUTCMonth()];
|
|
1485
|
+
const yy = String(d.getUTCFullYear() % 100).padStart(2, "0");
|
|
1486
|
+
const hh = String(d.getUTCHours()).padStart(2, "0");
|
|
1487
|
+
const mm = String(d.getUTCMinutes()).padStart(2, "0");
|
|
1488
|
+
return `${dd}-${mon}-${yy} ${hh}:${mm}`;
|
|
1489
|
+
}
|
|
1490
|
+
function writeCrx(rinexText, opts = {}) {
|
|
1491
|
+
const rawLines = rinexText.split("\n");
|
|
1492
|
+
const cursor = { li: 0 };
|
|
1493
|
+
const out = [];
|
|
1494
|
+
const firstLine = chop(rawLines[cursor.li++] ?? "");
|
|
1495
|
+
if (firstLine.slice(60, 80) !== "RINEX VERSION / TYPE" || firstLine[20] !== "O") {
|
|
1496
|
+
throw new Error("writeCrx: not a RINEX observation file");
|
|
1497
|
+
}
|
|
1498
|
+
const rinexVersion = parseInt(firstLine, 10);
|
|
1499
|
+
const rinexVersionFull = readVersionFull(firstLine);
|
|
1500
|
+
if (rinexVersionFull < 0) throw new Error("writeCrx: invalid RINEX version");
|
|
1501
|
+
const crxVersion = rinexVersionFull >= 402 ? "3.1" : rinexVersion === 2 ? "1.0" : "3.0";
|
|
1502
|
+
out.push(
|
|
1503
|
+
`${crxVersion.padEnd(20)}${"COMPACT RINEX FORMAT".padEnd(40)}${"CRINEX VERS / TYPE".padEnd(20)}`
|
|
1504
|
+
);
|
|
1505
|
+
const prog = (opts.prog ?? "gnss-js writeCrx").slice(0, 40);
|
|
1506
|
+
const date = opts.date ?? crinexDate();
|
|
1507
|
+
out.push(`${prog.padEnd(40)}${date.padEnd(20)}CRINEX PROG / DATE`);
|
|
1508
|
+
out.push(firstLine);
|
|
1509
|
+
let ntype = 0;
|
|
1510
|
+
const ntypeGnss = {};
|
|
1511
|
+
let line;
|
|
1512
|
+
do {
|
|
1513
|
+
line = chop(rawLines[cursor.li++] ?? "");
|
|
1514
|
+
out.push(line);
|
|
1515
|
+
const label2 = line.slice(60).trimStart();
|
|
1516
|
+
if (label2.startsWith("# / TYPES OF OBSERV") && line[5] !== " ") {
|
|
1517
|
+
ntype = parseInt(line, 10);
|
|
1518
|
+
} else if (label2.startsWith("SYS / # / OBS TYPES") && line[0] !== " ") {
|
|
1519
|
+
ntypeGnss[line[0]] = parseInt(line.slice(3), 10);
|
|
1520
|
+
}
|
|
1521
|
+
if (cursor.li >= rawLines.length) break;
|
|
1522
|
+
} while (!line.slice(60).trimStart().startsWith("END OF HEADER"));
|
|
1523
|
+
const v2 = rinexVersion === 2;
|
|
1524
|
+
const off = v2 ? { event: 28, nsat: 29, satlst: 32, clock: 68, satOld: 32, shiftClk: 1 } : {
|
|
1525
|
+
event: 31,
|
|
1526
|
+
nsat: 32,
|
|
1527
|
+
satlst: 41,
|
|
1528
|
+
clock: 41,
|
|
1529
|
+
satOld: 41,
|
|
1530
|
+
shiftClk: 4,
|
|
1531
|
+
psec: 57
|
|
1532
|
+
};
|
|
1533
|
+
let oldline = "&";
|
|
1534
|
+
let nsatOld = 0;
|
|
1535
|
+
let clk0 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
1536
|
+
let dy0 = [];
|
|
1537
|
+
let flag0 = [];
|
|
1538
|
+
let oldpsec = "";
|
|
1539
|
+
let clkOrderPrev = -1;
|
|
1540
|
+
const resetArcs = () => {
|
|
1541
|
+
oldline = "&";
|
|
1542
|
+
nsatOld = 0;
|
|
1543
|
+
clkOrderPrev = -1;
|
|
1544
|
+
};
|
|
1545
|
+
for (; ; ) {
|
|
1546
|
+
if (cursor.li >= rawLines.length) break;
|
|
1547
|
+
let epoch = rawLines[cursor.li];
|
|
1548
|
+
if (epoch === void 0) break;
|
|
1549
|
+
if (epoch === "" && cursor.li === rawLines.length - 1) break;
|
|
1550
|
+
cursor.li++;
|
|
1551
|
+
epoch = chop(epoch);
|
|
1552
|
+
if (epoch === "") continue;
|
|
1553
|
+
let newline;
|
|
1554
|
+
if (v2) {
|
|
1555
|
+
newline = epoch;
|
|
1556
|
+
} else {
|
|
1557
|
+
newline = epoch.length < 41 ? epoch.padEnd(41, " ") : epoch;
|
|
1558
|
+
}
|
|
1559
|
+
const eventFlag = parseInt(newline[off.event] ?? "0", 10) || 0;
|
|
1560
|
+
if (eventFlag > 1) {
|
|
1561
|
+
putEventData(rawLines, cursor, v2, newline, out, ntypeGnss, (n) => {
|
|
1562
|
+
ntype = n;
|
|
1563
|
+
});
|
|
1564
|
+
resetArcs();
|
|
1565
|
+
clk0 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
1566
|
+
dy0 = [];
|
|
1567
|
+
flag0 = [];
|
|
1568
|
+
continue;
|
|
1569
|
+
}
|
|
1570
|
+
let newpsec = "";
|
|
1571
|
+
if (rinexVersionFull >= 402 && newline.length === 62) {
|
|
1572
|
+
const psec = newline.slice(off.psec, off.psec + 5);
|
|
1573
|
+
if (/^\d{5}$/.test(psec)) newpsec = psec;
|
|
1574
|
+
newline = newline.slice(0, off.psec).replace(/\s+$/, "");
|
|
1575
|
+
}
|
|
1576
|
+
let clkOrder = -1;
|
|
1577
|
+
const clk1 = { u: [0, 0, 0, 0], l: [0, 0, 0, 0] };
|
|
1578
|
+
if (newline.length > off.clock) {
|
|
1579
|
+
clkOrder = readClock(
|
|
1580
|
+
newline.slice(off.clock),
|
|
1581
|
+
off.shiftClk,
|
|
1582
|
+
clk1,
|
|
1583
|
+
clkOrderPrev
|
|
1584
|
+
);
|
|
1585
|
+
if (clkOrder > -1) {
|
|
1586
|
+
newline = newline.slice(0, off.clock).replace(/\s+$/, "");
|
|
1587
|
+
if (!v2 && newline.length < 41) newline = newline.padEnd(41, " ");
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
clkOrderPrev = clkOrder;
|
|
1591
|
+
const nsat = parseInt((newline.slice(off.nsat) || "0").trim(), 10) || 0;
|
|
1592
|
+
if (v2 && nsat > 12) {
|
|
1593
|
+
newline = readMoreSat(rawLines, cursor, nsat, newline);
|
|
1594
|
+
}
|
|
1595
|
+
const sats = [];
|
|
1596
|
+
const satIds = [];
|
|
1597
|
+
let bad = false;
|
|
1598
|
+
let satlist = v2 ? newline.slice(off.satlst, off.satlst + nsat * 3) : "";
|
|
1599
|
+
for (let i = 0; i < nsat; i++) {
|
|
1600
|
+
const r = readSat(rawLines, cursor, rinexVersion, ntype, ntypeGnss);
|
|
1601
|
+
if (!r) {
|
|
1602
|
+
bad = true;
|
|
1603
|
+
break;
|
|
1604
|
+
}
|
|
1605
|
+
sats.push(r.sat);
|
|
1606
|
+
satIds.push(v2 ? satlist.slice(i * 3, i * 3 + 3) : r.satId);
|
|
1607
|
+
}
|
|
1608
|
+
if (bad) continue;
|
|
1609
|
+
if (!v2) satlist = satIds.join("");
|
|
1610
|
+
const fullNew = v2 ? newline : newline.slice(0, 41) + satlist;
|
|
1611
|
+
const oldSatList = v2 ? oldline.slice(off.satOld, off.satOld + nsatOld * 3) : oldline.slice(off.satOld);
|
|
1612
|
+
const sattbl = [];
|
|
1613
|
+
const dup = /* @__PURE__ */ new Set();
|
|
1614
|
+
for (let i = 0; i < nsat; i++) {
|
|
1615
|
+
const id = satIds[i];
|
|
1616
|
+
if (dup.has(id)) {
|
|
1617
|
+
bad = true;
|
|
1618
|
+
break;
|
|
1619
|
+
}
|
|
1620
|
+
dup.add(id);
|
|
1621
|
+
let found = -1;
|
|
1622
|
+
for (let j = 0; j < nsatOld; j++) {
|
|
1623
|
+
if (oldSatList.slice(j * 3, j * 3 + 3) === id) {
|
|
1624
|
+
found = j;
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
sattbl.push(found);
|
|
1629
|
+
}
|
|
1630
|
+
if (bad) continue;
|
|
1631
|
+
out.push(strdiff(oldline, fullNew));
|
|
1632
|
+
let clockLine = "";
|
|
1633
|
+
if (clkOrder > -1) {
|
|
1634
|
+
if (clkOrder > 0) processClock(clk1, clk0, clkOrder);
|
|
1635
|
+
clockLine += putClock(clk1.u[clkOrder], clk1.l[clkOrder], clkOrder);
|
|
1636
|
+
}
|
|
1637
|
+
if (newpsec.length === 5) {
|
|
1638
|
+
clockLine += " " + strdiff(oldpsec, newpsec);
|
|
1639
|
+
}
|
|
1640
|
+
out.push(clockLine);
|
|
1641
|
+
const dataLines = buildData(sats, sattbl, dy0, flag0, rinexVersion);
|
|
1642
|
+
for (const dl of dataLines) out.push(dl);
|
|
1643
|
+
oldline = fullNew;
|
|
1644
|
+
nsatOld = nsat;
|
|
1645
|
+
clk0 = clk1;
|
|
1646
|
+
oldpsec = newpsec;
|
|
1647
|
+
dy0 = sats.map((s) => s.data);
|
|
1648
|
+
flag0 = sats.map((s) => s.flag);
|
|
1649
|
+
}
|
|
1650
|
+
return out.join("\n") + "\n";
|
|
1651
|
+
}
|
|
1652
|
+
function readClock(field, shiftClk, clk1, prevOrder) {
|
|
1653
|
+
const c = field.split("");
|
|
1654
|
+
if (c[2] !== ".") return -1;
|
|
1655
|
+
for (let k = 0; k < shiftClk; k++) c[2 + k] = c[3 + k];
|
|
1656
|
+
c[2 + shiftClk] = ".";
|
|
1657
|
+
const s = c.join("");
|
|
1658
|
+
const m = /(-?\d+)\.(\d+)/.exec(s);
|
|
1659
|
+
if (!m) return -1;
|
|
1660
|
+
clk1.u[0] = parseInt(m[1], 10);
|
|
1661
|
+
clk1.l[0] = parseInt(m[2], 10);
|
|
1662
|
+
if (c[0] === "-" || c[1] === "-") clk1.l[0] = -clk1.l[0];
|
|
1663
|
+
return Math.min(prevOrder + 1, ARC_ORDER);
|
|
1664
|
+
}
|
|
1665
|
+
function processClock(clk1, clk0, clkOrder) {
|
|
1666
|
+
for (let i = 0; i < clkOrder; i++) {
|
|
1667
|
+
clk1.u[i + 1] = clk1.u[i] - clk0.u[i];
|
|
1668
|
+
clk1.l[i + 1] = clk1.l[i] - clk0.l[i];
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
function takeDiff(py1, py0) {
|
|
1672
|
+
py1.order = py0.order;
|
|
1673
|
+
if (py1.order < ARC_ORDER) py1.order++;
|
|
1674
|
+
for (let k = 0; k < py1.order; k++) {
|
|
1675
|
+
py1.u[k + 1] = py1.u[k] - py0.u[k];
|
|
1676
|
+
py1.l[k + 1] = py1.l[k] - py0.l[k];
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
function buildData(sats, sattbl, dy0, flag0, rinexVersion) {
|
|
1680
|
+
const lines = [];
|
|
1681
|
+
for (let i = 0; i < sats.length; i++) {
|
|
1682
|
+
const sat = sats[i];
|
|
1683
|
+
const i0 = sattbl[i];
|
|
1684
|
+
const prevFlag = (i0 >= 0 ? flag0[i0] ?? "" : "").split("");
|
|
1685
|
+
let line = "";
|
|
1686
|
+
for (let j = 0; j < sat.ntypeRec; j++) {
|
|
1687
|
+
const py1 = sat.data[j];
|
|
1688
|
+
if (py1.order >= 0) {
|
|
1689
|
+
if (i0 < 0 || dy0[i0]?.[j]?.order === -1) {
|
|
1690
|
+
py1.order = 0;
|
|
1691
|
+
line += `${ARC_ORDER}&`;
|
|
1692
|
+
} else {
|
|
1693
|
+
takeDiff(py1, dy0[i0][j]);
|
|
1694
|
+
if (Math.abs(py1.u[py1.order]) > 1e5) {
|
|
1695
|
+
py1.order = 0;
|
|
1696
|
+
line += `${ARC_ORDER}&`;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
line += putdiff(py1.u[py1.order], py1.l[py1.order]);
|
|
1700
|
+
} else if (i0 >= 0 && rinexVersion === 2) {
|
|
1701
|
+
prevFlag[j * 2] = " ";
|
|
1702
|
+
prevFlag[j * 2 + 1] = " ";
|
|
1703
|
+
}
|
|
1704
|
+
line += " ";
|
|
1705
|
+
}
|
|
1706
|
+
if (i0 < 0 && rinexVersion !== 2) {
|
|
1707
|
+
for (const ch of sat.flag) line += ch === " " ? "&" : ch;
|
|
1708
|
+
} else {
|
|
1709
|
+
line += i0 < 0 ? strdiff("", sat.flag) : strdiff(prevFlag.join(""), sat.flag);
|
|
1710
|
+
line = line.replace(/ +$/, "");
|
|
1711
|
+
}
|
|
1712
|
+
lines.push(line);
|
|
1713
|
+
}
|
|
1714
|
+
return lines;
|
|
1715
|
+
}
|
|
1716
|
+
function putEventData(lines, cursor, v2, epochLine, out, ntypeGnss, setNtype) {
|
|
1717
|
+
if (v2) {
|
|
1718
|
+
out.push("&" + epochLine.slice(1));
|
|
1719
|
+
if (epochLine.length > 29) {
|
|
1720
|
+
const n = parseInt(epochLine.slice(29), 10) || 0;
|
|
1721
|
+
for (let i = 0; i < n; i++) {
|
|
1722
|
+
const l = chop(lines[cursor.li++] ?? "");
|
|
1723
|
+
out.push(l);
|
|
1724
|
+
if (l.slice(60).trimStart().startsWith("# / TYPES OF OBSERV") && l[5] !== " ") {
|
|
1725
|
+
setNtype(parseInt(l, 10));
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
} else {
|
|
1730
|
+
out.push(epochLine.replace(/\s+$/, ""));
|
|
1731
|
+
const n = parseInt(epochLine.slice(32), 10) || 0;
|
|
1732
|
+
for (let i = 0; i < n; i++) {
|
|
1733
|
+
const l = chop(lines[cursor.li++] ?? "");
|
|
1734
|
+
out.push(l);
|
|
1735
|
+
if (l.slice(60).trimStart().startsWith("SYS / # / OBS TYPES") && l[0] !== " ") {
|
|
1736
|
+
ntypeGnss[l[0]] = parseInt(l.slice(3), 10);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
function readMoreSat(lines, cursor, n, epochLine) {
|
|
1742
|
+
let result = epochLine;
|
|
1743
|
+
let remaining = n;
|
|
1744
|
+
while (remaining > 12) {
|
|
1745
|
+
const l = lines[cursor.li++] ?? "";
|
|
1746
|
+
const chopped = chop(l);
|
|
1747
|
+
result += chopped[2] === " " ? chopped.slice(32) : chopped;
|
|
1748
|
+
remaining -= 12;
|
|
1749
|
+
}
|
|
1750
|
+
return result;
|
|
1751
|
+
}
|
|
1752
|
+
function readVersionFull(line) {
|
|
1753
|
+
if (line[5] === "2" && line[6] === " ") return 200;
|
|
1754
|
+
const d = (c) => c !== void 0 && c >= "0" && c <= "9";
|
|
1755
|
+
if (!d(line[5]) || line[6] !== "." || !d(line[7]) || !d(line[8])) return -1;
|
|
1756
|
+
return (line.charCodeAt(5) - 48) * 100 + (line.charCodeAt(7) - 48) * 10 + (line.charCodeAt(8) - 48);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1322
1759
|
// src/rinex/format.ts
|
|
1323
1760
|
function padL(s, w) {
|
|
1324
1761
|
return s.length >= w ? s.slice(0, w) : s + " ".repeat(w - s.length);
|
|
@@ -14662,6 +15099,7 @@ function computePsdDb(centerMHz, halfSpanChips, numPoints, psdFn, f0 = 1023e3, f
|
|
|
14662
15099
|
updateStreamStats,
|
|
14663
15100
|
verifyChecksum,
|
|
14664
15101
|
vincenty,
|
|
15102
|
+
writeCrx,
|
|
14665
15103
|
writeModernObsBlob,
|
|
14666
15104
|
writeRinex2ObsBlob,
|
|
14667
15105
|
writeRinex4ObsBlob,
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as ARC_GAP_FACTOR, B as BAND_LABELS, a as BDS_SATELLITES, b as BdsSat
|
|
|
4
4
|
export { Scale, getBdsTime, getDateFromBdsTime, getDateFromDayOfWeek, getDateFromDayOfYear, getDateFromGalTime, getDateFromGloN, getDateFromGpsData, getDateFromGpsTime, getDateFromHourCode, getDateFromJulianDate, getDateFromMJD, getDateFromMJD2000, getDateFromRINEX, getDateFromTai, getDateFromTimeOfDay, getDateFromTt, getDateFromUnixTime, getDateFromUtc, getDayOfWeek, getDayOfYear, getGalTime, getGloN4, getGloNA, getGpsLeap, getGpsTime, getHourCode, getHoursFromTimeDifference, getJulianDate, getLeap, getMJD, getMJD2000, getMinutesFromTimeDifference, getNtpTime, getRINEX, getSecondsFromTimeDifference, getTaiDate, getTimeDifference, getTimeDifferenceFromDays, getTimeDifferenceFromHours, getTimeDifferenceFromMinutes, getTimeDifferenceFromObject, getTimeDifferenceFromSeconds, getTimeOfDay, getTimeOfWeek, getTotalDaysFromTimeDifference, getTtDate, getUnixTime, getUtcDate, getWeekNumber, getWeekOfYear } from './time.cjs';
|
|
5
5
|
export { deg2dms, deg2rad, euclidean3D, geodeticToGeohash, geodeticToMaidenhead, geodeticToUtm, greatCircleMidpoint, horizonDistance, rad2deg, rhumbLine, vincenty } from './coordinates.cjs';
|
|
6
6
|
export { c as clampUnit, e as ecefToGeodetic, g as geodeticToEcef, a as getAer, b as getEnuDifference } from './ecef-CF0uAysr.cjs';
|
|
7
|
-
export { CompactEpoch, CrxField, DiffState, EMPTY_WARNINGS, Nav4Input, RinexWarning, RinexWarnings, Sp3File, Sp3Sample, WarningAccumulator, WarningSeverity, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob } from './rinex.cjs';
|
|
7
|
+
export { CompactEpoch, CrxField, DiffState, EMPTY_WARNINGS, Nav4Input, RinexWarning, RinexWarnings, Sp3File, Sp3Sample, WarningAccumulator, WarningSeverity, WriteCrxOptions, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeCrx, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob } from './rinex.cjs';
|
|
8
8
|
export { E as EpochSummary, P as ParseOptions, R as RinexHeader, a as RinexResult, b as RinexStats, S as SYSTEM_ORDER, c as SatObsCallback, p as parseRinexStream, s as systemCmp, d as systemName } from './parser-JPjjFgeP.cjs';
|
|
9
9
|
export { C as CnavEphemeris, E as Ephemeris, G as GlonassEphemeris, K as KeplerEphemeris, N as NavHeader, a as NavResult, R as RinexCnavEphemeris, p as parseNavFile } from './nav-DImXUdbp.cjs';
|
|
10
10
|
export { I as IonexGrid, p as parseIonex } from './ionex-DaW5x9nq.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { A as ARC_GAP_FACTOR, B as BAND_LABELS, a as BDS_SATELLITES, b as BdsSat
|
|
|
4
4
|
export { Scale, getBdsTime, getDateFromBdsTime, getDateFromDayOfWeek, getDateFromDayOfYear, getDateFromGalTime, getDateFromGloN, getDateFromGpsData, getDateFromGpsTime, getDateFromHourCode, getDateFromJulianDate, getDateFromMJD, getDateFromMJD2000, getDateFromRINEX, getDateFromTai, getDateFromTimeOfDay, getDateFromTt, getDateFromUnixTime, getDateFromUtc, getDayOfWeek, getDayOfYear, getGalTime, getGloN4, getGloNA, getGpsLeap, getGpsTime, getHourCode, getHoursFromTimeDifference, getJulianDate, getLeap, getMJD, getMJD2000, getMinutesFromTimeDifference, getNtpTime, getRINEX, getSecondsFromTimeDifference, getTaiDate, getTimeDifference, getTimeDifferenceFromDays, getTimeDifferenceFromHours, getTimeDifferenceFromMinutes, getTimeDifferenceFromObject, getTimeDifferenceFromSeconds, getTimeOfDay, getTimeOfWeek, getTotalDaysFromTimeDifference, getTtDate, getUnixTime, getUtcDate, getWeekNumber, getWeekOfYear } from './time.js';
|
|
5
5
|
export { deg2dms, deg2rad, euclidean3D, geodeticToGeohash, geodeticToMaidenhead, geodeticToUtm, greatCircleMidpoint, horizonDistance, rad2deg, rhumbLine, vincenty } from './coordinates.js';
|
|
6
6
|
export { c as clampUnit, e as ecefToGeodetic, g as geodeticToEcef, a as getAer, b as getEnuDifference } from './ecef-CF0uAysr.js';
|
|
7
|
-
export { CompactEpoch, CrxField, DiffState, EMPTY_WARNINGS, Nav4Input, RinexWarning, RinexWarnings, Sp3File, Sp3Sample, WarningAccumulator, WarningSeverity, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob } from './rinex.js';
|
|
7
|
+
export { CompactEpoch, CrxField, DiffState, EMPTY_WARNINGS, Nav4Input, RinexWarning, RinexWarnings, Sp3File, Sp3Sample, WarningAccumulator, WarningSeverity, WriteCrxOptions, createGzipLineSink, crxDecompress, crxRepair, fmtD, fmtF, hdrLine, padL, padR, parseCrxDataLine, parseSp3, sp3Position, stationHeaderLines, writeCrx, writeModernObsBlob, writeRinex2ObsBlob, writeRinex4ObsBlob, writeRinexNav, writeRinexNav4, writeRinexObsBlob } from './rinex.js';
|
|
8
8
|
export { E as EpochSummary, P as ParseOptions, R as RinexHeader, a as RinexResult, b as RinexStats, S as SYSTEM_ORDER, c as SatObsCallback, p as parseRinexStream, s as systemCmp, d as systemName } from './parser-JPjjFgeP.js';
|
|
9
9
|
export { C as CnavEphemeris, E as Ephemeris, G as GlonassEphemeris, K as KeplerEphemeris, N as NavHeader, a as NavResult, R as RinexCnavEphemeris, p as parseNavFile } from './nav-DImXUdbp.js';
|
|
10
10
|
export { I as IonexGrid, p as parseIonex } from './ionex-DaW5x9nq.js';
|
package/dist/index.js
CHANGED
|
@@ -204,13 +204,14 @@ import {
|
|
|
204
204
|
parseSp3,
|
|
205
205
|
sp3Position,
|
|
206
206
|
stationHeaderLines,
|
|
207
|
+
writeCrx,
|
|
207
208
|
writeModernObsBlob,
|
|
208
209
|
writeRinex2ObsBlob,
|
|
209
210
|
writeRinex4ObsBlob,
|
|
210
211
|
writeRinexNav,
|
|
211
212
|
writeRinexNav4,
|
|
212
213
|
writeRinexObsBlob
|
|
213
|
-
} from "./chunk-
|
|
214
|
+
} from "./chunk-QVNNHACQ.js";
|
|
214
215
|
import "./chunk-726LQBGM.js";
|
|
215
216
|
import "./chunk-IQ5OIMQD.js";
|
|
216
217
|
import {
|
|
@@ -593,6 +594,7 @@ export {
|
|
|
593
594
|
updateStreamStats,
|
|
594
595
|
verifyChecksum,
|
|
595
596
|
vincenty,
|
|
597
|
+
writeCrx,
|
|
596
598
|
writeModernObsBlob,
|
|
597
599
|
writeRinex2ObsBlob,
|
|
598
600
|
writeRinex4ObsBlob,
|