pub struct GnssData {
pub time: Option<String>,
pub latitude: Option<f64>,
pub longitude: Option<f64>,
pub fix_quality: Option<u8>,
pub num_satellites: Option<u8>,
pub altitude: Option<f64>,
pub speed_knots: Option<f64>,
pub track_angle: Option<f64>,
pub date: Option<String>,
pub systems: HashMap<&'static str, GnssSystemData>,
pub fused_position: Option<FusedPosition>,
}Expand description
Main GNSS data structure holding parsed information and fused position.
Fields§
§time: Option<String>UTC time from NMEA sentence
latitude: Option<f64>Latitude in decimal degrees
longitude: Option<f64>Longitude in decimal degrees
fix_quality: Option<u8>Fix quality indicator
num_satellites: Option<u8>Number of satellites used for fix
altitude: Option<f64>Altitude above mean sea level in meters
speed_knots: Option<f64>Speed over ground in knots
track_angle: Option<f64>Track angle in degrees
date: Option<String>Date in DDMMYY format
systems: HashMap<&'static str, GnssSystemData>Data for each GNSS system
fused_position: Option<FusedPosition>Fused position calculated from available systems
Implementations§
Source§impl GnssData
impl GnssData
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new GnssData instance with all supported GNSS systems initialized.
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let gnss = GnssData::new();Sourcepub fn feed_nmea(&mut self, sentence: &str)
pub fn feed_nmea(&mut self, sentence: &str)
Feeds a single NMEA sentence to the parser and updates internal state.
§Arguments
sentence- A string slice containing the NMEA sentence.
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let mut gnss = GnssData::new();
gnss.feed_nmea("$GNGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47");Sourcepub fn calculate_fused_position(&mut self)
pub fn calculate_fused_position(&mut self)
Calculates a fused position from all available GNSS systems using weighted averaging.
The fused position is stored in self.fused_position.
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let mut gnss = GnssData::new();
gnss.calculate_fused_position();
if let Some(fused) = &gnss.fused_position {
println!("Fused position: {}, {}", fused.latitude, fused.longitude);
}Sourcepub fn calculate_advanced_fused_position(&mut self)
pub fn calculate_advanced_fused_position(&mut self)
Calculates an advanced fused position using a Kalman-like filtering approach.
The fused position is stored in self.fused_position.
Sourcepub fn get_fused_accuracy(&self) -> f64
pub fn get_fused_accuracy(&self) -> f64
Gets the fused data accuracy in meters.
§Returns
f64- The fused accuracy value in meters
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let gnss = GnssData::new();
// The fused accuracy is calculated using RSS formula from active system accuracies
assert!((gnss.get_fused_accuracy() - 1.37).abs() < 0.01);Sourcepub fn set_fused_accuracy(&mut self, _accuracy: f64)
pub fn set_fused_accuracy(&mut self, _accuracy: f64)
Sets the fused data accuracy in meters.
§Arguments
accuracy- The fused accuracy value in meters
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let mut gnss = GnssData::new();
gnss.set_fused_accuracy(3.0);
// Fused accuracy is always dynamically calculated, not set by this function
let fused_accuracy = gnss.get_fused_accuracy();
assert!((fused_accuracy - 1.3675).abs() < 0.01);Sourcepub fn get_system_accuracy(&self, system: &str) -> Option<f64>
pub fn get_system_accuracy(&self, system: &str) -> Option<f64>
Gets the dynamic accuracy for a specific GNSS system in meters.
§Arguments
system- The GNSS system name (“GPS”, “GLONASS”, “GALILEO”, “BEIDOU”)
§Returns
Option<f64>- The system accuracy value in meters, or None if system doesn’t exist
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let gnss = GnssData::new();
assert_eq!(gnss.get_system_accuracy("GPS"), Some(2.0));
assert_eq!(gnss.get_system_accuracy("GLONASS"), Some(4.0));Sourcepub fn get_system_fixed_accuracy(&self, system: &str) -> Option<f64>
pub fn get_system_fixed_accuracy(&self, system: &str) -> Option<f64>
Gets the fixed accuracy for a specific GNSS system in meters.
§Arguments
system- The GNSS system name (“GPS”, “GLONASS”, “GALILEO”, “BEIDOU”)
§Returns
Option<f64>- The fixed accuracy value in meters, or None if the system doesn’t exist
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let gnss = GnssData::new();
assert_eq!(gnss.get_system_fixed_accuracy("GPS"), Some(2.0));
assert_eq!(gnss.get_system_fixed_accuracy("GLONASS"), Some(4.0));Sourcepub fn set_system_fixed_accuracy(&mut self, system: &str, accuracy: f64) -> bool
pub fn set_system_fixed_accuracy(&mut self, system: &str, accuracy: f64) -> bool
Sets the accuracy for a specific GNSS system in meters.
§Arguments
system- The GNSS system name (“GPS”, “GLONASS”, “GALILEO”, “BEIDOU”)accuracy- The system accuracy value in meters
§Returns
bool- True if the system exists and accuracy was set, false otherwise
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let mut gnss = GnssData::new();
assert!(gnss.set_system_fixed_accuracy("GPS", 1.5));
assert_eq!(gnss.get_system_fixed_accuracy("GPS"), Some(1.5));
assert!(!gnss.set_system_fixed_accuracy("INVALID", 1.0));Sourcepub fn get_all_system_accuracies(&self) -> HashMap<String, f64>
pub fn get_all_system_accuracies(&self) -> HashMap<String, f64>
Gets all system accuracies as a HashMap.
§Returns
HashMap<String, f64>- Map of system names to their accuracy values in meters
§Example
use nema_parser::gnss_multignss_parser::GnssData;
let gnss = GnssData::new();
let accuracies = gnss.get_all_system_accuracies();
assert_eq!(accuracies.get("GPS"), Some(&2.0));
assert_eq!(accuracies.get("GLONASS"), Some(&4.0));