Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate tracks by classification #6

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "track2kml"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
authors = [
"Alejandro Perea ([email protected])",
Expand Down
3 changes: 3 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "track2kml-cli"
version = "2.3.1"
version = "2.4.0"
edition = "2021"
authors = [
"Alejandro Perea ([email protected])",
Expand Down
33 changes: 30 additions & 3 deletions src/kml/tracking.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -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(())
Expand Down
Loading