-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpx_export.rs
More file actions
61 lines (53 loc) · 2.18 KB
/
Copy pathgpx_export.rs
File metadata and controls
61 lines (53 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//! GPX Export Example
//!
//! Demonstrates how to export GPS data to GPX format for use with mapping applications.
//! The parser module now fully supports GPS frame parsing (G-frames and H-frames).
use bbl_parser::{export_to_gpx, parse_bbl_file, ExportOptions};
use std::path::Path;
fn main() -> anyhow::Result<()> {
// Get input file from command line or show usage
let input_file = std::env::args().nth(1).unwrap_or_else(|| {
println!("Usage: gpx_export <input.BBL> [output_dir]");
println!("Example: gpx_export flight.BBL ./output");
println!("Note: GPS export requires GPS data in the BBL file");
std::process::exit(1);
});
// Get optional output directory from command line
let output_dir = std::env::args().nth(2).map(|s| s.to_string());
// Configure export options - GPX export enabled
let export_opts = ExportOptions {
csv: false,
gpx: true,
event: false,
output_dir: output_dir.clone(),
force_export: false,
};
// Parse the BBL file
println!("Parsing: {}", input_file);
let log = parse_bbl_file(Path::new(&input_file), export_opts.clone(), false)?;
// Display log information
println!("\nLog Information:");
println!(" Total G frames (GPS): {}", log.stats.g_frames);
println!(" Total H frames (Home): {}", log.stats.h_frames);
println!(" GPS coordinates collected: {}", log.gps_coordinates.len());
// Export GPS data if available
if !log.gps_coordinates.is_empty() {
println!("\nExporting to GPX...");
export_to_gpx(
Path::new(&input_file),
0, // log index
log.total_logs,
&log.gps_coordinates,
&log.home_coordinates,
&export_opts,
log.header.log_start_datetime.as_deref(),
)?;
println!("✓ GPX export complete");
println!(" Exported {} GPS coordinates", log.gps_coordinates.len());
} else {
println!("\n⊘ No GPS coordinates available");
println!("Note: This BBL file may not contain GPS data (no G-frames).");
println!("Check that your flight controller has GPS enabled and connected.");
}
Ok(())
}