Skip to content

Commit 3caed50

Browse files
committed
Rewrite time module in pure Rust
1 parent 9693bcd commit 3caed50

File tree

9 files changed

+2314
-1718
lines changed

9 files changed

+2314
-1718
lines changed

swiftnav/src/ephemeris.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl Ephemeris {
320320
let result = unsafe {
321321
swiftnav_sys::calc_sat_state(
322322
&self.0,
323-
t.c_ptr(),
323+
&t.to_gps_time_t(),
324324
sat.pos.as_mut_array_ref(),
325325
sat.vel.as_mut_array_ref(),
326326
sat.acc.as_mut_array_ref(),
@@ -348,7 +348,7 @@ impl Ephemeris {
348348
let result = unsafe {
349349
swiftnav_sys::calc_sat_az_el(
350350
&self.0,
351-
t.c_ptr(),
351+
&t.to_gps_time_t(),
352352
pos.as_array_ref(),
353353
swiftnav_sys::satellite_orbit_type_t_MEO,
354354
&mut sat.az,
@@ -377,7 +377,7 @@ impl Ephemeris {
377377
let result = unsafe {
378378
swiftnav_sys::calc_sat_doppler(
379379
&self.0,
380-
t.c_ptr(),
380+
&t.to_gps_time_t(),
381381
pos.as_array_ref(),
382382
vel.as_array_ref(),
383383
swiftnav_sys::satellite_orbit_type_t_MEO,
@@ -401,13 +401,13 @@ impl Ephemeris {
401401

402402
pub fn detailed_status(&self, t: GpsTime) -> Status {
403403
Status::from_ephemeris_status_t(unsafe {
404-
swiftnav_sys::ephemeris_valid_detailed(&self.0, t.c_ptr())
404+
swiftnav_sys::ephemeris_valid_detailed(&self.0, &t.to_gps_time_t())
405405
})
406406
}
407407

408408
/// Is this ephemeris usable?
409409
pub fn is_valid_at_time(&self, t: GpsTime) -> bool {
410-
let result = unsafe { swiftnav_sys::ephemeris_valid(&self.0, t.c_ptr()) };
410+
let result = unsafe { swiftnav_sys::ephemeris_valid(&self.0, &t.to_gps_time_t()) };
411411
result == 1
412412
}
413413

swiftnav/src/ionosphere.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl Ionosphere {
7373
/// * IS-GPS-200H, Section 20.3.3.5.1.7
7474
pub fn decode_parameters(words: &[u32; 8]) -> Result<Ionosphere, IonoDecodeFailure> {
7575
let mut iono = Ionosphere(swiftnav_sys::ionosphere_t {
76-
toa: GpsTime::unknown(),
76+
toa: GpsTime::new_unchecked(0, 0.0).to_gps_time_t(),
7777
a0: 0.0,
7878
a1: 0.0,
7979
a2: 0.0,
@@ -104,7 +104,7 @@ impl Ionosphere {
104104
///
105105
/// \return Ionospheric delay distance for GPS L1 frequency \[m\]
106106
pub fn calc_delay(&self, t: &GpsTime, lat_u: f64, lon_u: f64, a: f64, e: f64) -> f64 {
107-
unsafe { swiftnav_sys::calc_ionosphere(t.c_ptr(), lat_u, lon_u, a, e, &self.0) }
107+
unsafe { swiftnav_sys::calc_ionosphere(&t.to_gps_time_t(), lat_u, lon_u, a, e, &self.0) }
108108
}
109109
}
110110

swiftnav/src/solver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ pub fn calc_pvt(
416416
swiftnav_sys::calc_PVT(
417417
measurements.len() as u8,
418418
meas_ptr,
419-
tor.c_ptr(),
419+
&tor.to_gps_time_t(),
420420
settings.disable_raim,
421421
settings.disable_velocity,
422422
&obs_config,

0 commit comments

Comments
 (0)