cot_proto/tak/
create.rs

1use chrono::Utc;
2
3use crate::base::{Cot, Point};
4
5use super::detail::TakMarkerDetail;
6
7/// Support for creating TAK CoT messages with reasonable defaults for quickly getting integration
8/// working.
9///
10/// Instead of providing builder APIs, we implement [`Default`] on different CoT variants: You'll
11/// want to modify key fields like `point` with your real coordinates. For example:
12/// ```rust
13/// use cot_proto::base::{Cot, Point};
14/// use cot_proto::tak::detail::TakMarkerDetail;
15/// let mut cot = Cot::<TakMarkerDetail>::default();
16/// cot.point.lat = 10.0;
17/// cot.point.lon = 90.0;
18/// let xml_text = quick_xml::se::to_string(&cot).unwrap();
19/// ```
20
21/// Default CoT type for marker messages.
22pub const DEFAULT_COT_TYPE_MARKER: &str = "a-o-G";
23
24/// TAK CoT Marker
25impl Default for Cot<TakMarkerDetail> {
26    fn default() -> Self {
27        let now = Utc::now();
28        let detail = TakMarkerDetail {
29            ..Default::default()
30        };
31        Self {
32            version: "2.0".to_string(),
33            uid: uuid::Uuid::new_v4().to_string(),
34            cot_type: DEFAULT_COT_TYPE_MARKER.to_string(),
35            time: now,
36            start: now,
37            // now plus 1 day
38            stale: now + chrono::Duration::days(1),
39            how: Some("m-g".to_string()),
40            detail,
41            point: Point::north_pole(),
42        }
43    }
44}