gnss-js 1.21.0 → 1.22.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-DLXTTHRK.js → chunk-MCAVU3XL.js} +118 -9
- package/dist/{chunk-K3V3NHWL.js → chunk-PZNVFCKJ.js} +25 -766
- package/dist/chunk-VTX3VCL4.js +769 -0
- package/dist/index.cjs +1397 -1295
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/dist/sbf.js +2 -1
- package/dist/ubx.cjs +809 -10
- package/dist/ubx.d.cts +111 -1
- package/dist/ubx.d.ts +111 -1
- package/dist/ubx.js +6 -1
- package/package.json +1 -1
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BdsAssembler,
|
|
3
|
+
GalFnavAssembler,
|
|
4
|
+
GalInavAssembler,
|
|
5
|
+
GloStringAssembler,
|
|
6
|
+
bdsSubframeParityOk,
|
|
7
|
+
galFnavPageCrcOk,
|
|
8
|
+
galInavPageCrcOk,
|
|
9
|
+
testGloString
|
|
10
|
+
} from "./chunk-VTX3VCL4.js";
|
|
1
11
|
import {
|
|
2
12
|
CnavAssembler,
|
|
3
|
-
GPS_PI,
|
|
4
13
|
cnavCrcOk,
|
|
5
14
|
crc24q,
|
|
6
15
|
getBitS,
|
|
7
16
|
getBitU
|
|
8
17
|
} from "./chunk-WZDFZ76K.js";
|
|
9
18
|
import {
|
|
10
|
-
getGpsLeap
|
|
11
|
-
getUtcDate
|
|
19
|
+
getGpsLeap
|
|
12
20
|
} from "./chunk-HVXYFUCB.js";
|
|
13
21
|
|
|
14
22
|
// src/sbf/frame.ts
|
|
@@ -449,314 +457,6 @@ function parseSbfCnav(data) {
|
|
|
449
457
|
return { ephemerides, badCrc, messages };
|
|
450
458
|
}
|
|
451
459
|
|
|
452
|
-
// src/navbits/gal.ts
|
|
453
|
-
var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
|
|
454
|
-
var SEC_PER_WEEK2 = 7 * 86400;
|
|
455
|
-
var HALF_WEEK = 302400;
|
|
456
|
-
var GST_GPS_WEEK_OFFSET = 1024;
|
|
457
|
-
function galInavPageCrcOk(page) {
|
|
458
|
-
if (page.length < 28) return false;
|
|
459
|
-
return crc24q(page, 196) === getBitU(page, 196, 24);
|
|
460
|
-
}
|
|
461
|
-
function galFnavPageCrcOk(page) {
|
|
462
|
-
if (page.length < 30) return false;
|
|
463
|
-
return crc24q(page, 214) === getBitU(page, 214, 24);
|
|
464
|
-
}
|
|
465
|
-
function gpsDate(week, sec) {
|
|
466
|
-
return new Date(GPS_EPOCH_MS2 + (week * SEC_PER_WEEK2 + sec) * 1e3);
|
|
467
|
-
}
|
|
468
|
-
function weekOfToe(week, tow, toe) {
|
|
469
|
-
if (toe - tow > HALF_WEEK) return week - 1;
|
|
470
|
-
if (toe - tow < -HALF_WEEK) return week + 1;
|
|
471
|
-
return week;
|
|
472
|
-
}
|
|
473
|
-
var two2 = (n) => String(n).padStart(2, "0");
|
|
474
|
-
function decodeGalInavWords(words) {
|
|
475
|
-
if (words.length < 96) return null;
|
|
476
|
-
const b = words;
|
|
477
|
-
let i = 128;
|
|
478
|
-
const type1 = getBitU(b, i, 6);
|
|
479
|
-
i += 6;
|
|
480
|
-
const iodNav1 = getBitU(b, i, 10);
|
|
481
|
-
i += 10;
|
|
482
|
-
const toes = getBitU(b, i, 14) * 60;
|
|
483
|
-
i += 14;
|
|
484
|
-
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
485
|
-
i += 32;
|
|
486
|
-
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
487
|
-
i += 32;
|
|
488
|
-
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
489
|
-
i = 128 * 2;
|
|
490
|
-
const type2 = getBitU(b, i, 6);
|
|
491
|
-
i += 6;
|
|
492
|
-
const iodNav2 = getBitU(b, i, 10);
|
|
493
|
-
i += 10;
|
|
494
|
-
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
495
|
-
i += 32;
|
|
496
|
-
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
497
|
-
i += 32;
|
|
498
|
-
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
499
|
-
i += 32;
|
|
500
|
-
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
501
|
-
i = 128 * 3;
|
|
502
|
-
const type3 = getBitU(b, i, 6);
|
|
503
|
-
i += 6;
|
|
504
|
-
const iodNav3 = getBitU(b, i, 10);
|
|
505
|
-
i += 10;
|
|
506
|
-
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
507
|
-
i += 24;
|
|
508
|
-
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
509
|
-
i += 16;
|
|
510
|
-
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
511
|
-
i += 16;
|
|
512
|
-
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
513
|
-
i += 16;
|
|
514
|
-
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
515
|
-
i += 16;
|
|
516
|
-
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
517
|
-
i = 128 * 4;
|
|
518
|
-
const type4 = getBitU(b, i, 6);
|
|
519
|
-
i += 6;
|
|
520
|
-
const iodNav4 = getBitU(b, i, 10);
|
|
521
|
-
i += 10;
|
|
522
|
-
const svid = getBitU(b, i, 6);
|
|
523
|
-
i += 6;
|
|
524
|
-
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
525
|
-
i += 16;
|
|
526
|
-
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
527
|
-
i += 16;
|
|
528
|
-
const tocs = getBitU(b, i, 14) * 60;
|
|
529
|
-
i += 14;
|
|
530
|
-
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
531
|
-
i += 31;
|
|
532
|
-
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
533
|
-
i += 21;
|
|
534
|
-
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
535
|
-
i = 128 * 5;
|
|
536
|
-
const type5 = getBitU(b, i, 6);
|
|
537
|
-
i += 6 + 11 + 11 + 14 + 5;
|
|
538
|
-
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
539
|
-
i += 10;
|
|
540
|
-
i += 10;
|
|
541
|
-
const e5bHs = getBitU(b, i, 2);
|
|
542
|
-
i += 2;
|
|
543
|
-
const e1bHs = getBitU(b, i, 2);
|
|
544
|
-
i += 2;
|
|
545
|
-
const e5bDvs = getBitU(b, i, 1);
|
|
546
|
-
i += 1;
|
|
547
|
-
const e1bDvs = getBitU(b, i, 1);
|
|
548
|
-
i += 1;
|
|
549
|
-
const gstWeek = getBitU(b, i, 12);
|
|
550
|
-
i += 12;
|
|
551
|
-
const tow = getBitU(b, i, 20);
|
|
552
|
-
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4 || type5 !== 5)
|
|
553
|
-
return null;
|
|
554
|
-
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
555
|
-
return null;
|
|
556
|
-
if (svid < 1 || svid > 36) return null;
|
|
557
|
-
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
558
|
-
const tocDate = gpsDate(week, tocs);
|
|
559
|
-
return {
|
|
560
|
-
system: "E",
|
|
561
|
-
prn: `E${two2(svid)}`,
|
|
562
|
-
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK2,
|
|
563
|
-
tocDate,
|
|
564
|
-
af0,
|
|
565
|
-
af1,
|
|
566
|
-
af2,
|
|
567
|
-
iode: iodNav1,
|
|
568
|
-
crs,
|
|
569
|
-
deltaN,
|
|
570
|
-
m0,
|
|
571
|
-
cuc,
|
|
572
|
-
e,
|
|
573
|
-
cus,
|
|
574
|
-
sqrtA,
|
|
575
|
-
toe: toes,
|
|
576
|
-
cic,
|
|
577
|
-
omega0,
|
|
578
|
-
cis,
|
|
579
|
-
i0,
|
|
580
|
-
crc,
|
|
581
|
-
omega,
|
|
582
|
-
omegaDot,
|
|
583
|
-
idot,
|
|
584
|
-
week,
|
|
585
|
-
svHealth: e5bHs << 7 | e5bDvs << 6 | e1bHs << 1 | e1bDvs,
|
|
586
|
-
tgd: bgdE5a
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
function decodeGalFnavPages(pages) {
|
|
590
|
-
if (pages.length < 124) return null;
|
|
591
|
-
const b = pages;
|
|
592
|
-
let i = 0;
|
|
593
|
-
const type1 = getBitU(b, i, 6);
|
|
594
|
-
i += 6;
|
|
595
|
-
const svid = getBitU(b, i, 6);
|
|
596
|
-
i += 6;
|
|
597
|
-
const iodNav1 = getBitU(b, i, 10);
|
|
598
|
-
i += 10;
|
|
599
|
-
const tocs = getBitU(b, i, 14) * 60;
|
|
600
|
-
i += 14;
|
|
601
|
-
const af0 = getBitS(b, i, 31) * 2 ** -34;
|
|
602
|
-
i += 31;
|
|
603
|
-
const af1 = getBitS(b, i, 21) * 2 ** -46;
|
|
604
|
-
i += 21;
|
|
605
|
-
const af2 = getBitS(b, i, 6) * 2 ** -59;
|
|
606
|
-
i += 6;
|
|
607
|
-
i += 8 + 11 + 11 + 14 + 5;
|
|
608
|
-
const bgdE5a = getBitS(b, i, 10) * 2 ** -32;
|
|
609
|
-
i += 10;
|
|
610
|
-
const e5aHs = getBitU(b, i, 2);
|
|
611
|
-
i += 2;
|
|
612
|
-
const gstWeek = getBitU(b, i, 12);
|
|
613
|
-
i += 12;
|
|
614
|
-
const tow = getBitU(b, i, 20);
|
|
615
|
-
i += 20;
|
|
616
|
-
const e5aDvs = getBitU(b, i, 1);
|
|
617
|
-
i = 31 * 8;
|
|
618
|
-
const type2 = getBitU(b, i, 6);
|
|
619
|
-
i += 6;
|
|
620
|
-
const iodNav2 = getBitU(b, i, 10);
|
|
621
|
-
i += 10;
|
|
622
|
-
const m0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
623
|
-
i += 32;
|
|
624
|
-
const omegaDot = getBitS(b, i, 24) * 2 ** -43 * GPS_PI;
|
|
625
|
-
i += 24;
|
|
626
|
-
const e = getBitU(b, i, 32) * 2 ** -33;
|
|
627
|
-
i += 32;
|
|
628
|
-
const sqrtA = getBitU(b, i, 32) * 2 ** -19;
|
|
629
|
-
i += 32;
|
|
630
|
-
const omega0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
631
|
-
i += 32;
|
|
632
|
-
const idot = getBitS(b, i, 14) * 2 ** -43 * GPS_PI;
|
|
633
|
-
i = 62 * 8;
|
|
634
|
-
const type3 = getBitU(b, i, 6);
|
|
635
|
-
i += 6;
|
|
636
|
-
const iodNav3 = getBitU(b, i, 10);
|
|
637
|
-
i += 10;
|
|
638
|
-
const i0 = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
639
|
-
i += 32;
|
|
640
|
-
const omega = getBitS(b, i, 32) * 2 ** -31 * GPS_PI;
|
|
641
|
-
i += 32;
|
|
642
|
-
const deltaN = getBitS(b, i, 16) * 2 ** -43 * GPS_PI;
|
|
643
|
-
i += 16;
|
|
644
|
-
const cuc = getBitS(b, i, 16) * 2 ** -29;
|
|
645
|
-
i += 16;
|
|
646
|
-
const cus = getBitS(b, i, 16) * 2 ** -29;
|
|
647
|
-
i += 16;
|
|
648
|
-
const crc = getBitS(b, i, 16) * 2 ** -5;
|
|
649
|
-
i += 16;
|
|
650
|
-
const crs = getBitS(b, i, 16) * 2 ** -5;
|
|
651
|
-
i += 16;
|
|
652
|
-
const toes = getBitU(b, i, 14) * 60;
|
|
653
|
-
i = 93 * 8;
|
|
654
|
-
const type4 = getBitU(b, i, 6);
|
|
655
|
-
i += 6;
|
|
656
|
-
const iodNav4 = getBitU(b, i, 10);
|
|
657
|
-
i += 10;
|
|
658
|
-
const cic = getBitS(b, i, 16) * 2 ** -29;
|
|
659
|
-
i += 16;
|
|
660
|
-
const cis = getBitS(b, i, 16) * 2 ** -29;
|
|
661
|
-
if (type1 !== 1 || type2 !== 2 || type3 !== 3 || type4 !== 4) return null;
|
|
662
|
-
if (iodNav1 !== iodNav2 || iodNav1 !== iodNav3 || iodNav1 !== iodNav4)
|
|
663
|
-
return null;
|
|
664
|
-
if (svid < 1 || svid > 36) return null;
|
|
665
|
-
const week = weekOfToe(gstWeek, tow, toes) + GST_GPS_WEEK_OFFSET;
|
|
666
|
-
const tocDate = gpsDate(week, tocs);
|
|
667
|
-
return {
|
|
668
|
-
system: "E",
|
|
669
|
-
prn: `E${two2(svid)}`,
|
|
670
|
-
toc: tocDate.getTime() / 1e3 % SEC_PER_WEEK2,
|
|
671
|
-
tocDate,
|
|
672
|
-
af0,
|
|
673
|
-
af1,
|
|
674
|
-
af2,
|
|
675
|
-
iode: iodNav1,
|
|
676
|
-
crs,
|
|
677
|
-
deltaN,
|
|
678
|
-
m0,
|
|
679
|
-
cuc,
|
|
680
|
-
e,
|
|
681
|
-
cus,
|
|
682
|
-
sqrtA,
|
|
683
|
-
toe: toes,
|
|
684
|
-
cic,
|
|
685
|
-
omega0,
|
|
686
|
-
cis,
|
|
687
|
-
i0,
|
|
688
|
-
crc,
|
|
689
|
-
omega,
|
|
690
|
-
omegaDot,
|
|
691
|
-
idot,
|
|
692
|
-
week,
|
|
693
|
-
svHealth: e5aHs << 4 | e5aDvs << 3,
|
|
694
|
-
tgd: bgdE5a
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
var dedupKey = (eph) => `${eph.iode}:${eph.toe}:${eph.tocDate.getTime()}`;
|
|
698
|
-
var GalInavAssembler = class {
|
|
699
|
-
sats = /* @__PURE__ */ new Map();
|
|
700
|
-
/**
|
|
701
|
-
* Push one I/NAV page pair for satellite `prn` (1-36): the 234-bit
|
|
702
|
-
* even+odd concatenation, even part first with its 6 tail bits
|
|
703
|
-
* removed, bit 0 = the even part's Even/Odd bit (≥ 17 bytes).
|
|
704
|
-
* Returns the newly completed ephemeris, or null. Pages that are
|
|
705
|
-
* not an even/odd nominal pair, alert pages and word types outside
|
|
706
|
-
* 1-5 are ignored.
|
|
707
|
-
*/
|
|
708
|
-
push(prn, page) {
|
|
709
|
-
if (prn < 1 || prn > 36 || page.length < 17) return null;
|
|
710
|
-
if (getBitU(page, 0, 1) !== 0 || getBitU(page, 114, 1) !== 1) return null;
|
|
711
|
-
if (getBitU(page, 1, 1) === 1 || getBitU(page, 115, 1) === 1) return null;
|
|
712
|
-
const type = getBitU(page, 2, 6);
|
|
713
|
-
if (type < 1 || type > 5) return null;
|
|
714
|
-
let sat = this.sats.get(prn);
|
|
715
|
-
if (!sat) {
|
|
716
|
-
sat = { words: new Uint8Array(96) };
|
|
717
|
-
this.sats.set(prn, sat);
|
|
718
|
-
}
|
|
719
|
-
for (let k = 0; k < 14; k++)
|
|
720
|
-
sat.words[type * 16 + k] = getBitU(page, 2 + 8 * k, 8);
|
|
721
|
-
sat.words[type * 16 + 14] = getBitU(page, 116, 8);
|
|
722
|
-
sat.words[type * 16 + 15] = getBitU(page, 124, 8);
|
|
723
|
-
if (type !== 5) return null;
|
|
724
|
-
const eph = decodeGalInavWords(sat.words);
|
|
725
|
-
if (!eph || eph.prn !== `E${two2(prn)}`) return null;
|
|
726
|
-
const key = dedupKey(eph);
|
|
727
|
-
if (key === sat.lastKey) return null;
|
|
728
|
-
sat.lastKey = key;
|
|
729
|
-
return eph;
|
|
730
|
-
}
|
|
731
|
-
};
|
|
732
|
-
var GalFnavAssembler = class {
|
|
733
|
-
sats = /* @__PURE__ */ new Map();
|
|
734
|
-
/**
|
|
735
|
-
* Push one F/NAV page for satellite `prn` (1-36): 244 bits with the
|
|
736
|
-
* sync field stripped, bit 0 = first page-type bit (≥ 31 bytes).
|
|
737
|
-
* Returns the newly completed ephemeris, or null. Dummy pages
|
|
738
|
-
* (type 63) and page types outside 1-4 are ignored.
|
|
739
|
-
*/
|
|
740
|
-
push(prn, page) {
|
|
741
|
-
if (prn < 1 || prn > 36 || page.length < 31) return null;
|
|
742
|
-
const type = getBitU(page, 0, 6);
|
|
743
|
-
if (type < 1 || type > 4) return null;
|
|
744
|
-
let sat = this.sats.get(prn);
|
|
745
|
-
if (!sat) {
|
|
746
|
-
sat = { words: new Uint8Array(124) };
|
|
747
|
-
this.sats.set(prn, sat);
|
|
748
|
-
}
|
|
749
|
-
sat.words.set(page.subarray(0, 31), (type - 1) * 31);
|
|
750
|
-
if (type !== 4) return null;
|
|
751
|
-
const eph = decodeGalFnavPages(sat.words);
|
|
752
|
-
if (!eph || eph.prn !== `E${two2(prn)}`) return null;
|
|
753
|
-
const key = dedupKey(eph);
|
|
754
|
-
if (key === sat.lastKey) return null;
|
|
755
|
-
sat.lastKey = key;
|
|
756
|
-
return eph;
|
|
757
|
-
}
|
|
758
|
-
};
|
|
759
|
-
|
|
760
460
|
// src/sbf/rawnav-gal.ts
|
|
761
461
|
var INAV_SOURCES = [17, 21, 22];
|
|
762
462
|
var FNAV_SOURCES = [20, 22];
|
|
@@ -814,450 +514,9 @@ function isFnavDummy(page) {
|
|
|
814
514
|
return page[0] >> 2 === 63;
|
|
815
515
|
}
|
|
816
516
|
|
|
817
|
-
// src/navbits/bds.ts
|
|
818
|
-
var BDT_EPOCH_MS2 = Date.UTC(2006, 0, 1);
|
|
819
|
-
var SEC_PER_WEEK3 = 7 * 86400;
|
|
820
|
-
var MS_PER_WEEK2 = SEC_PER_WEEK3 * 1e3;
|
|
821
|
-
var HALF_WEEK2 = 302400;
|
|
822
|
-
var sowOf2 = (dateMs) => dateMs / 1e3 % SEC_PER_WEEK3;
|
|
823
|
-
var BDS_SUBFRAME_BYTES = 38;
|
|
824
|
-
function getBitU22(b, p1, l1, p2, l2) {
|
|
825
|
-
return getBitU(b, p1, l1) * 2 ** l2 + getBitU(b, p2, l2);
|
|
826
|
-
}
|
|
827
|
-
function getBitS2(b, p1, l1, p2, l2) {
|
|
828
|
-
return getBitS(b, p1, l1) * 2 ** l2 + getBitU(b, p2, l2);
|
|
829
|
-
}
|
|
830
|
-
function getBitU3(b, p1, l1, p2, l2, p3, l3) {
|
|
831
|
-
return getBitU(b, p1, l1) * 2 ** (l2 + l3) + getBitU(b, p2, l2) * 2 ** l3 + getBitU(b, p3, l3);
|
|
832
|
-
}
|
|
833
|
-
function getBitS3(b, p1, l1, p2, l2, p3, l3) {
|
|
834
|
-
return getBitS(b, p1, l1) * 2 ** (l2 + l3) + getBitU(b, p2, l2) * 2 ** l3 + getBitU(b, p3, l3);
|
|
835
|
-
}
|
|
836
|
-
var mergeS = (hi, lo, n) => hi * 2 ** n + lo;
|
|
837
|
-
function bchOk(cw) {
|
|
838
|
-
for (let i = 14; i >= 4; i--) {
|
|
839
|
-
if (cw & 1 << i) cw ^= 19 << i - 4;
|
|
840
|
-
}
|
|
841
|
-
return cw === 0;
|
|
842
|
-
}
|
|
843
|
-
function bdsSubframeParityOk(subframe) {
|
|
844
|
-
if (subframe.length < BDS_SUBFRAME_BYTES) return false;
|
|
845
|
-
if (!bchOk(getBitU(subframe, 15, 15))) return false;
|
|
846
|
-
for (let w = 1; w < 10; w++) {
|
|
847
|
-
const base = 30 * w;
|
|
848
|
-
const cw1 = getBitU(subframe, base, 11) * 16 + getBitU(subframe, base + 22, 4);
|
|
849
|
-
const cw2 = getBitU(subframe, base + 11, 11) * 16 + getBitU(subframe, base + 26, 4);
|
|
850
|
-
if (!bchOk(cw1) || !bchOk(cw2)) return false;
|
|
851
|
-
}
|
|
852
|
-
return true;
|
|
853
|
-
}
|
|
854
|
-
function buildBdsEphemeris(prn, f) {
|
|
855
|
-
let week = f.week;
|
|
856
|
-
if (f.toes < f.sow - HALF_WEEK2) week++;
|
|
857
|
-
else if (f.toes > f.sow + HALF_WEEK2) week--;
|
|
858
|
-
const tocDate = new Date(BDT_EPOCH_MS2 + week * MS_PER_WEEK2 + f.tocSec * 1e3);
|
|
859
|
-
return {
|
|
860
|
-
system: "C",
|
|
861
|
-
prn,
|
|
862
|
-
toc: sowOf2(tocDate.getTime()),
|
|
863
|
-
tocDate,
|
|
864
|
-
af0: f.af0,
|
|
865
|
-
af1: f.af1,
|
|
866
|
-
af2: f.af2,
|
|
867
|
-
// AODE is not in the ephemeris subframes; RTKLIB derives the RINEX
|
|
868
|
-
// IODE/AODE slot from toc per the BDS ICD update schedule.
|
|
869
|
-
iode: Math.floor(f.tocSec / 720) % 240,
|
|
870
|
-
crs: f.crs,
|
|
871
|
-
deltaN: f.deltaN,
|
|
872
|
-
m0: f.m0,
|
|
873
|
-
cuc: f.cuc,
|
|
874
|
-
e: f.e,
|
|
875
|
-
cus: f.cus,
|
|
876
|
-
sqrtA: f.sqrtA,
|
|
877
|
-
toe: f.toes,
|
|
878
|
-
cic: f.cic,
|
|
879
|
-
omega0: f.omega0,
|
|
880
|
-
cis: f.cis,
|
|
881
|
-
i0: f.i0,
|
|
882
|
-
crc: f.crc,
|
|
883
|
-
omega: f.omega,
|
|
884
|
-
omegaDot: f.omegaDot,
|
|
885
|
-
idot: f.idot,
|
|
886
|
-
week,
|
|
887
|
-
// RINEX BDS week field is the BDT week of toe
|
|
888
|
-
svHealth: f.svh,
|
|
889
|
-
// SatH1
|
|
890
|
-
tgd: f.tgd1
|
|
891
|
-
// TGD1 (B1) — RINEX slot
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
function decodeBdsD1Frame(subframes, opts = {}) {
|
|
895
|
-
if (subframes.length < 3 * BDS_SUBFRAME_BYTES) return null;
|
|
896
|
-
const b = subframes;
|
|
897
|
-
let i = 8 * 38 * 0;
|
|
898
|
-
const frn1 = getBitU(b, i + 15, 3);
|
|
899
|
-
const sow1 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
900
|
-
const svh = getBitU(b, i + 42, 1);
|
|
901
|
-
const week = getBitU(b, i + 60, 13);
|
|
902
|
-
const tocSec = getBitU22(b, i + 73, 9, i + 90, 8) * 8;
|
|
903
|
-
const tgd1 = getBitS(b, i + 98, 10) * 0.1 * 1e-9;
|
|
904
|
-
const af2 = getBitS(b, i + 214, 11) * 2 ** -66;
|
|
905
|
-
const af0 = getBitS2(b, i + 225, 7, i + 240, 17) * 2 ** -33;
|
|
906
|
-
const af1 = getBitS2(b, i + 257, 5, i + 270, 17) * 2 ** -50;
|
|
907
|
-
i = 8 * 38 * 1;
|
|
908
|
-
const frn2 = getBitU(b, i + 15, 3);
|
|
909
|
-
const sow2 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
910
|
-
const deltaN = getBitS2(b, i + 42, 10, i + 60, 6) * 2 ** -43 * GPS_PI;
|
|
911
|
-
const cuc = getBitS2(b, i + 66, 16, i + 90, 2) * 2 ** -31;
|
|
912
|
-
const m0 = getBitS2(b, i + 92, 20, i + 120, 12) * 2 ** -31 * GPS_PI;
|
|
913
|
-
const e = getBitU22(b, i + 132, 10, i + 150, 22) * 2 ** -33;
|
|
914
|
-
const cus = getBitS(b, i + 180, 18) * 2 ** -31;
|
|
915
|
-
const crc = getBitS2(b, i + 198, 4, i + 210, 14) * 2 ** -6;
|
|
916
|
-
const crs = getBitS2(b, i + 224, 8, i + 240, 10) * 2 ** -6;
|
|
917
|
-
const sqrtA = getBitU22(b, i + 250, 12, i + 270, 20) * 2 ** -19;
|
|
918
|
-
const toe1 = getBitU(b, i + 290, 2);
|
|
919
|
-
i = 8 * 38 * 2;
|
|
920
|
-
const frn3 = getBitU(b, i + 15, 3);
|
|
921
|
-
const sow3 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
922
|
-
const toe2 = getBitU22(b, i + 42, 10, i + 60, 5);
|
|
923
|
-
const i0 = getBitS2(b, i + 65, 17, i + 90, 15) * 2 ** -31 * GPS_PI;
|
|
924
|
-
const cic = getBitS2(b, i + 105, 7, i + 120, 11) * 2 ** -31;
|
|
925
|
-
const omegaDot = getBitS2(b, i + 131, 11, i + 150, 13) * 2 ** -43 * GPS_PI;
|
|
926
|
-
const cis = getBitS2(b, i + 163, 9, i + 180, 9) * 2 ** -31;
|
|
927
|
-
const idot = getBitS2(b, i + 189, 13, i + 210, 1) * 2 ** -43 * GPS_PI;
|
|
928
|
-
const omega0 = getBitS2(b, i + 211, 21, i + 240, 11) * 2 ** -31 * GPS_PI;
|
|
929
|
-
const omega = getBitS2(b, i + 251, 11, i + 270, 21) * 2 ** -31 * GPS_PI;
|
|
930
|
-
const toes = (toe1 * 2 ** 15 + toe2) * 8;
|
|
931
|
-
if (frn1 !== 1 || frn2 !== 2 || frn3 !== 3) return null;
|
|
932
|
-
if (sow2 !== sow1 + 6 || sow3 !== sow2 + 6) return null;
|
|
933
|
-
if (tocSec !== toes) return null;
|
|
934
|
-
return buildBdsEphemeris(opts.prn ?? "C00", {
|
|
935
|
-
week,
|
|
936
|
-
sow: sow1,
|
|
937
|
-
toes,
|
|
938
|
-
tocSec,
|
|
939
|
-
svh,
|
|
940
|
-
tgd1,
|
|
941
|
-
af0,
|
|
942
|
-
af1,
|
|
943
|
-
af2,
|
|
944
|
-
crs,
|
|
945
|
-
deltaN,
|
|
946
|
-
m0,
|
|
947
|
-
cuc,
|
|
948
|
-
e,
|
|
949
|
-
cus,
|
|
950
|
-
sqrtA,
|
|
951
|
-
cic,
|
|
952
|
-
omega0,
|
|
953
|
-
cis,
|
|
954
|
-
i0,
|
|
955
|
-
crc,
|
|
956
|
-
omega,
|
|
957
|
-
omegaDot,
|
|
958
|
-
idot
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
function decodeBdsD2Frame(pages, opts = {}) {
|
|
962
|
-
if (pages.length < 10 * BDS_SUBFRAME_BYTES) return null;
|
|
963
|
-
const b = pages;
|
|
964
|
-
let i = 8 * 38 * 0;
|
|
965
|
-
const pgn1 = getBitU(b, i + 42, 4);
|
|
966
|
-
const sow1 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
967
|
-
const svh = getBitU(b, i + 46, 1);
|
|
968
|
-
const week = getBitU(b, i + 64, 13);
|
|
969
|
-
const tocSec = getBitU22(b, i + 77, 5, i + 90, 12) * 8;
|
|
970
|
-
const tgd1 = getBitS(b, i + 102, 10) * 0.1 * 1e-9;
|
|
971
|
-
i = 8 * 38 * 2;
|
|
972
|
-
const pgn3 = getBitU(b, i + 42, 4);
|
|
973
|
-
const sow3 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
974
|
-
const af0 = getBitS2(b, i + 100, 12, i + 120, 12) * 2 ** -33;
|
|
975
|
-
const af1p3 = getBitS(b, i + 132, 4);
|
|
976
|
-
i = 8 * 38 * 3;
|
|
977
|
-
const pgn4 = getBitU(b, i + 42, 4);
|
|
978
|
-
const sow4 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
979
|
-
const af1p4 = getBitU22(b, i + 46, 6, i + 60, 12);
|
|
980
|
-
const af2 = getBitS2(b, i + 72, 10, i + 90, 1) * 2 ** -66;
|
|
981
|
-
const deltaN = getBitS(b, i + 96, 16) * 2 ** -43 * GPS_PI;
|
|
982
|
-
const cucp4 = getBitS(b, i + 120, 14);
|
|
983
|
-
i = 8 * 38 * 4;
|
|
984
|
-
const pgn5 = getBitU(b, i + 42, 4);
|
|
985
|
-
const sow5 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
986
|
-
const cucp5 = getBitU(b, i + 46, 4);
|
|
987
|
-
const m0 = getBitS3(b, i + 50, 2, i + 60, 22, i + 90, 8) * 2 ** -31 * GPS_PI;
|
|
988
|
-
const cus = getBitS2(b, i + 98, 14, i + 120, 4) * 2 ** -31;
|
|
989
|
-
const ep5 = getBitS(b, i + 124, 10);
|
|
990
|
-
i = 8 * 38 * 5;
|
|
991
|
-
const pgn6 = getBitU(b, i + 42, 4);
|
|
992
|
-
const sow6 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
993
|
-
const ep6 = getBitU22(b, i + 46, 6, i + 60, 16);
|
|
994
|
-
const sqrtA = getBitU3(b, i + 76, 6, i + 90, 22, i + 120, 4) * 2 ** -19;
|
|
995
|
-
const cicp6 = getBitS(b, i + 124, 10);
|
|
996
|
-
i = 8 * 38 * 6;
|
|
997
|
-
const pgn7 = getBitU(b, i + 42, 4);
|
|
998
|
-
const sow7 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
999
|
-
const cicp7 = getBitU22(b, i + 46, 6, i + 60, 2);
|
|
1000
|
-
const cis = getBitS(b, i + 62, 18) * 2 ** -31;
|
|
1001
|
-
const toes = getBitU22(b, i + 80, 2, i + 90, 15) * 8;
|
|
1002
|
-
const i0p7 = getBitS2(b, i + 105, 7, i + 120, 14);
|
|
1003
|
-
i = 8 * 38 * 7;
|
|
1004
|
-
const pgn8 = getBitU(b, i + 42, 4);
|
|
1005
|
-
const sow8 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
1006
|
-
const i0p8 = getBitU22(b, i + 46, 6, i + 60, 5);
|
|
1007
|
-
const crc = getBitS2(b, i + 65, 17, i + 90, 1) * 2 ** -6;
|
|
1008
|
-
const crs = getBitS(b, i + 91, 18) * 2 ** -6;
|
|
1009
|
-
const omegaDotP8 = getBitS2(b, i + 109, 3, i + 120, 16);
|
|
1010
|
-
i = 8 * 38 * 8;
|
|
1011
|
-
const pgn9 = getBitU(b, i + 42, 4);
|
|
1012
|
-
const sow9 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
1013
|
-
const omegaDotP9 = getBitU(b, i + 46, 5);
|
|
1014
|
-
const omega0 = getBitS3(b, i + 51, 1, i + 60, 22, i + 90, 9) * 2 ** -31 * GPS_PI;
|
|
1015
|
-
const omegaP9 = getBitS2(b, i + 99, 13, i + 120, 14);
|
|
1016
|
-
i = 8 * 38 * 9;
|
|
1017
|
-
const pgn10 = getBitU(b, i + 42, 4);
|
|
1018
|
-
const sow10 = getBitU22(b, i + 18, 8, i + 30, 12);
|
|
1019
|
-
const omegaP10 = getBitU(b, i + 46, 5);
|
|
1020
|
-
const idot = getBitS2(b, i + 51, 1, i + 60, 13) * 2 ** -43 * GPS_PI;
|
|
1021
|
-
if (pgn1 !== 1 || pgn3 !== 3 || pgn4 !== 4 || pgn5 !== 5 || pgn6 !== 6 || pgn7 !== 7 || pgn8 !== 8 || pgn9 !== 9 || pgn10 !== 10) {
|
|
1022
|
-
return null;
|
|
1023
|
-
}
|
|
1024
|
-
if (sow3 !== sow1 + 6 || sow4 !== sow3 + 3 || sow5 !== sow4 + 3 || sow6 !== sow5 + 3 || sow7 !== sow6 + 3 || sow8 !== sow7 + 3 || sow9 !== sow8 + 3 || sow10 !== sow9 + 3) {
|
|
1025
|
-
return null;
|
|
1026
|
-
}
|
|
1027
|
-
if (tocSec !== toes) return null;
|
|
1028
|
-
return buildBdsEphemeris(opts.prn ?? "C00", {
|
|
1029
|
-
week,
|
|
1030
|
-
sow: sow1,
|
|
1031
|
-
toes,
|
|
1032
|
-
tocSec,
|
|
1033
|
-
svh,
|
|
1034
|
-
tgd1,
|
|
1035
|
-
af0,
|
|
1036
|
-
af1: mergeS(af1p3, af1p4, 18) * 2 ** -50,
|
|
1037
|
-
af2,
|
|
1038
|
-
crs,
|
|
1039
|
-
deltaN,
|
|
1040
|
-
m0,
|
|
1041
|
-
cuc: mergeS(cucp4, cucp5, 4) * 2 ** -31,
|
|
1042
|
-
e: mergeS(ep5, ep6, 22) * 2 ** -33,
|
|
1043
|
-
cus,
|
|
1044
|
-
sqrtA,
|
|
1045
|
-
cic: mergeS(cicp6, cicp7, 8) * 2 ** -31,
|
|
1046
|
-
omega0,
|
|
1047
|
-
cis,
|
|
1048
|
-
i0: mergeS(i0p7, i0p8, 11) * 2 ** -31 * GPS_PI,
|
|
1049
|
-
crc,
|
|
1050
|
-
omega: mergeS(omegaP9, omegaP10, 5) * 2 ** -31 * GPS_PI,
|
|
1051
|
-
omegaDot: mergeS(omegaDotP8, omegaDotP9, 5) * 2 ** -43 * GPS_PI,
|
|
1052
|
-
idot
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
function isBdsGeoPrn(prn) {
|
|
1056
|
-
return prn < 6 || prn > 58;
|
|
1057
|
-
}
|
|
1058
|
-
var BdsAssembler = class {
|
|
1059
|
-
sats = /* @__PURE__ */ new Map();
|
|
1060
|
-
/**
|
|
1061
|
-
* Push one 300-bit subframe (38+ bytes, bit 0 = first bit of the
|
|
1062
|
-
* preamble) for the satellite `prn` ("C06"). Returns the newly
|
|
1063
|
-
* completed ephemeris, or null.
|
|
1064
|
-
*/
|
|
1065
|
-
push(prn, subframe) {
|
|
1066
|
-
if (subframe.length < BDS_SUBFRAME_BYTES) return null;
|
|
1067
|
-
const num = parseInt(prn.slice(1), 10);
|
|
1068
|
-
if (!Number.isFinite(num) || num < 1 || num > 63) return null;
|
|
1069
|
-
const id = getBitU(subframe, 15, 3);
|
|
1070
|
-
if (id < 1 || id > 5) return null;
|
|
1071
|
-
let sat = this.sats.get(prn);
|
|
1072
|
-
if (!sat) {
|
|
1073
|
-
sat = { buf: new Uint8Array(10 * BDS_SUBFRAME_BYTES) };
|
|
1074
|
-
this.sats.set(prn, sat);
|
|
1075
|
-
}
|
|
1076
|
-
let eph = null;
|
|
1077
|
-
if (!isBdsGeoPrn(num)) {
|
|
1078
|
-
sat.buf.set(subframe.subarray(0, BDS_SUBFRAME_BYTES), (id - 1) * 38);
|
|
1079
|
-
if (id === 3) eph = decodeBdsD1Frame(sat.buf, { prn });
|
|
1080
|
-
} else {
|
|
1081
|
-
if (id !== 1) return null;
|
|
1082
|
-
const pgn = getBitU(subframe, 42, 4);
|
|
1083
|
-
if (pgn < 1 || pgn > 10) return null;
|
|
1084
|
-
sat.buf.set(subframe.subarray(0, BDS_SUBFRAME_BYTES), (pgn - 1) * 38);
|
|
1085
|
-
if (pgn === 10) eph = decodeBdsD2Frame(sat.buf, { prn });
|
|
1086
|
-
}
|
|
1087
|
-
if (!eph) return null;
|
|
1088
|
-
const key = `${eph.week}:${eph.toe}`;
|
|
1089
|
-
if (key === sat.lastKey) return null;
|
|
1090
|
-
sat.lastKey = key;
|
|
1091
|
-
return eph;
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
|
|
1095
|
-
// src/navbits/glo.ts
|
|
1096
|
-
var GPS_EPOCH_MS3 = Date.UTC(1980, 0, 6);
|
|
1097
|
-
var SEC_PER_WEEK4 = 7 * 86400;
|
|
1098
|
-
var SEC_PER_DAY = 86400;
|
|
1099
|
-
var GLO_STRING_BYTES = 10;
|
|
1100
|
-
function getBitG(b, pos, len) {
|
|
1101
|
-
const value = getBitU(b, pos + 1, len - 1);
|
|
1102
|
-
return getBitU(b, pos, 1) && value !== 0 ? -value : value;
|
|
1103
|
-
}
|
|
1104
|
-
var HAMMING_MASKS = [
|
|
1105
|
-
[85, 85, 90, 170, 170, 170, 181, 85, 106, 216, 8],
|
|
1106
|
-
[102, 102, 108, 204, 204, 204, 217, 153, 179, 104, 16],
|
|
1107
|
-
[135, 135, 143, 15, 15, 15, 30, 30, 60, 112, 32],
|
|
1108
|
-
[7, 248, 15, 240, 15, 240, 31, 224, 63, 128, 64],
|
|
1109
|
-
[248, 0, 15, 255, 240, 0, 31, 255, 192, 0, 128],
|
|
1110
|
-
[0, 0, 15, 255, 255, 255, 224, 0, 0, 1, 0],
|
|
1111
|
-
[255, 255, 240, 0, 0, 0, 0, 0, 0, 2, 0],
|
|
1112
|
-
[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 248]
|
|
1113
|
-
];
|
|
1114
|
-
function testGloString(buff) {
|
|
1115
|
-
if (buff.length < 11) return false;
|
|
1116
|
-
let n = 0;
|
|
1117
|
-
let cs = 0;
|
|
1118
|
-
for (const mask of HAMMING_MASKS) {
|
|
1119
|
-
cs = 0;
|
|
1120
|
-
for (let j = 0; j < 11; j++) {
|
|
1121
|
-
let x = buff[j] & mask[j];
|
|
1122
|
-
x ^= x >> 4;
|
|
1123
|
-
x ^= x >> 2;
|
|
1124
|
-
x ^= x >> 1;
|
|
1125
|
-
cs ^= x & 1;
|
|
1126
|
-
}
|
|
1127
|
-
if (cs) n++;
|
|
1128
|
-
}
|
|
1129
|
-
return n === 0 || n === 2 && cs === 1;
|
|
1130
|
-
}
|
|
1131
|
-
function decodeGloStrings(strings, refDate, opts = {}) {
|
|
1132
|
-
if (strings.length < 4 * GLO_STRING_BYTES) return null;
|
|
1133
|
-
const b = strings;
|
|
1134
|
-
let i = 1;
|
|
1135
|
-
const frn1 = getBitU(b, i, 4);
|
|
1136
|
-
i += 4 + 2;
|
|
1137
|
-
i += 2;
|
|
1138
|
-
const tkH = getBitU(b, i, 5);
|
|
1139
|
-
i += 5;
|
|
1140
|
-
const tkM = getBitU(b, i, 6);
|
|
1141
|
-
i += 6;
|
|
1142
|
-
const tkS = getBitU(b, i, 1) * 30;
|
|
1143
|
-
i += 1;
|
|
1144
|
-
const xDot = getBitG(b, i, 24) * 2 ** -20;
|
|
1145
|
-
i += 24;
|
|
1146
|
-
const xAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
1147
|
-
i += 5;
|
|
1148
|
-
const x = getBitG(b, i, 27) * 2 ** -11;
|
|
1149
|
-
i = 80 + 1;
|
|
1150
|
-
const frn2 = getBitU(b, i, 4);
|
|
1151
|
-
i += 4;
|
|
1152
|
-
const bn = getBitU(b, i, 1);
|
|
1153
|
-
i += 1 + 2;
|
|
1154
|
-
i += 1;
|
|
1155
|
-
const tb = getBitU(b, i, 7);
|
|
1156
|
-
i += 7 + 5;
|
|
1157
|
-
const yDot = getBitG(b, i, 24) * 2 ** -20;
|
|
1158
|
-
i += 24;
|
|
1159
|
-
const yAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
1160
|
-
i += 5;
|
|
1161
|
-
const y = getBitG(b, i, 27) * 2 ** -11;
|
|
1162
|
-
i = 160 + 1;
|
|
1163
|
-
const frn3 = getBitU(b, i, 4);
|
|
1164
|
-
i += 4;
|
|
1165
|
-
i += 1;
|
|
1166
|
-
const gammaN = getBitG(b, i, 11) * 2 ** -40;
|
|
1167
|
-
i += 11 + 1;
|
|
1168
|
-
i += 2;
|
|
1169
|
-
i += 1;
|
|
1170
|
-
const zDot = getBitG(b, i, 24) * 2 ** -20;
|
|
1171
|
-
i += 24;
|
|
1172
|
-
const zAcc = getBitG(b, i, 5) * 2 ** -30;
|
|
1173
|
-
i += 5;
|
|
1174
|
-
const z = getBitG(b, i, 27) * 2 ** -11;
|
|
1175
|
-
i = 240 + 1;
|
|
1176
|
-
const frn4 = getBitU(b, i, 4);
|
|
1177
|
-
i += 4;
|
|
1178
|
-
const tauN = getBitG(b, i, 22) * 2 ** -30;
|
|
1179
|
-
i += 22;
|
|
1180
|
-
i += 5;
|
|
1181
|
-
i += 5;
|
|
1182
|
-
i += 14;
|
|
1183
|
-
i += 1;
|
|
1184
|
-
i += 4;
|
|
1185
|
-
i += 3;
|
|
1186
|
-
i += 11;
|
|
1187
|
-
const slot = getBitU(b, i, 5);
|
|
1188
|
-
if (frn1 !== 1 || frn2 !== 2 || frn3 !== 3 || frn4 !== 4) return null;
|
|
1189
|
-
if (slot < 1 || slot > 27) return null;
|
|
1190
|
-
const utcSec = (getUtcDate(refDate).getTime() - GPS_EPOCH_MS3) / 1e3;
|
|
1191
|
-
const week = Math.floor(utcSec / SEC_PER_WEEK4);
|
|
1192
|
-
let tow = utcSec - week * SEC_PER_WEEK4;
|
|
1193
|
-
const tod = tow % SEC_PER_DAY;
|
|
1194
|
-
tow -= tod;
|
|
1195
|
-
let tof = tkH * 3600 + tkM * 60 + tkS - 10800;
|
|
1196
|
-
if (tof < tod - 43200) tof += SEC_PER_DAY;
|
|
1197
|
-
else if (tof > tod + 43200) tof -= SEC_PER_DAY;
|
|
1198
|
-
let toe = tb * 900 - 10800;
|
|
1199
|
-
if (toe < tod - 43200) toe += SEC_PER_DAY;
|
|
1200
|
-
else if (toe > tod + 43200) toe -= SEC_PER_DAY;
|
|
1201
|
-
return {
|
|
1202
|
-
system: "R",
|
|
1203
|
-
prn: `R${String(slot).padStart(2, "0")}`,
|
|
1204
|
-
// RINEX GLONASS epochs are UTC: build the UTC toe Date directly.
|
|
1205
|
-
tocDate: new Date(GPS_EPOCH_MS3 + (week * SEC_PER_WEEK4 + tow + toe) * 1e3),
|
|
1206
|
-
tauN: -tauN,
|
|
1207
|
-
// RINEX stores −τn; the SIS carries τn (ICD sign)
|
|
1208
|
-
gammaN,
|
|
1209
|
-
// v3 message frame time: seconds of the UTC week (RTKLIB tof).
|
|
1210
|
-
messageFrameTime: ((tow + tof) % SEC_PER_WEEK4 + SEC_PER_WEEK4) % SEC_PER_WEEK4,
|
|
1211
|
-
x,
|
|
1212
|
-
xDot,
|
|
1213
|
-
xAcc,
|
|
1214
|
-
y,
|
|
1215
|
-
yDot,
|
|
1216
|
-
yAcc,
|
|
1217
|
-
z,
|
|
1218
|
-
zDot,
|
|
1219
|
-
zAcc,
|
|
1220
|
-
// MSB of the 3-bit Bn word — the unhealthy flag RINEX carries
|
|
1221
|
-
health: bn,
|
|
1222
|
-
freqNum: opts.freqNum ?? 0
|
|
1223
|
-
};
|
|
1224
|
-
}
|
|
1225
|
-
var GloStringAssembler = class {
|
|
1226
|
-
sats = /* @__PURE__ */ new Map();
|
|
1227
|
-
/**
|
|
1228
|
-
* Push one navigation string (10+ bytes, bit 0 = string bit 85) for
|
|
1229
|
-
* the satellite `prn` ("R09"), received at the GPS-scale `time`.
|
|
1230
|
-
* Returns the newly completed ephemeris, or null. The decoded
|
|
1231
|
-
* string-4 slot number must match `prn`, or nothing is emitted.
|
|
1232
|
-
*/
|
|
1233
|
-
push(prn, str, time, freqNum = 0) {
|
|
1234
|
-
if (str.length < GLO_STRING_BYTES) return null;
|
|
1235
|
-
const m = getBitU(str, 1, 4);
|
|
1236
|
-
if (m < 1) return null;
|
|
1237
|
-
const sec = Math.floor(time.getTime() / 1e3);
|
|
1238
|
-
let sat = this.sats.get(prn);
|
|
1239
|
-
if (!sat) {
|
|
1240
|
-
sat = { buf: new Uint8Array(4 * GLO_STRING_BYTES), batchSec: sec };
|
|
1241
|
-
this.sats.set(prn, sat);
|
|
1242
|
-
} else if (Math.abs(sec - sat.batchSec) > 30) {
|
|
1243
|
-
sat.buf.fill(0);
|
|
1244
|
-
sat.batchSec = sec;
|
|
1245
|
-
}
|
|
1246
|
-
if (m > 4) return null;
|
|
1247
|
-
sat.buf.set(str.subarray(0, GLO_STRING_BYTES), (m - 1) * 10);
|
|
1248
|
-
if (m !== 4) return null;
|
|
1249
|
-
const eph = decodeGloStrings(sat.buf, time, { freqNum });
|
|
1250
|
-
if (!eph || eph.prn !== prn) return null;
|
|
1251
|
-
const key = `${eph.tocDate.getTime()}:${eph.health}`;
|
|
1252
|
-
if (key === sat.lastKey) return null;
|
|
1253
|
-
sat.lastKey = key;
|
|
1254
|
-
return eph;
|
|
1255
|
-
}
|
|
1256
|
-
};
|
|
1257
|
-
|
|
1258
517
|
// src/sbf/rawnav-bds.ts
|
|
1259
|
-
var
|
|
1260
|
-
var
|
|
518
|
+
var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
|
|
519
|
+
var MS_PER_WEEK2 = 7 * 86400 * 1e3;
|
|
1261
520
|
var TOW_DNU = 4294967295;
|
|
1262
521
|
var WNC_DNU = 65535;
|
|
1263
522
|
function parseSbfBdsNav(data) {
|
|
@@ -1326,7 +585,7 @@ function parseSbfGloNav(data) {
|
|
|
1326
585
|
const eph = assembler.push(
|
|
1327
586
|
prn,
|
|
1328
587
|
str,
|
|
1329
|
-
new Date(
|
|
588
|
+
new Date(GPS_EPOCH_MS2 + wnc * MS_PER_WEEK2 + towMs),
|
|
1330
589
|
view.getUint8(b + 18) - 8
|
|
1331
590
|
// FreqNr, offset by 8
|
|
1332
591
|
);
|
|
@@ -1860,8 +1119,8 @@ function parseSbfHas(data) {
|
|
|
1860
1119
|
|
|
1861
1120
|
// src/sbf/index.ts
|
|
1862
1121
|
var CLIGHT = 299792458;
|
|
1863
|
-
var
|
|
1864
|
-
var
|
|
1122
|
+
var GPS_EPOCH_MS3 = Date.UTC(1980, 0, 6);
|
|
1123
|
+
var MS_PER_WEEK3 = 7 * 864e5;
|
|
1865
1124
|
var M3_SYS = ["G", "R", "E", "C", "S", "J", "I"];
|
|
1866
1125
|
var M3_PR_BASE = [19e6, 19e6, 22e6, 2e7, 34e6, 34e6, 34e6];
|
|
1867
1126
|
var M3_INTERVALS = [
|
|
@@ -1960,23 +1219,23 @@ var MEAS2_SIG = [
|
|
|
1960
1219
|
["J", "1E"],
|
|
1961
1220
|
["J", "5P"]
|
|
1962
1221
|
];
|
|
1963
|
-
var
|
|
1222
|
+
var two2 = (n) => String(n).padStart(2, "0");
|
|
1964
1223
|
function m3Prn(navsys, svid) {
|
|
1965
1224
|
switch (navsys) {
|
|
1966
1225
|
case 0:
|
|
1967
|
-
return svid < 32 ? `G${
|
|
1226
|
+
return svid < 32 ? `G${two2(svid + 1)}` : null;
|
|
1968
1227
|
case 1:
|
|
1969
|
-
return svid < 27 ? `R${
|
|
1228
|
+
return svid < 27 ? `R${two2(svid + 1)}` : null;
|
|
1970
1229
|
case 2:
|
|
1971
|
-
return svid < 36 ? `E${
|
|
1230
|
+
return svid < 36 ? `E${two2(svid + 1)}` : null;
|
|
1972
1231
|
case 3:
|
|
1973
|
-
return svid < 50 ? `C${
|
|
1232
|
+
return svid < 50 ? `C${two2(svid + 1)}` : null;
|
|
1974
1233
|
case 4:
|
|
1975
|
-
return svid <= 38 ? `S${
|
|
1234
|
+
return svid <= 38 ? `S${two2(svid + 20)}` : null;
|
|
1976
1235
|
case 5:
|
|
1977
|
-
return svid < 10 ? `J${
|
|
1236
|
+
return svid < 10 ? `J${two2(svid + 1)}` : null;
|
|
1978
1237
|
case 6:
|
|
1979
|
-
return svid < 14 ? `I${
|
|
1238
|
+
return svid < 14 ? `I${two2(svid + 1)}` : null;
|
|
1980
1239
|
default:
|
|
1981
1240
|
return null;
|
|
1982
1241
|
}
|
|
@@ -2514,7 +1773,7 @@ function parseSbfMeas(data) {
|
|
|
2514
1773
|
const tow = view.getUint32(i + 8, true);
|
|
2515
1774
|
const wnc = view.getUint16(i + 12, true);
|
|
2516
1775
|
if (tow !== 4294967295 && wnc !== 65535) {
|
|
2517
|
-
ensureEpoch(
|
|
1776
|
+
ensureEpoch(GPS_EPOCH_MS3 + wnc * MS_PER_WEEK3 + tow);
|
|
2518
1777
|
if (id === 4109) decodeMeas3Ranges(i, tow);
|
|
2519
1778
|
else if (id === 4110) decodeMeas3CN0(i, len);
|
|
2520
1779
|
else if (id === 4111) decodeMeas3Doppler(i, len);
|