Added video url parser to CoT types

This commit is contained in:
2026-03-31 07:19:39 -03:00
parent 469a54c141
commit 3f14a75e81
5 changed files with 59 additions and 0 deletions

View File

@@ -16,9 +16,18 @@ pub struct CursorOverTime {
pub track_speed: Option<f32>,
pub link_uid: Option<String>,
pub remarker: Option<String>,
pub video_url: Option<String>,
}
impl CursorOverTime {
fn escape_xml_attribute(value: &str) -> String {
value
.replace('&', "&amp;")
.replace('"', "&quot;")
.replace('<', "&lt;")
.replace('>', "&gt;")
}
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!("<remarks>ARMATAK | {}</remarks>", 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("</detail></event>");
return xml;

View File

@@ -40,6 +40,8 @@ impl DigitalPointerPayload {
track_speed: None,
link_uid: Some(self.link_uid.clone()),
remarker: None,
video_url: None,
}
}
}

View File

@@ -57,6 +57,8 @@ impl EudCoTPayload {
track_speed: Some(self.track_speed),
link_uid: None,
remarker: None,
video_url: None,
}
}
}

View File

@@ -54,6 +54,8 @@ impl ExternalPositionPayload {
track_speed: Some(self.track_speed),
link_uid: None,
remarker: Some(self.remarker.clone()),
video_url: None,
}
}
}

View File

@@ -11,10 +11,40 @@ pub struct MarkerCoTPayload {
pub contact_callsign: String,
pub track_course: i32,
pub track_speed: f32,
pub video_url: Option<String>,
}
impl FromArma for MarkerCoTPayload {
fn from_arma(data: String) -> Result<MarkerCoTPayload, FromArmaError> {
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(),
}
}
}