From 0257ba9d7384da3b855b87040ba9551ef02947cd Mon Sep 17 00:00:00 2001 From: aleokdev Date: Tue, 20 Feb 2024 14:45:21 +0100 Subject: [PATCH 1/3] Separate tracks by classification --- src/kml/tracking.rs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/kml/tracking.rs b/src/kml/tracking.rs index a926353..7933eed 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,33 @@ 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); + if let Some(name) = &mut track.name { + 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(()) From 35123c96fbeb9f6660cc7da29eafb550cb7ac34a Mon Sep 17 00:00:00 2001 From: aleokdev Date: Tue, 20 Feb 2024 14:54:10 +0100 Subject: [PATCH 2/3] Update changelogs & versions --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- cli/CHANGELOG.md | 3 +++ cli/Cargo.toml | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) 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)", From 0b0ff94cc78a7da6c20f6c7cb3abcbd4da1d31f3 Mon Sep 17 00:00:00 2001 From: aleokdev Date: Mon, 26 Feb 2024 11:06:51 +0100 Subject: [PATCH 3/3] Address PR comment --- src/kml/tracking.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/kml/tracking.rs b/src/kml/tracking.rs index 7933eed..202ff4d 100644 --- a/src/kml/tracking.rs +++ b/src/kml/tracking.rs @@ -25,14 +25,16 @@ pub fn write_track_set( let filter_track_with_classification = |mut track: Track, classification: Classification| { track.records.retain(|r| r.classification == classification); - if let Some(name) = &mut track.name { - match classification { - Classification::Unknown => *name += " (Unknown)", - Classification::Uav => *name += " (UAV)", - Classification::Gcs => *name += " (GCS)", - Classification::Other => *name += " (Other)", - } + 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] = [