gnss-js 1.27.0 → 1.29.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.
@@ -1417,122 +1417,6 @@ function parseIonex(text) {
1417
1417
  return { epochs, lats, lons, maps };
1418
1418
  }
1419
1419
 
1420
- // src/rinex/sp3.ts
1421
- var BAD_CLOCK = 999999.999999;
1422
- function parseSp3(text) {
1423
- const lines = text.split("\n");
1424
- const epochs = [];
1425
- const satellites = {};
1426
- let version = "";
1427
- let intervalSec = 0;
1428
- let timeSystem = "GPS";
1429
- let timeSystemSet = false;
1430
- let epochIdx = -1;
1431
- for (const line of lines) {
1432
- if (!version && line.startsWith("#") && line.charAt(1) !== "#") {
1433
- version = line.charAt(1);
1434
- }
1435
- if (line.startsWith("##")) {
1436
- const f = line.slice(2).trim().split(/\s+/);
1437
- intervalSec = Number(f[2]) || 0;
1438
- } else if (line.startsWith("%c") && !timeSystemSet) {
1439
- const sys = line.slice(9, 12).trim();
1440
- if (sys && !/^c+$/.test(sys)) {
1441
- timeSystem = sys;
1442
- timeSystemSet = true;
1443
- }
1444
- } else if (line.startsWith("*")) {
1445
- const f = line.slice(1).trim().split(/\s+/).map(Number);
1446
- if (f.length >= 6 && f.every(Number.isFinite)) {
1447
- const sec = f[5];
1448
- epochs.push(
1449
- Date.UTC(
1450
- f[0],
1451
- f[1] - 1,
1452
- f[2],
1453
- f[3],
1454
- f[4],
1455
- Math.floor(sec),
1456
- Math.round(sec % 1 * 1e3)
1457
- )
1458
- );
1459
- epochIdx++;
1460
- }
1461
- } else if (line.startsWith("P") && epochIdx >= 0) {
1462
- const prn = line.slice(1, 4).replace(/\s/g, "0");
1463
- const f = line.slice(4).trim().split(/\s+/).map(Number);
1464
- if (f.length < 3) continue;
1465
- const [xKm, yKm, zKm] = f;
1466
- let arr = satellites[prn];
1467
- if (!arr) satellites[prn] = arr = [];
1468
- while (arr.length < epochIdx) arr.push(null);
1469
- if (xKm === 0 && yKm === 0 && zKm === 0) {
1470
- arr.push(null);
1471
- continue;
1472
- }
1473
- const clkUs = f[3];
1474
- arr.push({
1475
- x: xKm * 1e3,
1476
- y: yKm * 1e3,
1477
- z: zKm * 1e3,
1478
- clk: clkUs !== void 0 && Math.abs(clkUs) < BAD_CLOCK ? clkUs * 1e-6 : null
1479
- });
1480
- }
1481
- }
1482
- for (const arr of Object.values(satellites)) {
1483
- while (arr.length < epochs.length) arr.push(null);
1484
- }
1485
- return { version, epochs, intervalSec, timeSystem, satellites };
1486
- }
1487
- function sp3Position(sp3, prn, tMs, order = 9) {
1488
- const samples = sp3.satellites[prn];
1489
- const { epochs } = sp3;
1490
- const n = epochs.length;
1491
- if (!samples || n < order) return null;
1492
- if (tMs < epochs[0] || tMs > epochs[n - 1]) return null;
1493
- let lo = 0;
1494
- let hi = n - 1;
1495
- while (lo < hi) {
1496
- const mid = lo + hi + 1 >> 1;
1497
- if (epochs[mid] <= tMs) lo = mid;
1498
- else hi = mid - 1;
1499
- }
1500
- let start = lo - (order >> 1) + (order % 2 === 0 ? 1 : 0);
1501
- start = Math.max(0, Math.min(n - order, start));
1502
- for (let i = start; i < start + order; i++) {
1503
- if (!samples[i]) return null;
1504
- }
1505
- const t0 = epochs[start];
1506
- const t = (tMs - t0) / 1e3;
1507
- let x = 0;
1508
- let y = 0;
1509
- let z = 0;
1510
- for (let i = 0; i < order; i++) {
1511
- const ti = (epochs[start + i] - t0) / 1e3;
1512
- let w = 1;
1513
- for (let j = 0; j < order; j++) {
1514
- if (j === i) continue;
1515
- const tj = (epochs[start + j] - t0) / 1e3;
1516
- w *= (t - tj) / (ti - tj);
1517
- }
1518
- const s = samples[start + i];
1519
- x += w * s.x;
1520
- y += w * s.y;
1521
- z += w * s.z;
1522
- }
1523
- let clk = null;
1524
- const a = samples[lo];
1525
- const b = samples[Math.min(lo + 1, n - 1)];
1526
- if (a?.clk != null && b?.clk != null) {
1527
- const span = epochs[Math.min(lo + 1, n - 1)] - epochs[lo];
1528
- const f = span > 0 ? (tMs - epochs[lo]) / span : 0;
1529
- clk = a.clk * (1 - f) + b.clk * f;
1530
- } else if (a?.clk != null) {
1531
- clk = a.clk;
1532
- }
1533
- return { x, y, z, clk };
1534
- }
1535
-
1536
1420
  // src/rinex/obs-writer-common.ts
1537
1421
  function createGzipLineSink() {
1538
1422
  const encoder = new TextEncoder();
@@ -1920,8 +1804,6 @@ export {
1920
1804
  writeRinexNav,
1921
1805
  writeRinexNav4,
1922
1806
  parseIonex,
1923
- parseSp3,
1924
- sp3Position,
1925
1807
  createGzipLineSink,
1926
1808
  stationHeaderLines,
1927
1809
  writeRinexObsBlob,