Rust Local Dynamic Map (LDM)
The rustflexstack::facilities::local_dynamic_map module implements the Local Dynamic Map of ETSI EN 302 895: an in-memory store of received CAMs, DENMs and VAMs, with the data-provider interface IF.LDM.3 and the data-consumer interface IF.LDM.4.
Architecture
flowchart TD
subgraph FAC["<b>LdmFacility</b> (ETSI EN 302 895)"]
IF3["<b>IF.LDM.3</b> (data providers)<br/>register / add / update / delete"]
IF4["<b>IF.LDM.4</b> (data consumers)<br/>register / request / subscribe"]
SVC["<b>LdmService</b><br/>request handling and subscriptions"]
STORE[("<b>LdmStore</b><br/>in-memory records")]
MAINT["<b>LdmMaintenance</b> thread<br/>expiry and area check every second"]
IF3 --> SVC
IF4 --> SVC
SVC --> STORE
MAINT --> STORE
end
style FAC fill:#f8fafc,stroke:#94a3b8,stroke-width:2px
style IF3 fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px
style IF4 fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px
style SVC fill:#f3e8ff,stroke:#7c3aed,stroke-width:1.5px
style STORE fill:#fef3c7,stroke:#d97706,stroke-width:2px
style MAINT fill:#fee2e2,stroke:#dc2626,stroke-width:1.5px
Creating the LDM and Reading CAMs
LdmFacility::new takes the centre of the area of interest (latitude and longitude in tenths of a microdegree) and its radius in metres, and returns a shared handle:
use rustflexstack::facilities::local_dynamic_map::{
ldm_constants::ITS_AID_CAM,
ldm_types::{RegisterDataConsumerReq, RegisterDataProviderReq, RequestDataObjectsReq},
ItsDataObject, LdmFacility,
};
let (lat, lon) = (41.3851_f64, 2.1734_f64);
let ldm = LdmFacility::new((lat * 1e7) as i32, (lon * 1e7) as i32, 5_000.0);
ldm.if_ldm_3.register_data_provider(RegisterDataProviderReq { application_id: ITS_AID_CAM });
ldm.if_ldm_4.register_data_consumer(RegisterDataConsumerReq { application_id: ITS_AID_CAM });
let resp = ldm.if_ldm_4.request_data_objects(RequestDataObjectsReq {
application_id: ITS_AID_CAM,
data_object_types: vec![ITS_AID_CAM],
filter: None,
order: None,
max_results: None,
});
for entry in &resp.data_objects {
if let ItsDataObject::Cam(cam) = &entry.data_object {
println!("CAM from station {:?} at ({}, {})", cam.header.station_id, entry.lat_etsi, entry.lon_etsi);
}
}
The handle is given to the CA, DEN and VRU services, which store the messages they receive. The area centre follows the station: ldm.area_center.update(lat_etsi, lon_etsi).