# Aniker GPS A Rust library for parsing NMEA GPS sentences. ## Features - Parse GGA sentences to extract latitude, longitude, altitude, and more - Support for different units of measurement (meters, feet) - Comprehensive error handling with custom error types - Simple and efficient API ## Usage Add this to your `Cargo.toml`: ```toml [dependencies] aniker-gps = "0.1.0" ``` ### Example ```rust use aniker_gps::{parse_gga, GpsError}; fn main() { // Example NMEA GGA sentence let mut gga_example = "$GPGGA,210230,3855.4487,N,09446.0071,W,1,07,1.1,370.5,M,-29.5,M,,*7A".to_string(); // Parse the GGA sentence and handle the result match parse_gga(&mut gga_example) { Ok(position) => { println!("Latitude: {}", position.lat); println!("Longitude: {}", position.long); println!("Altitude: {} {}", position.alt, position.altitude_unit); println!("Geoid Separation: {} {}", position.geoid_separation, position.geoid_unit); } Err(e) => { println!("Error parsing GGA sentence:"); match e { GpsError::InvalidMessageType => println!(" Invalid message type, expected GGA"), GpsError::InvalidLength => println!(" Invalid GGA sentence length"), GpsError::ParseError(msg) => println!(" Parse error: {}", msg), GpsError::Other(msg) => println!(" Other error: {}", msg), } } } } ``` ## Error Handling The library provides a custom `GpsError` enum for error handling: ```rust pub enum GpsError { /// Invalid message type (not GGA) InvalidMessageType, /// Invalid sentence length InvalidLength, /// Error parsing a numeric field ParseError(String), /// Other errors Other(String), } ``` This allows for more detailed error handling and better error messages. ## GGA Sentence Format The GGA sentence contains the following fields: - Sentence type (checked for "GGA") - Current time (UTC) - Latitude (in DDMM.MMM format) - Latitude compass direction (N/S) - Longitude (in DDDMM.MMM format) - Longitude compass direction (E/W) - Fix type (0 for no fix, 1 for GPS, 2 for DGPS) - Number of satellites used for fix - Horizontal dilution of precision - Altitude above mean sea level - Altitude units (M for meters, F for feet) - Height of mean sea level above WGS-84 earth ellipsoid - Units of the above geoid separation (M for meters, F for feet) - Time since last differential correction (if available) - Differential station ID (if available) - Checksum validation value ## License This project is licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) at your option.