```
feat(protocol): Observation坐标字段可选化及协议v2扩展 - 将Observation中longitude/latitude/altitude_m/heading_deg改为Option类型, 支持无位置信息的观测数据 - 新增DeviceTelemetry结构体承载设备遥测扩展字段(serial, mac, model, rssi, speed, vertical_speed, pressure_altitude, geometric_altitude, height_agl, pilot_position等) - 新增LegacyObservation兼容结构体及From转换,保持旧接收器协议输入兼容 - PROTOCOL_VERSION从1升至2 - 新增coordinates()辅助方法统一提取有效坐标 - validate()适配Option类型,允许坐标字段同时缺失 - Store新增position_generation机制追踪位置可用性变化,确保合并帧间的 位置丢失仍能正确断开轨迹 - geofence-map-adapter过滤无效坐标避免渲染异常 - 新增appearance.css外观主题系统,支持blue/graphite/white三套配色 ```
This commit is contained in:
@@ -19,10 +19,11 @@ fn main() {
|
||||
receiver_id: "SIM".into(),
|
||||
source_epoch: 1,
|
||||
sequence,
|
||||
longitude: 120.0 + id as f64 * 0.00001,
|
||||
latitude: 30.0,
|
||||
altitude_m: 100.0,
|
||||
heading_deg: 90.0,
|
||||
longitude: Some(120.0 + id as f64 * 0.00001),
|
||||
latitude: Some(30.0),
|
||||
altitude_m: Some(100.0),
|
||||
heading_deg: Some(90.0),
|
||||
telemetry: None,
|
||||
},
|
||||
sequence,
|
||||
);
|
||||
|
||||
@@ -53,12 +53,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
receiver_id: "SIMULATOR".into(),
|
||||
source_epoch: epoch,
|
||||
sequence,
|
||||
longitude: 120.0
|
||||
+ (id as f64).cos() * 0.1
|
||||
+ ((sequence as f64) * 0.01).sin() * 0.005,
|
||||
latitude: 30.0 + (id as f64).sin() * 0.1,
|
||||
altitude_m: 100.0,
|
||||
heading_deg: (id % 360) as f32,
|
||||
longitude: Some(
|
||||
120.0 + (id as f64).cos() * 0.1 + ((sequence as f64) * 0.01).sin() * 0.005,
|
||||
),
|
||||
latitude: Some(30.0 + (id as f64).sin() * 0.1),
|
||||
altitude_m: Some(100.0),
|
||||
heading_deg: Some((id % 360) as f32),
|
||||
telemetry: None,
|
||||
})
|
||||
.collect();
|
||||
let body = postcard::to_allocvec(&batch)?;
|
||||
|
||||
@@ -72,7 +72,13 @@ impl Store {
|
||||
observation.receiver_id.clone(),
|
||||
(observation.source_epoch, observation.sequence),
|
||||
);
|
||||
let position_generation = track.target.position_generation
|
||||
+ u64::from(
|
||||
track.target.observation.coordinates().is_some()
|
||||
!= observation.coordinates().is_some(),
|
||||
);
|
||||
track.target = Target {
|
||||
position_generation,
|
||||
observation,
|
||||
received_at_ms: now_ms,
|
||||
};
|
||||
@@ -89,6 +95,7 @@ impl Store {
|
||||
id.clone(),
|
||||
Track {
|
||||
target: Target {
|
||||
position_generation: 0,
|
||||
observation,
|
||||
received_at_ms: now_ms,
|
||||
},
|
||||
@@ -175,13 +182,29 @@ mod tests {
|
||||
receiver_id: "station-1".into(),
|
||||
source_epoch: 1,
|
||||
sequence,
|
||||
longitude: 120.0,
|
||||
latitude: 30.0,
|
||||
altitude_m: 100.0,
|
||||
heading_deg: 90.0,
|
||||
longitude: Some(120.0),
|
||||
latitude: Some(30.0),
|
||||
altitude_m: Some(100.0),
|
||||
heading_deg: Some(90.0),
|
||||
telemetry: None,
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn coalesced_position_loss_still_breaks_the_trail() {
|
||||
let mut store = Store::new(10, 100, 30000, 1);
|
||||
let a = sample("TEST", 1);
|
||||
store.apply(a, 1);
|
||||
let mut b = sample("TEST", 2);
|
||||
b.longitude = None;
|
||||
b.latitude = None;
|
||||
store.apply(b, 2);
|
||||
store.apply(sample("TEST", 3), 3);
|
||||
let frame = store.frame(Some(1), 3);
|
||||
assert_eq!(frame.targets.len(), 1);
|
||||
assert_eq!(frame.targets[0].position_generation, 2);
|
||||
assert!(frame.targets[0].observation.coordinates().is_some());
|
||||
}
|
||||
#[test]
|
||||
fn stale_and_capacity_are_bounded() {
|
||||
let mut s = Store::new(1, 4, 100, 1);
|
||||
assert!(s.apply(sample("a", 2), 0));
|
||||
@@ -212,7 +235,7 @@ mod tests {
|
||||
fn rejects_invalid_values_and_previous_source_session() {
|
||||
let mut s = Store::new(2, 4, 100, 1);
|
||||
let mut a = sample("a", 1);
|
||||
a.longitude = f64::NAN;
|
||||
a.longitude = Some(f64::NAN);
|
||||
assert!(!s.apply(a, 0));
|
||||
let mut a = sample("a", 1);
|
||||
a.source_epoch = 2;
|
||||
|
||||
Reference in New Issue
Block a user