Skip to content

Commit d7c9745

Browse files
authored
Develop (#42)
* Remove commented out section - Make Utf8Buffer public * Tracker: add more public functions * Formatting: make Utf8Buffer public and format API as well --------- Signed-off-by: Guillaume W. Bres <[email protected]>
1 parent 6459059 commit d7c9745

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
* Documentation: https://github.com/rtk-rs/cggtts
1212
*/
1313

14-
// #[cfg(feature = "tracker")]
15-
// #[cfg_attr(docsrs, doc(cfg(feature = "tracker")))]
16-
// pub mod tracker;
17-
1814
extern crate gnss_rs as gnss;
1915

2016
use gnss::prelude::{Constellation, SV};
@@ -43,11 +39,10 @@ mod tracker;
4339
#[cfg(test)]
4440
mod tests;
4541

42+
pub mod buffer;
4643
pub mod errors;
4744
pub mod track;
4845

49-
pub(crate) mod buffer;
50-
5146
#[cfg(feature = "serde")]
5247
#[macro_use]
5348
extern crate serde;

src/track/formatting.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ fn fmt_saturated_f64(nb: f64, scaling: f64, sat: i64, padding: usize) -> String
2222
}
2323

2424
impl Track {
25-
pub(crate) fn format<W: Write>(
25+
/// Format [Track] into mutable [BufWriter].
26+
/// Requires a pre-allocated [Utf8Buffer].
27+
pub fn format<W: Write>(
2628
&self,
2729
writer: &mut BufWriter<W>,
2830
buffer: &mut Utf8Buffer,

src/tracker/fit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ use crate::prelude::{Duration, Epoch, FittedData, SV};
99
/// CGGTTS track formation errors
1010
#[derive(Debug, Clone, Error)]
1111
pub enum FitError {
12+
/// Unknown satellite (not tracked at all)
13+
#[error("unknown satellite (not tracked at all)")]
14+
UnknownSatellite,
1215
/// At least two symbols are required to fit
1316
#[error("track fitting requires at least 3 observations")]
1417
NotEnoughSymbols,

src/tracker/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,19 @@ impl SkyTracker {
4646
self.trackers.insert(satellite, new);
4747
}
4848
}
49+
50+
/// Attempt new satellite track fitting.
51+
/// ## Input
52+
/// - satellite: [SV] that must have been tracked.
53+
/// That tracking duration might have to respect external requirements.
54+
/// ## Output
55+
/// - fitted: [FittedData] that you can turn into a valid
56+
/// CGGTTS track if you provide a little more information.
57+
pub fn track_fit(&mut self, satellite: SV) -> Result<FittedData, FitError> {
58+
if let Some(sv) = self.trackers.get_mut(&satellite) {
59+
sv.fit()
60+
} else {
61+
Err(FitError::UnknownSatellite)
62+
}
63+
}
4964
}

0 commit comments

Comments
 (0)