diff --git a/CHANGELOG.md b/CHANGELOG.md index f2086dd..c716977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ These refer to the track2kml crate versions. +## 0.4.2 +- Separate track records by classification: Create one KML track per set of records with the same classification in a COURAGEOUS track. + ## 0.4.1 - Implement UAV home location representation in kml. diff --git a/Cargo.toml b/Cargo.toml index 04b13ce..6d633f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "track2kml" -version = "0.4.1" +version = "0.4.2" edition = "2021" authors = [ "Alejandro Perea (aleok.inf@gmail.com)", diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 313c76d..9f53e33 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.4.0 +- Separate track records by classification: Create one KML track per set of records with the same classification in a COURAGEOUS track. + ## 2.3.1 - Implement UAV home location representation. diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d65c477..8df1a14 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "track2kml-cli" -version = "2.3.1" +version = "2.4.0" edition = "2021" authors = [ "Alejandro Perea (aleok.inf@gmail.com)", diff --git a/src/kml/tracking.rs b/src/kml/tracking.rs index a926353..202ff4d 100644 --- a/src/kml/tracking.rs +++ b/src/kml/tracking.rs @@ -1,4 +1,4 @@ -use courageous_format::{Arc, Location, Position3d, Track, TrackingRecord}; +use courageous_format::{Arc, Classification, Location, Position3d, Track, TrackingRecord}; use quick_xml::{events::BytesText, Writer}; use time::{format_description::well_known::Rfc3339, OffsetDateTime}; @@ -21,8 +21,35 @@ pub fn write_track_set( x.create_element("name") .write_text_content(BytesText::new("Tracks"))?; - for detection in set { - write_track(x, detection, static_cuas_origin, cuas_range)?; + for track in set { + let filter_track_with_classification = + |mut track: Track, classification: Classification| { + track.records.retain(|r| r.classification == classification); + let name = track + .name + .get_or_insert_with(|| format!("Unnamed track (UAS ID {})", track.uas_id)); + match classification { + Classification::Unknown => *name += " (Unknown)", + Classification::Uav => *name += " (UAV)", + Classification::Gcs => *name += " (GCS)", + Classification::Other => *name += " (Other)", + } + + track + }; + const CLASSIFICATIONS: [Classification; 4] = [ + Classification::Uav, + Classification::Gcs, + Classification::Other, + Classification::Unknown, + ]; + for track in + CLASSIFICATIONS.map(|cls| filter_track_with_classification(track.clone(), cls)) + { + if !track.records.is_empty() { + write_track(x, &track, static_cuas_origin, cuas_range)?; + } + } } Ok(())