gnss-js 1.51.0 → 1.53.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.
@@ -43,6 +43,7 @@ __export(positioning_exports, {
43
43
  postProcessRtk: () => postProcessRtk,
44
44
  resolvePppAmbiguities: () => resolvePppAmbiguities,
45
45
  satClockCorrection: () => satClockCorrection,
46
+ sbasProtectionLevels: () => sbasProtectionLevels,
46
47
  solidEarthTide: () => solidEarthTide,
47
48
  solveDgnss: () => solveDgnss,
48
49
  solvePpp: () => solvePpp,
@@ -3593,6 +3594,65 @@ function sagnac2(pos, travelTimeS) {
3593
3594
  const s = Math.sin(theta);
3594
3595
  return [pos.x * c + pos.y * s, -pos.x * s + pos.y * c, pos.z];
3595
3596
  }
3597
+ function sbasAirTropoVar(elRad) {
3598
+ const elDeg = elRad * 180 / Math.PI;
3599
+ const sigMp = 0.13 + 0.53 * Math.exp(-elDeg / 10);
3600
+ const sigNoise = 0.15 + 0.43 * Math.exp(-elDeg / 6.9);
3601
+ const m = 1.001 / Math.sqrt(2001e-6 + Math.sin(elRad) * Math.sin(elRad));
3602
+ const sigTropo = 0.12 * m;
3603
+ return sigMp * sigMp + sigNoise * sigNoise + sigTropo * sigTropo;
3604
+ }
3605
+ function invertMatrix(A) {
3606
+ const n = A.length;
3607
+ const M = A.map((row, i) => [
3608
+ ...row,
3609
+ ...Array.from({ length: n }, (_, j) => i === j ? 1 : 0)
3610
+ ]);
3611
+ for (let col = 0; col < n; col++) {
3612
+ let piv = col;
3613
+ for (let r = col + 1; r < n; r++)
3614
+ if (Math.abs(M[r][col]) > Math.abs(M[piv][col])) piv = r;
3615
+ if (Math.abs(M[piv][col]) < 1e-12) return null;
3616
+ [M[col], M[piv]] = [M[piv], M[col]];
3617
+ const d = M[col][col];
3618
+ for (let j = 0; j < 2 * n; j++) M[col][j] /= d;
3619
+ for (let r = 0; r < n; r++) {
3620
+ if (r === col) continue;
3621
+ const f = M[r][col];
3622
+ for (let j = 0; j < 2 * n; j++) M[r][j] -= f * M[col][j];
3623
+ }
3624
+ }
3625
+ return M.map((row) => row.slice(n));
3626
+ }
3627
+ function sbasProtectionLevels(sats, opts = {}) {
3628
+ const kH = opts.kH ?? 6;
3629
+ const kV = opts.kV ?? 5.33;
3630
+ if (sats.length < 4) return null;
3631
+ const N = [0, 1, 2, 3].map(() => [0, 0, 0, 0]);
3632
+ for (const s of sats) {
3633
+ if (!(s.variance > 0)) continue;
3634
+ const ce = Math.cos(s.elRad);
3635
+ const g = [
3636
+ ce * Math.sin(s.azRad),
3637
+ ce * Math.cos(s.azRad),
3638
+ Math.sin(s.elRad),
3639
+ 1
3640
+ ];
3641
+ const w = 1 / s.variance;
3642
+ for (let i = 0; i < 4; i++)
3643
+ for (let j = 0; j < 4; j++) N[i][j] += w * g[i] * g[j];
3644
+ }
3645
+ const cov = invertMatrix(N);
3646
+ if (!cov) return null;
3647
+ const dE2 = cov[0][0];
3648
+ const dN2 = cov[1][1];
3649
+ const dEN = cov[0][1];
3650
+ const dU = Math.sqrt(Math.max(cov[2][2], 0));
3651
+ const dMajor = Math.sqrt(
3652
+ (dE2 + dN2) / 2 + Math.sqrt(((dE2 - dN2) / 2) ** 2 + dEN * dEN)
3653
+ );
3654
+ return { hpl: kH * dMajor, vpl: kV * dU, dMajor, dU };
3655
+ }
3596
3656
  function solveLinear(A, b) {
3597
3657
  const n = b.length;
3598
3658
  const M = A.map((row, i) => [...row, b[i]]);
@@ -3649,7 +3709,7 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3649
3709
  const sysRows = new Map(systems.map((s) => [s, 0]));
3650
3710
  for (const k of Object.keys(residuals2)) delete residuals2[k];
3651
3711
  const positionSaneIter = x9 * x9 + y2 * y2 + z2 * z2 > 1e12;
3652
- const [rxLat, rxLon, rxHgt] = positionSaneIter ? ecefToGeodetic(x9, y2, z2) : [0, 0, 0];
3712
+ const [rxLat2, rxLon2, rxHgt2] = positionSaneIter ? ecefToGeodetic(x9, y2, z2) : [0, 0, 0];
3653
3713
  for (const prn of prns) {
3654
3714
  const psr = pseudoranges.get(prn);
3655
3715
  const eph = ephemerides.get(prn);
@@ -3688,7 +3748,7 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3688
3748
  const sinEl = Math.max(Math.sin(elev), 0.1);
3689
3749
  weight = sinEl * sinEl;
3690
3750
  }
3691
- const tropo = troposphere && positionSane ? tropoDelay2(elev, rxLat, rxHgt) : 0;
3751
+ const tropo = troposphere && positionSane ? tropoDelay2(elev, rxLat2, rxHgt2) : 0;
3692
3752
  let ionoM = 0;
3693
3753
  if ((sbas || gim || iono) && positionSane) {
3694
3754
  let l1M = null;
@@ -3696,18 +3756,18 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3696
3756
  const si = sbas.ionoDelay(
3697
3757
  gpsWeek,
3698
3758
  gpsTow,
3699
- rxLat,
3700
- rxLon,
3701
- rxHgt,
3759
+ rxLat2,
3760
+ rxLon2,
3761
+ rxHgt2,
3702
3762
  azim,
3703
3763
  elev
3704
3764
  );
3705
3765
  if (si) l1M = si.delayM;
3706
3766
  }
3707
3767
  if (l1M === null && gim)
3708
- l1M = gimSlantIonoDelayL1(gim, rxLat, rxLon, azim, elev, timeMs);
3768
+ l1M = gimSlantIonoDelayL1(gim, rxLat2, rxLon2, azim, elev, timeMs);
3709
3769
  if (l1M === null && iono) {
3710
- l1M = C_LIGHT * klobucharDelay(iono, rxLat, rxLon, azim, elev, gpsTow);
3770
+ l1M = C_LIGHT * klobucharDelay(iono, rxLat2, rxLon2, azim, elev, gpsTow);
3711
3771
  }
3712
3772
  if (l1M !== null) {
3713
3773
  const f = PRIMARY_FREQ_HZ[sys] ?? F_L12;
@@ -3780,6 +3840,8 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3780
3840
  const { x, y, z, clock, residuals, iterations, converged } = inner;
3781
3841
  const used = [];
3782
3842
  const azels = [];
3843
+ const [rxLat, rxLon, rxHgt] = ecefToGeodetic(x, y, z);
3844
+ const sbasRows = [];
3783
3845
  for (const prn of candidates) {
3784
3846
  if (!(prn in residuals)) continue;
3785
3847
  const eph = ephemerides.get(prn);
@@ -3789,8 +3851,27 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3789
3851
  if (azel.el >= elevationMaskDeg * Math.PI / 180) {
3790
3852
  used.push(prn);
3791
3853
  azels.push(azel);
3854
+ if (sbas) {
3855
+ const sc = sbas.satCorrection(prn, gpsWeek, gpsTow);
3856
+ const si = sbas.ionoDelay(
3857
+ gpsWeek,
3858
+ gpsTow,
3859
+ rxLat,
3860
+ rxLon,
3861
+ rxHgt,
3862
+ azel.az,
3863
+ azel.el
3864
+ );
3865
+ if (sc && si)
3866
+ sbasRows.push({
3867
+ azRad: azel.az,
3868
+ elRad: azel.el,
3869
+ variance: sc.varM2 + si.varM2 + sbasAirTropoVar(azel.el)
3870
+ });
3871
+ }
3792
3872
  }
3793
3873
  }
3874
+ const pl = sbas ? sbasProtectionLevels(sbasRows) : null;
3794
3875
  return {
3795
3876
  position: [x, y, z],
3796
3877
  clockBias: Object.fromEntries(clock),
@@ -3799,7 +3880,8 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3799
3880
  residuals,
3800
3881
  dop: computeDop(azels),
3801
3882
  iterations,
3802
- converged
3883
+ converged,
3884
+ ...pl ? { hpl: pl.hpl, vpl: pl.vpl, sbasSats: sbasRows.length } : sbas ? { sbasSats: sbasRows.length } : {}
3803
3885
  };
3804
3886
  }
3805
3887
  // Annotate the CommonJS export names for ESM import in node:
@@ -3827,6 +3909,7 @@ function solveSpp(pseudoranges, ephemerides, timeMs, opts = {}) {
3827
3909
  postProcessRtk,
3828
3910
  resolvePppAmbiguities,
3829
3911
  satClockCorrection,
3912
+ sbasProtectionLevels,
3830
3913
  solidEarthTide,
3831
3914
  solveDgnss,
3832
3915
  solvePpp,
@@ -1261,6 +1261,15 @@ interface SppSolution {
1261
1261
  dop: DopValues | null;
1262
1262
  iterations: number;
1263
1263
  converged: boolean;
1264
+ /**
1265
+ * SBAS integrity, present only when the `sbas` option was given and enough
1266
+ * corrected satellites were available. Horizontal/vertical protection levels
1267
+ * (m) — the DO-229 statistical error bounds — and the count of SBAS-corrected
1268
+ * satellites they were computed from.
1269
+ */
1270
+ hpl?: number;
1271
+ vpl?: number;
1272
+ sbasSats?: number;
1264
1273
  }
1265
1274
  /**
1266
1275
  * Broadcast satellite clock correction in seconds at time `tMs`
@@ -1273,6 +1282,26 @@ declare function satClockCorrection(eph: Ephemeris, tMs: number): number;
1273
1282
  * Removes the first-order ionospheric delay.
1274
1283
  */
1275
1284
  declare function ionoFree(p1: number, p2: number, f1: number, f2: number): number;
1285
+ /**
1286
+ * SBAS horizontal/vertical protection levels (m) from the per-satellite ENU
1287
+ * geometry and total error variances. HPL = K_H·d_major, VPL = K_V·d_U, where
1288
+ * d_major is the semi-major axis of the horizontal position-error ellipse and
1289
+ * d_U the vertical std, both from the variance-weighted least-squares
1290
+ * covariance (DO-229 §2.1.4.10). Needs ≥ 4 satellites.
1291
+ */
1292
+ declare function sbasProtectionLevels(sats: readonly {
1293
+ azRad: number;
1294
+ elRad: number;
1295
+ variance: number;
1296
+ }[], opts?: {
1297
+ kH?: number;
1298
+ kV?: number;
1299
+ }): {
1300
+ hpl: number;
1301
+ vpl: number;
1302
+ dMajor: number;
1303
+ dU: number;
1304
+ } | null;
1276
1305
  /**
1277
1306
  * Solve receiver position from one epoch of pseudoranges.
1278
1307
  *
@@ -1285,4 +1314,4 @@ declare function ionoFree(p1: number, p2: number, f1: number, f2: number): numbe
1285
1314
  */
1286
1315
  declare function solveSpp(pseudoranges: Map<string, number>, ephemerides: Map<string, Ephemeris>, timeMs: number, opts?: SppOptions): SppSolution | null;
1287
1316
 
1288
- export { type AntennaOffset, type ArFixedSat, type ArOptions, type ArResult, type ArSat, type CorrectionResult, type DgnssOptions, type DgnssSolution, type EphemerisSource, type FixedPositionResult, IONO_L1_M_PER_TECU, type KlobucharCoeffs, type LambdaResult, type NetworkFcbResult, type NetworkFcbSummary, type NlArc, type NlFcbResult, type PppAntennaModel, type PppArc, type PppCorrectionConfig, type PppCorrections, type PppEpoch, type PppEpochContext, type PppEpochResult, type PppFixState, type PppOptions, type PppSatObs, type PppSolution, type RawObservation, type RtkEpochMeasurements, RtkFloatEngine, type RtkFloatOptions, type RtkFloatSolution, type RtkMeasurement, type RtkObsEpoch, type RtkObsInput, type RtkPostProcessOptions, type RtkPostProcessResult, type RtkTrackPoint, type SatGeom, type SbasCorrectionSource, type SbasIonoDelay, SbasProcessor, type SbasSatCorrection, type SppOptions, type SppSolution, type TropoMapping, type WlArc, type WlFcbOptions, type WlFcbResult, type WlObs, buildPppAntenna, createPppCorrections, estimateNarrowlaneFcb, estimateNetworkFcbs, estimateWidelaneFcb, extractWidelaneArcs, fixPppPosition, gimSlantIonoDelayL1, gimVerticalTec, gmst, ionoFree, klobucharDelay, lambdaReduction, lambdaSearch, moonEcef, niellMapping, nlWavelength, postProcessRtk, resolvePppAmbiguities, satClockCorrection, solidEarthTide, solveDgnss, solvePpp, solveSpp, sunEcef, toRtkEpoch, wlWavelength };
1317
+ export { type AntennaOffset, type ArFixedSat, type ArOptions, type ArResult, type ArSat, type CorrectionResult, type DgnssOptions, type DgnssSolution, type EphemerisSource, type FixedPositionResult, IONO_L1_M_PER_TECU, type KlobucharCoeffs, type LambdaResult, type NetworkFcbResult, type NetworkFcbSummary, type NlArc, type NlFcbResult, type PppAntennaModel, type PppArc, type PppCorrectionConfig, type PppCorrections, type PppEpoch, type PppEpochContext, type PppEpochResult, type PppFixState, type PppOptions, type PppSatObs, type PppSolution, type RawObservation, type RtkEpochMeasurements, RtkFloatEngine, type RtkFloatOptions, type RtkFloatSolution, type RtkMeasurement, type RtkObsEpoch, type RtkObsInput, type RtkPostProcessOptions, type RtkPostProcessResult, type RtkTrackPoint, type SatGeom, type SbasCorrectionSource, type SbasIonoDelay, SbasProcessor, type SbasSatCorrection, type SppOptions, type SppSolution, type TropoMapping, type WlArc, type WlFcbOptions, type WlFcbResult, type WlObs, buildPppAntenna, createPppCorrections, estimateNarrowlaneFcb, estimateNetworkFcbs, estimateWidelaneFcb, extractWidelaneArcs, fixPppPosition, gimSlantIonoDelayL1, gimVerticalTec, gmst, ionoFree, klobucharDelay, lambdaReduction, lambdaSearch, moonEcef, niellMapping, nlWavelength, postProcessRtk, resolvePppAmbiguities, satClockCorrection, sbasProtectionLevels, solidEarthTide, solveDgnss, solvePpp, solveSpp, sunEcef, toRtkEpoch, wlWavelength };
@@ -1261,6 +1261,15 @@ interface SppSolution {
1261
1261
  dop: DopValues | null;
1262
1262
  iterations: number;
1263
1263
  converged: boolean;
1264
+ /**
1265
+ * SBAS integrity, present only when the `sbas` option was given and enough
1266
+ * corrected satellites were available. Horizontal/vertical protection levels
1267
+ * (m) — the DO-229 statistical error bounds — and the count of SBAS-corrected
1268
+ * satellites they were computed from.
1269
+ */
1270
+ hpl?: number;
1271
+ vpl?: number;
1272
+ sbasSats?: number;
1264
1273
  }
1265
1274
  /**
1266
1275
  * Broadcast satellite clock correction in seconds at time `tMs`
@@ -1273,6 +1282,26 @@ declare function satClockCorrection(eph: Ephemeris, tMs: number): number;
1273
1282
  * Removes the first-order ionospheric delay.
1274
1283
  */
1275
1284
  declare function ionoFree(p1: number, p2: number, f1: number, f2: number): number;
1285
+ /**
1286
+ * SBAS horizontal/vertical protection levels (m) from the per-satellite ENU
1287
+ * geometry and total error variances. HPL = K_H·d_major, VPL = K_V·d_U, where
1288
+ * d_major is the semi-major axis of the horizontal position-error ellipse and
1289
+ * d_U the vertical std, both from the variance-weighted least-squares
1290
+ * covariance (DO-229 §2.1.4.10). Needs ≥ 4 satellites.
1291
+ */
1292
+ declare function sbasProtectionLevels(sats: readonly {
1293
+ azRad: number;
1294
+ elRad: number;
1295
+ variance: number;
1296
+ }[], opts?: {
1297
+ kH?: number;
1298
+ kV?: number;
1299
+ }): {
1300
+ hpl: number;
1301
+ vpl: number;
1302
+ dMajor: number;
1303
+ dU: number;
1304
+ } | null;
1276
1305
  /**
1277
1306
  * Solve receiver position from one epoch of pseudoranges.
1278
1307
  *
@@ -1285,4 +1314,4 @@ declare function ionoFree(p1: number, p2: number, f1: number, f2: number): numbe
1285
1314
  */
1286
1315
  declare function solveSpp(pseudoranges: Map<string, number>, ephemerides: Map<string, Ephemeris>, timeMs: number, opts?: SppOptions): SppSolution | null;
1287
1316
 
1288
- export { type AntennaOffset, type ArFixedSat, type ArOptions, type ArResult, type ArSat, type CorrectionResult, type DgnssOptions, type DgnssSolution, type EphemerisSource, type FixedPositionResult, IONO_L1_M_PER_TECU, type KlobucharCoeffs, type LambdaResult, type NetworkFcbResult, type NetworkFcbSummary, type NlArc, type NlFcbResult, type PppAntennaModel, type PppArc, type PppCorrectionConfig, type PppCorrections, type PppEpoch, type PppEpochContext, type PppEpochResult, type PppFixState, type PppOptions, type PppSatObs, type PppSolution, type RawObservation, type RtkEpochMeasurements, RtkFloatEngine, type RtkFloatOptions, type RtkFloatSolution, type RtkMeasurement, type RtkObsEpoch, type RtkObsInput, type RtkPostProcessOptions, type RtkPostProcessResult, type RtkTrackPoint, type SatGeom, type SbasCorrectionSource, type SbasIonoDelay, SbasProcessor, type SbasSatCorrection, type SppOptions, type SppSolution, type TropoMapping, type WlArc, type WlFcbOptions, type WlFcbResult, type WlObs, buildPppAntenna, createPppCorrections, estimateNarrowlaneFcb, estimateNetworkFcbs, estimateWidelaneFcb, extractWidelaneArcs, fixPppPosition, gimSlantIonoDelayL1, gimVerticalTec, gmst, ionoFree, klobucharDelay, lambdaReduction, lambdaSearch, moonEcef, niellMapping, nlWavelength, postProcessRtk, resolvePppAmbiguities, satClockCorrection, solidEarthTide, solveDgnss, solvePpp, solveSpp, sunEcef, toRtkEpoch, wlWavelength };
1317
+ export { type AntennaOffset, type ArFixedSat, type ArOptions, type ArResult, type ArSat, type CorrectionResult, type DgnssOptions, type DgnssSolution, type EphemerisSource, type FixedPositionResult, IONO_L1_M_PER_TECU, type KlobucharCoeffs, type LambdaResult, type NetworkFcbResult, type NetworkFcbSummary, type NlArc, type NlFcbResult, type PppAntennaModel, type PppArc, type PppCorrectionConfig, type PppCorrections, type PppEpoch, type PppEpochContext, type PppEpochResult, type PppFixState, type PppOptions, type PppSatObs, type PppSolution, type RawObservation, type RtkEpochMeasurements, RtkFloatEngine, type RtkFloatOptions, type RtkFloatSolution, type RtkMeasurement, type RtkObsEpoch, type RtkObsInput, type RtkPostProcessOptions, type RtkPostProcessResult, type RtkTrackPoint, type SatGeom, type SbasCorrectionSource, type SbasIonoDelay, SbasProcessor, type SbasSatCorrection, type SppOptions, type SppSolution, type TropoMapping, type WlArc, type WlFcbOptions, type WlFcbResult, type WlObs, buildPppAntenna, createPppCorrections, estimateNarrowlaneFcb, estimateNetworkFcbs, estimateWidelaneFcb, extractWidelaneArcs, fixPppPosition, gimSlantIonoDelayL1, gimVerticalTec, gmst, ionoFree, klobucharDelay, lambdaReduction, lambdaSearch, moonEcef, niellMapping, nlWavelength, postProcessRtk, resolvePppAmbiguities, satClockCorrection, sbasProtectionLevels, solidEarthTide, solveDgnss, solvePpp, solveSpp, sunEcef, toRtkEpoch, wlWavelength };
@@ -22,6 +22,7 @@ import {
22
22
  postProcessRtk,
23
23
  resolvePppAmbiguities,
24
24
  satClockCorrection,
25
+ sbasProtectionLevels,
25
26
  solidEarthTide,
26
27
  solveDgnss,
27
28
  solvePpp,
@@ -29,7 +30,7 @@ import {
29
30
  sunEcef,
30
31
  toRtkEpoch,
31
32
  wlWavelength
32
- } from "./chunk-E3QCNJL4.js";
33
+ } from "./chunk-U32IU7RO.js";
33
34
  import "./chunk-WQX354KD.js";
34
35
  import "./chunk-MHGNKSSH.js";
35
36
  import "./chunk-MIIM4LDY.js";
@@ -65,6 +66,7 @@ export {
65
66
  postProcessRtk,
66
67
  resolvePppAmbiguities,
67
68
  satClockCorrection,
69
+ sbasProtectionLevels,
68
70
  solidEarthTide,
69
71
  solveDgnss,
70
72
  solvePpp,
package/dist/sbf.cjs CHANGED
@@ -33,6 +33,7 @@ __export(sbf_exports, {
33
33
  parseSbfIonoUtc: () => parseSbfIonoUtc,
34
34
  parseSbfMeas: () => parseSbfMeas,
35
35
  parseSbfNav: () => parseSbfNav,
36
+ parseSbfPvt: () => parseSbfPvt,
36
37
  parseSbfReceiverSetup: () => parseSbfReceiverSetup,
37
38
  sbfCrc16: () => crc16,
38
39
  scanSbfFrames: () => scanSbfFrames
@@ -601,9 +602,61 @@ function parseSbfReceiverSetup(data) {
601
602
  return out;
602
603
  }
603
604
 
605
+ // src/sbf/pvt.ts
606
+ var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
607
+ var RAD2DEG = 180 / Math.PI;
608
+ var DNU_F8 = -2e10;
609
+ var MODE_LABELS = {
610
+ 0: "no-pvt",
611
+ 1: "standalone",
612
+ 2: "differential",
613
+ 3: "fixed-location",
614
+ 4: "rtk-fixed",
615
+ 5: "rtk-float",
616
+ 6: "sbas-aided",
617
+ 7: "moving-base-rtk-fixed",
618
+ 8: "moving-base-rtk-float",
619
+ 10: "ppp"
620
+ };
621
+ function parseSbfPvt(data) {
622
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
623
+ const records = [];
624
+ let messages = 0;
625
+ scanSbfFrames(data, view, (id, b, len) => {
626
+ if (id !== 4007 || len < 96) return;
627
+ messages++;
628
+ const tow = view.getUint32(b + 8, true);
629
+ const wnc = view.getUint16(b + 12, true);
630
+ if (tow === 4294967295 || wnc === 65535) return;
631
+ const modeByte = view.getUint8(b + 14);
632
+ const modeType = modeByte & 15;
633
+ const lat = view.getFloat64(b + 16, true);
634
+ const lon = view.getFloat64(b + 24, true);
635
+ const hgt = view.getFloat64(b + 32, true);
636
+ const nrSV = view.getUint8(b + 74);
637
+ const hAcc = view.getUint16(b + 90, true);
638
+ const vAcc = view.getUint16(b + 92, true);
639
+ const hasFix = lat > DNU_F8 && lon > DNU_F8 && hgt > DNU_F8;
640
+ records.push({
641
+ timeMs: GPS_EPOCH_MS2 + wnc * 6048e5 + tow,
642
+ week: wnc,
643
+ tow: tow / 1e3,
644
+ modeType,
645
+ mode: MODE_LABELS[modeType] ?? `mode-${modeType}`,
646
+ latDeg: hasFix ? lat * RAD2DEG : null,
647
+ lonDeg: hasFix ? lon * RAD2DEG : null,
648
+ heightM: hasFix ? hgt : null,
649
+ nrSV: nrSV === 255 ? null : nrSV,
650
+ hAccuracyM: hAcc === 65535 ? null : hAcc / 100,
651
+ vAccuracyM: vAcc === 65535 ? null : vAcc / 100
652
+ });
653
+ });
654
+ return { records, messages };
655
+ }
656
+
604
657
  // src/navbits/index.ts
605
658
  var GPS_PI = 3.1415926535898;
606
- var GPS_EPOCH_MS2 = Date.UTC(1980, 0, 6);
659
+ var GPS_EPOCH_MS3 = Date.UTC(1980, 0, 6);
607
660
  var SEC_PER_WEEK2 = 7 * 86400;
608
661
  function getBitU(buff, pos, len) {
609
662
  let bits = 0;
@@ -733,13 +786,13 @@ function decodeGpsLnavFrame(subframes, opts = {}) {
733
786
  const iodc = iodc0 * 256 + iodc1;
734
787
  if (id1 !== 1 || id2 !== 2 || id3 !== 3) return null;
735
788
  if (iode3 !== iode || iode !== (iodc & 255)) return null;
736
- const ref = opts.refWeek ?? Math.floor((Date.now() - GPS_EPOCH_MS2) / 1e3 / SEC_PER_WEEK2);
789
+ const ref = opts.refWeek ?? Math.floor((Date.now() - GPS_EPOCH_MS3) / 1e3 / SEC_PER_WEEK2);
737
790
  let week = week10 + 1024 * Math.round((ref - week10) / 1024);
738
791
  if (toes < tow1 - 302400) week++;
739
792
  else if (toes > tow1 + 302400) week--;
740
793
  const prn = opts.prn ?? "G00";
741
794
  const tocDate = new Date(
742
- GPS_EPOCH_MS2 + (week * SEC_PER_WEEK2 + tocSec) * 1e3
795
+ GPS_EPOCH_MS3 + (week * SEC_PER_WEEK2 + tocSec) * 1e3
743
796
  );
744
797
  return {
745
798
  system: prn[0] === "J" ? "J" : "G",
@@ -812,7 +865,7 @@ function parseSbfGpsNav(data) {
812
865
  }
813
866
 
814
867
  // src/navbits/cnav.ts
815
- var GPS_EPOCH_MS3 = Date.UTC(1980, 0, 6);
868
+ var GPS_EPOCH_MS4 = Date.UTC(1980, 0, 6);
816
869
  var SEC_PER_WEEK3 = 7 * 86400;
817
870
  var HALF_WEEK = 302400;
818
871
  var CNAV_PREAMBLE = 139;
@@ -917,7 +970,7 @@ function resolveWeek(week, towSec, sec) {
917
970
  return week;
918
971
  }
919
972
  function gpsDate(week, sec) {
920
- return new Date(GPS_EPOCH_MS3 + (week * SEC_PER_WEEK3 + sec) * 1e3);
973
+ return new Date(GPS_EPOCH_MS4 + (week * SEC_PER_WEEK3 + sec) * 1e3);
921
974
  }
922
975
  var CnavAssembler = class {
923
976
  sats = /* @__PURE__ */ new Map();
@@ -1047,7 +1100,7 @@ function parseSbfCnav(data) {
1047
1100
  }
1048
1101
 
1049
1102
  // src/navbits/gal.ts
1050
- var GPS_EPOCH_MS4 = Date.UTC(1980, 0, 6);
1103
+ var GPS_EPOCH_MS5 = Date.UTC(1980, 0, 6);
1051
1104
  var SEC_PER_WEEK4 = 7 * 86400;
1052
1105
  var HALF_WEEK2 = 302400;
1053
1106
  var GST_GPS_WEEK_OFFSET = 1024;
@@ -1060,7 +1113,7 @@ function galFnavPageCrcOk(page) {
1060
1113
  return crc24q(page, 214) === getBitU(page, 214, 24);
1061
1114
  }
1062
1115
  function gpsDate2(week, sec) {
1063
- return new Date(GPS_EPOCH_MS4 + (week * SEC_PER_WEEK4 + sec) * 1e3);
1116
+ return new Date(GPS_EPOCH_MS5 + (week * SEC_PER_WEEK4 + sec) * 1e3);
1064
1117
  }
1065
1118
  function weekOfToe(week, tow, toe) {
1066
1119
  if (toe - tow > HALF_WEEK2) return week - 1;
@@ -1691,7 +1744,7 @@ var BdsAssembler = class {
1691
1744
  };
1692
1745
 
1693
1746
  // src/navbits/glo.ts
1694
- var GPS_EPOCH_MS5 = Date.UTC(1980, 0, 6);
1747
+ var GPS_EPOCH_MS6 = Date.UTC(1980, 0, 6);
1695
1748
  var SEC_PER_WEEK6 = 7 * 86400;
1696
1749
  var SEC_PER_DAY = 86400;
1697
1750
  var GLO_STRING_BYTES = 10;
@@ -1785,7 +1838,7 @@ function decodeGloStrings(strings, refDate, opts = {}) {
1785
1838
  const slot = getBitU(b, i, 5);
1786
1839
  if (frn1 !== 1 || frn2 !== 2 || frn3 !== 3 || frn4 !== 4) return null;
1787
1840
  if (slot < 1 || slot > 27) return null;
1788
- const utcSec = (getUtcDate(refDate).getTime() - GPS_EPOCH_MS5) / 1e3;
1841
+ const utcSec = (getUtcDate(refDate).getTime() - GPS_EPOCH_MS6) / 1e3;
1789
1842
  const week = Math.floor(utcSec / SEC_PER_WEEK6);
1790
1843
  let tow = utcSec - week * SEC_PER_WEEK6;
1791
1844
  const tod = tow % SEC_PER_DAY;
@@ -1800,7 +1853,7 @@ function decodeGloStrings(strings, refDate, opts = {}) {
1800
1853
  system: "R",
1801
1854
  prn: `R${String(slot).padStart(2, "0")}`,
1802
1855
  // RINEX GLONASS epochs are UTC: build the UTC toe Date directly.
1803
- tocDate: new Date(GPS_EPOCH_MS5 + (week * SEC_PER_WEEK6 + tow + toe) * 1e3),
1856
+ tocDate: new Date(GPS_EPOCH_MS6 + (week * SEC_PER_WEEK6 + tow + toe) * 1e3),
1804
1857
  tauN: -tauN,
1805
1858
  // RINEX stores −τn; the SIS carries τn (ICD sign)
1806
1859
  gammaN,
@@ -1854,7 +1907,7 @@ var GloStringAssembler = class {
1854
1907
  };
1855
1908
 
1856
1909
  // src/sbf/rawnav-bds.ts
1857
- var GPS_EPOCH_MS6 = Date.UTC(1980, 0, 6);
1910
+ var GPS_EPOCH_MS7 = Date.UTC(1980, 0, 6);
1858
1911
  var MS_PER_WEEK3 = 7 * 86400 * 1e3;
1859
1912
  var TOW_DNU = 4294967295;
1860
1913
  var WNC_DNU2 = 65535;
@@ -1915,7 +1968,7 @@ function feedGloBlock(view, b, assembler) {
1915
1968
  const eph = assembler.push(
1916
1969
  prn,
1917
1970
  str2,
1918
- new Date(GPS_EPOCH_MS6 + wnc * MS_PER_WEEK3 + towMs),
1971
+ new Date(GPS_EPOCH_MS7 + wnc * MS_PER_WEEK3 + towMs),
1919
1972
  view.getUint8(b + 18) - 8
1920
1973
  // FreqNr, offset by 8
1921
1974
  );
@@ -1938,7 +1991,7 @@ function parseSbfGloNav(data) {
1938
1991
  }
1939
1992
 
1940
1993
  // src/navbits/sbas.ts
1941
- var GPS_EPOCH_MS7 = Date.UTC(1980, 0, 6);
1994
+ var GPS_EPOCH_MS8 = Date.UTC(1980, 0, 6);
1942
1995
  var MS_PER_WEEK4 = 7 * 86400 * 1e3;
1943
1996
  var two3 = (n) => String(n).padStart(2, "0");
1944
1997
  var SBAS_MT_GEO_NAV = 9;
@@ -1960,7 +2013,7 @@ function decodeSbasGeoNav(msg, prn, week, tow) {
1960
2013
  return {
1961
2014
  system: "S",
1962
2015
  prn: `S${two3(prn - 100)}`,
1963
- tocDate: new Date(GPS_EPOCH_MS7 + week * MS_PER_WEEK4 + t0Sec * 1e3),
2016
+ tocDate: new Date(GPS_EPOCH_MS8 + week * MS_PER_WEEK4 + t0Sec * 1e3),
1964
2017
  tauN: getBitS(msg, 206, 12) * 2 ** -31,
1965
2018
  // a_Gf0, clock offset (s)
1966
2019
  gammaN: getBitS(msg, 218, 8) * 2 ** -39 / 2,
@@ -2708,7 +2761,7 @@ function parseSbfHas(data) {
2708
2761
 
2709
2762
  // src/sbf/index.ts
2710
2763
  var CLIGHT = 299792458;
2711
- var GPS_EPOCH_MS8 = Date.UTC(1980, 0, 6);
2764
+ var GPS_EPOCH_MS9 = Date.UTC(1980, 0, 6);
2712
2765
  var MS_PER_WEEK5 = 7 * 864e5;
2713
2766
  var M3_SYS = ["G", "R", "E", "C", "S", "J", "I"];
2714
2767
  var M3_PR_BASE = [19e6, 19e6, 22e6, 2e7, 34e6, 34e6, 34e6];
@@ -3362,7 +3415,7 @@ function parseSbfMeas(data) {
3362
3415
  const tow = view.getUint32(i + 8, true);
3363
3416
  const wnc = view.getUint16(i + 12, true);
3364
3417
  if (tow !== 4294967295 && wnc !== 65535) {
3365
- ensureEpoch(GPS_EPOCH_MS8 + wnc * MS_PER_WEEK5 + tow);
3418
+ ensureEpoch(GPS_EPOCH_MS9 + wnc * MS_PER_WEEK5 + tow);
3366
3419
  if (id === 4109) decodeMeas3Ranges(i, tow);
3367
3420
  else if (id === 4110) decodeMeas3CN0(i, len);
3368
3421
  else if (id === 4111) decodeMeas3Doppler(i, len);
@@ -3388,6 +3441,7 @@ function parseSbfMeas(data) {
3388
3441
  parseSbfIonoUtc,
3389
3442
  parseSbfMeas,
3390
3443
  parseSbfNav,
3444
+ parseSbfPvt,
3391
3445
  parseSbfReceiverSetup,
3392
3446
  sbfCrc16,
3393
3447
  scanSbfFrames
package/dist/sbf.d.cts CHANGED
@@ -124,6 +124,35 @@ interface SbfReceiverSetup {
124
124
  */
125
125
  declare function parseSbfReceiverSetup(data: Uint8Array): SbfReceiverSetup | null;
126
126
 
127
+ interface SbfPvt {
128
+ /** GPS-scale epoch time (ms). */
129
+ timeMs: number;
130
+ week: number;
131
+ /** Time of week (s). */
132
+ tow: number;
133
+ /** PVT solution type (Mode & 0x0F). */
134
+ modeType: number;
135
+ /** Human label for `modeType` ('standalone', 'sbas-aided', 'rtk-fixed', …). */
136
+ mode: string;
137
+ /** Geodetic position, or null when the receiver has no fix this epoch. */
138
+ latDeg: number | null;
139
+ lonDeg: number | null;
140
+ heightM: number | null;
141
+ /** Satellites used in the receiver's solution. */
142
+ nrSV: number | null;
143
+ /** Receiver 2-σ horizontal accuracy estimate (m), or null. */
144
+ hAccuracyM: number | null;
145
+ /** Receiver 2-σ vertical accuracy estimate (m), or null. */
146
+ vAccuracyM: number | null;
147
+ }
148
+ interface SbfPvtResult {
149
+ records: SbfPvt[];
150
+ /** PVTGeodetic blocks seen (with valid framing). */
151
+ messages: number;
152
+ }
153
+ /** Decode every PVTGeodetic (4007) block in an SBF byte stream. */
154
+ declare function parseSbfPvt(data: Uint8Array): SbfPvtResult;
155
+
127
156
  /**
128
157
  * Septentrio SBF raw GPS / QZSS LNAV navigation-bit blocks: GPSRawCA
129
158
  * (4017) and QZSRawL1CA (4066) each carry one 300-bit L1 C/A (LNAV)
@@ -634,4 +663,4 @@ interface SbfParseResult {
634
663
  */
635
664
  declare function parseSbfMeas(data: Uint8Array): SbfParseResult;
636
665
 
637
- export { CnavEphemeris, type HasMessage, type SbfBdsNavResult, type SbfCnavEphemeris, type SbfCnavResult, type SbfGalEphemeris, type SbfGalNavResult, type SbfGeoNavResult, type SbfGloNavResult, type SbfGpsNavResult, type SbfHasMessage, type SbfHasResult, type SbfIonoUtcResult, type SbfMeasEpoch, type SbfMeasurement, type SbfNavCounts, type SbfNavigation, type SbfParseResult, type SbfReceiverSetup, decodeSbfNavigation, feedGeoBlock, parseSbfBdsNav, parseSbfCnav, parseSbfGalNav, parseSbfGeoNav, parseSbfGloNav, parseSbfGpsNav, parseSbfHas, parseSbfIonoUtc, parseSbfMeas, parseSbfReceiverSetup, crc16 as sbfCrc16, scanSbfFrames };
666
+ export { CnavEphemeris, type HasMessage, type SbfBdsNavResult, type SbfCnavEphemeris, type SbfCnavResult, type SbfGalEphemeris, type SbfGalNavResult, type SbfGeoNavResult, type SbfGloNavResult, type SbfGpsNavResult, type SbfHasMessage, type SbfHasResult, type SbfIonoUtcResult, type SbfMeasEpoch, type SbfMeasurement, type SbfNavCounts, type SbfNavigation, type SbfParseResult, type SbfPvt, type SbfPvtResult, type SbfReceiverSetup, decodeSbfNavigation, feedGeoBlock, parseSbfBdsNav, parseSbfCnav, parseSbfGalNav, parseSbfGeoNav, parseSbfGloNav, parseSbfGpsNav, parseSbfHas, parseSbfIonoUtc, parseSbfMeas, parseSbfPvt, parseSbfReceiverSetup, crc16 as sbfCrc16, scanSbfFrames };
package/dist/sbf.d.ts CHANGED
@@ -124,6 +124,35 @@ interface SbfReceiverSetup {
124
124
  */
125
125
  declare function parseSbfReceiverSetup(data: Uint8Array): SbfReceiverSetup | null;
126
126
 
127
+ interface SbfPvt {
128
+ /** GPS-scale epoch time (ms). */
129
+ timeMs: number;
130
+ week: number;
131
+ /** Time of week (s). */
132
+ tow: number;
133
+ /** PVT solution type (Mode & 0x0F). */
134
+ modeType: number;
135
+ /** Human label for `modeType` ('standalone', 'sbas-aided', 'rtk-fixed', …). */
136
+ mode: string;
137
+ /** Geodetic position, or null when the receiver has no fix this epoch. */
138
+ latDeg: number | null;
139
+ lonDeg: number | null;
140
+ heightM: number | null;
141
+ /** Satellites used in the receiver's solution. */
142
+ nrSV: number | null;
143
+ /** Receiver 2-σ horizontal accuracy estimate (m), or null. */
144
+ hAccuracyM: number | null;
145
+ /** Receiver 2-σ vertical accuracy estimate (m), or null. */
146
+ vAccuracyM: number | null;
147
+ }
148
+ interface SbfPvtResult {
149
+ records: SbfPvt[];
150
+ /** PVTGeodetic blocks seen (with valid framing). */
151
+ messages: number;
152
+ }
153
+ /** Decode every PVTGeodetic (4007) block in an SBF byte stream. */
154
+ declare function parseSbfPvt(data: Uint8Array): SbfPvtResult;
155
+
127
156
  /**
128
157
  * Septentrio SBF raw GPS / QZSS LNAV navigation-bit blocks: GPSRawCA
129
158
  * (4017) and QZSRawL1CA (4066) each carry one 300-bit L1 C/A (LNAV)
@@ -634,4 +663,4 @@ interface SbfParseResult {
634
663
  */
635
664
  declare function parseSbfMeas(data: Uint8Array): SbfParseResult;
636
665
 
637
- export { CnavEphemeris, type HasMessage, type SbfBdsNavResult, type SbfCnavEphemeris, type SbfCnavResult, type SbfGalEphemeris, type SbfGalNavResult, type SbfGeoNavResult, type SbfGloNavResult, type SbfGpsNavResult, type SbfHasMessage, type SbfHasResult, type SbfIonoUtcResult, type SbfMeasEpoch, type SbfMeasurement, type SbfNavCounts, type SbfNavigation, type SbfParseResult, type SbfReceiverSetup, decodeSbfNavigation, feedGeoBlock, parseSbfBdsNav, parseSbfCnav, parseSbfGalNav, parseSbfGeoNav, parseSbfGloNav, parseSbfGpsNav, parseSbfHas, parseSbfIonoUtc, parseSbfMeas, parseSbfReceiverSetup, crc16 as sbfCrc16, scanSbfFrames };
666
+ export { CnavEphemeris, type HasMessage, type SbfBdsNavResult, type SbfCnavEphemeris, type SbfCnavResult, type SbfGalEphemeris, type SbfGalNavResult, type SbfGeoNavResult, type SbfGloNavResult, type SbfGpsNavResult, type SbfHasMessage, type SbfHasResult, type SbfIonoUtcResult, type SbfMeasEpoch, type SbfMeasurement, type SbfNavCounts, type SbfNavigation, type SbfParseResult, type SbfPvt, type SbfPvtResult, type SbfReceiverSetup, decodeSbfNavigation, feedGeoBlock, parseSbfBdsNav, parseSbfCnav, parseSbfGalNav, parseSbfGeoNav, parseSbfGloNav, parseSbfGpsNav, parseSbfHas, parseSbfIonoUtc, parseSbfMeas, parseSbfPvt, parseSbfReceiverSetup, crc16 as sbfCrc16, scanSbfFrames };
package/dist/sbf.js CHANGED
@@ -13,9 +13,10 @@ import {
13
13
  parseSbfIonoUtc,
14
14
  parseSbfMeas,
15
15
  parseSbfNav,
16
+ parseSbfPvt,
16
17
  parseSbfReceiverSetup,
17
18
  scanSbfFrames
18
- } from "./chunk-DE5IUULR.js";
19
+ } from "./chunk-ZPNMIUNZ.js";
19
20
  import "./chunk-FA2UTLEQ.js";
20
21
  import "./chunk-WQX354KD.js";
21
22
  import "./chunk-37QNKGTC.js";
@@ -38,6 +39,7 @@ export {
38
39
  parseSbfIonoUtc,
39
40
  parseSbfMeas,
40
41
  parseSbfNav,
42
+ parseSbfPvt,
41
43
  parseSbfReceiverSetup,
42
44
  crc16 as sbfCrc16,
43
45
  scanSbfFrames
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gnss-js",
3
- "version": "1.51.0",
3
+ "version": "1.53.0",
4
4
  "description": "Comprehensive GNSS library for JavaScript — time scales, coordinates, RINEX parsing, RTCM3 decoding, orbit computation, and signal analysis",
5
5
  "type": "module",
6
6
  "sideEffects": false,