From 3f14a75e814155864186754cb5065a944eaa9fb5 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Tue, 31 Mar 2026 07:19:39 -0300 Subject: [PATCH] Added video url parser to CoT types --- src/cot/cot.rs | 21 +++++++++++++++++++++ src/cot/digital_pointer.rs | 2 ++ src/cot/eud.rs | 2 ++ src/cot/gps.rs | 2 ++ src/cot/nato.rs | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 59 insertions(+) diff --git a/src/cot/cot.rs b/src/cot/cot.rs index c749e66..0177905 100644 --- a/src/cot/cot.rs +++ b/src/cot/cot.rs @@ -16,9 +16,18 @@ pub struct CursorOverTime { pub track_speed: Option, pub link_uid: Option, pub remarker: Option, + pub video_url: Option, } impl CursorOverTime { + fn escape_xml_attribute(value: &str) -> String { + value + .replace('&', "&") + .replace('"', """) + .replace('<', "<") + .replace('>', ">") + } + pub fn convert_to_xml(&self) -> String { let uuid = match &self.uuid { Some(uuid) => uuid, @@ -107,6 +116,18 @@ impl CursorOverTime { xml.push_str(format!("ARMATAK | {}", remark).as_str()); } + if let Some(video_url) = &self.video_url { + if !video_url.trim().is_empty() { + xml.push_str( + format!( + "<__video url=\"{}\" />", + Self::escape_xml_attribute(video_url.trim()) + ) + .as_str(), + ); + } + } + xml.push_str(""); return xml; diff --git a/src/cot/digital_pointer.rs b/src/cot/digital_pointer.rs index 2b73a4d..762bb45 100644 --- a/src/cot/digital_pointer.rs +++ b/src/cot/digital_pointer.rs @@ -40,6 +40,8 @@ impl DigitalPointerPayload { track_speed: None, link_uid: Some(self.link_uid.clone()), remarker: None, + video_url: None, } } } + diff --git a/src/cot/eud.rs b/src/cot/eud.rs index 50e01fa..30b5481 100644 --- a/src/cot/eud.rs +++ b/src/cot/eud.rs @@ -57,6 +57,8 @@ impl EudCoTPayload { track_speed: Some(self.track_speed), link_uid: None, remarker: None, + video_url: None, } } } + diff --git a/src/cot/gps.rs b/src/cot/gps.rs index fa70c8f..8fad780 100644 --- a/src/cot/gps.rs +++ b/src/cot/gps.rs @@ -54,6 +54,8 @@ impl ExternalPositionPayload { track_speed: Some(self.track_speed), link_uid: None, remarker: Some(self.remarker.clone()), + video_url: None, } } } + diff --git a/src/cot/nato.rs b/src/cot/nato.rs index c8b5c98..515c370 100644 --- a/src/cot/nato.rs +++ b/src/cot/nato.rs @@ -11,10 +11,40 @@ pub struct MarkerCoTPayload { pub contact_callsign: String, pub track_course: i32, pub track_speed: f32, + pub video_url: Option, } impl FromArma for MarkerCoTPayload { fn from_arma(data: String) -> Result { + if let Ok(( + uuid, + r#type, + point_lat, + point_lon, + point_hae, + contact_callsign, + track_course, + track_speed, + video_url, + )) = <(String, String, f64, f64, f32, String, i32, f32, String)>::from_arma(data.clone()) + { + return Ok(Self { + uuid, + r#type, + point_lat, + point_lon, + point_hae, + contact_callsign, + track_course, + track_speed, + video_url: if video_url.trim().is_empty() { + None + } else { + Some(video_url) + }, + }); + } + let ( uuid, r#type, @@ -34,6 +64,7 @@ impl FromArma for MarkerCoTPayload { contact_callsign, track_course, track_speed, + video_url: None, }) } } @@ -55,6 +86,7 @@ impl MarkerCoTPayload { track_speed: Some(self.track_speed), link_uid: None, remarker: None, + video_url: self.video_url.clone(), } } }