Skip to content

Commit

Permalink
docs: added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovacs committed Jul 4, 2024
1 parent 143ebfa commit 8f184bf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
22 changes: 11 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataMessage> for RecordData {
Expand Down Expand Up @@ -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;
Expand All @@ -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:#?}");
Expand Down

0 comments on commit 8f184bf

Please sign in to comment.