From 8f184bff3cdc263becb6e936a171d73856e69321 Mon Sep 17 00:00:00 2001 From: Jeromos Kovacs Date: Thu, 4 Jul 2024 19:42:40 +0200 Subject: [PATCH] docs: added readme --- README.md | 23 +++++++++++++++++++++++ src/main.rs | 22 +++++++++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..f098f95 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# fit2gpx-rs + +## Purpose + +This is a simple Rust library and binary for converting .FIT files to .GPX files. +A faster alternative to [fit2gpx](https://github.com/dodo-saba/fit2gpx) + +- [FIT](https://developer.garmin.com/fit/overview/) is a GIS data file format used by Garmin GPS sport devices and Garmin software +- [GPX](https://docs.fileformat.com/gis/gpx/) is an XML based format for GPS tracks. + +## Why another one + +- cause it's 70 times as fast +- cause it's fun + +## Why not this one + +- it doesn't support strava bulk-export stuff + +## Deps + +- [fit-rust](https://crates.io/crates/fit-rust) +- [gpx](https://crates.io/crates/gpx) diff --git a/src/main.rs b/src/main.rs index 7d659f3..ecf566b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,8 +30,7 @@ struct RecordData { impl RecordData { // crazy check fn invalid(&self) -> bool { - (self.lat.is_some_and(|lat| lat == 0.) && self.lon.is_some_and(|lon| lon == 0.)) - || (self.lat.is_none() && self.lon.is_none()) + self.lat.is_none() && self.lon.is_none() } } impl From for RecordData { @@ -123,16 +122,17 @@ fn main() { fn fit2gpx(f_in: &String) { let file = fs::read(f_in).unwrap(); let fit: Fit = Fit::read(file).unwrap(); + eprintln!("-----------------------------------\n\n\nfile: {f_in}"); // let mut log_file = File::create([f_in, ".log"].concat()).unwrap(); - println!("\n\nHEADER:"); - println!("\theader size: {}", &fit.header.header_size); - println!("\tprotocol version: {}", &fit.header.protocol_version); - println!("\tprofile version: {}", &fit.header.profile_version); - println!("\tdata_size: {}", &fit.header.data_size); - println!("\tdata_type: {}", &fit.header.data_type); - println!("\tcrc: {:?}", &fit.header.crc); - println!("-----------------------------\n"); + // println!("\n\nHEADER:"); + // println!("\theader size: {}", &fit.header.header_size); + // println!("\tprotocol version: {}", &fit.header.protocol_version); + // println!("\tprofile version: {}", &fit.header.profile_version); + // println!("\tdata_size: {}", &fit.header.data_size); + // println!("\tdata_type: {}", &fit.header.data_type); + // println!("\tcrc: {:?}", &fit.header.crc); + // println!("-----------------------------\n"); let mut track_segment = TrackSegment { points: vec![] }; let mut ongoing_activity = true; @@ -148,7 +148,7 @@ fn fit2gpx(f_in: &String) { if let MessageType::Record = msg.data.message_type { let rec_dat: RecordData = msg.data.clone().into(); if rec_dat.invalid() { - eprintln!("warn: guess it's invalid: {msg:#?}"); + eprintln!("warn: guess it's invalid, as it doesn't contain lat/lon data: {msg:#?}"); continue; } // eprintln!("{rec_dat:#?}");