Crates.io | titanic |
lib.rs | titanic |
version | 0.1.0 |
source | src |
created_at | 2018-09-06 13:09:17.497696 |
updated_at | 2018-09-06 13:09:17.497696 |
description | Unsinkable parser for the GGA sentence of the NMEA 0183 protocol (parses GPS positions). |
homepage | |
repository | https://github.com/49nord/titanic-rs |
max_upload_size | |
id | 83165 |
size | 79,615 |
This is a parser for the GGA sentence of the NMEA 0183 protocol.
More sentences may be added in the future, but are not planned at the moment. Accepts data as described here.
Add this to Cargo.toml
:
[dependencies]
titanic = "0.1.0"
Then put this in your crate root:
extern crate titanic;
GgaParser
can be used like an
Iterator
.
Calling next
on GgaParser
blocks until
'$'
,'$'
signals the beginning of a new sentence. If the new sentence is of the
type GGA, it will be parsed if possible. The parser iterates over
Result<GgaSentence, ParseError>
.
EOF signals the end of the iterator.
# extern crate titanic;
# use std::io::Cursor;
use titanic::GgaParser;
let data = Cursor::new("$GPGGA,142212.000,1956.9418,S,06938.0163,W,1,3,5.74,102.1,M,47.9,M,,*57");
let parser = GgaParser::new(data).unwrap();
for gga in parser {
let gga = gga.unwrap();
println!(
"Time: {}, we are here: {}°, {}°",
gga.utc.format("%H:%M:%S"),
gga.lat.unwrap(),
gga.long.unwrap()
);
}
// Prints "Time: 14:22:12, we are here: -19.94903°, -69.633605°"