sidereon_core/spp/
source.rs1use crate::id::GnssSatelliteId;
4use crate::sp3::{MmapPreciseEphemerisInterpolant, PreciseEphemerisInterpolant, Sp3};
5
6pub trait EphemerisSource {
15 fn position_clock_at_j2000_s(
17 &self,
18 sat: GnssSatelliteId,
19 t_j2000_s: f64,
20 ) -> Option<([f64; 3], f64)>;
21}
22
23impl EphemerisSource for Sp3 {
24 fn position_clock_at_j2000_s(
25 &self,
26 sat: GnssSatelliteId,
27 t_j2000_s: f64,
28 ) -> Option<([f64; 3], f64)> {
29 let state = self.position_at_j2000_seconds(sat, t_j2000_s).ok()?;
30 let clk = state.clock_s?;
31 Some((state.position.as_array(), clk))
32 }
33}
34
35impl EphemerisSource for PreciseEphemerisInterpolant {
36 fn position_clock_at_j2000_s(
37 &self,
38 sat: GnssSatelliteId,
39 t_j2000_s: f64,
40 ) -> Option<([f64; 3], f64)> {
41 let state = self.position_at_j2000_seconds(sat, t_j2000_s).ok()?;
42 let clk = state.clock_s?;
43 Some((state.position.as_array(), clk))
44 }
45}
46
47impl EphemerisSource for MmapPreciseEphemerisInterpolant<'_> {
48 fn position_clock_at_j2000_s(
49 &self,
50 sat: GnssSatelliteId,
51 t_j2000_s: f64,
52 ) -> Option<([f64; 3], f64)> {
53 let state = self.position_at_j2000_seconds(sat, t_j2000_s).ok()?;
54 let clk = state.clock_s?;
55 Some((state.position.as_array(), clk))
56 }
57}