fix: GPS缺失下的数据缺失问题

This commit is contained in:
2026-04-18 13:12:54 +08:00
parent 2ca70d556b
commit 5fdb42b5ed
3 changed files with 42 additions and 13 deletions

View File

@@ -105,13 +105,30 @@ class GpsDataService:
}
def _build_payload_from_metadata(self, metadata: FrameTrailerMetadata) -> dict[str, Any]:
timestamp_seconds = metadata.timestamp_ns / 1_000_000_000
updated_at = _utc_from_epoch(metadata.received_at) or ""
if not metadata.has_gps_fix:
return {
"has_fix": False,
"utc_time": "--:--:--",
"latitude": None,
"longitude": None,
"raw_latitude_hex": f"0x{metadata.raw_latitude_hex}",
"raw_longitude_hex": f"0x{metadata.raw_longitude_hex}",
"satellites": None,
"altitude_m": None,
"coordinate_system": "WGS84",
"source_sentence": "VIDEO_TRAILER",
"raw_coordinate_format": VIDEO_TRAILER_COORDINATE_FORMAT,
"source_mode": "video-frame-trailer-no-fix",
"updated_at": updated_at,
}
timestamp_seconds = metadata.timestamp_ns / 1_000_000_000
return {
"has_fix": True,
"utc_time": datetime.fromtimestamp(timestamp_seconds, timezone.utc).strftime("%H:%M:%S"),
"latitude": round(metadata.latitude, 6),
"longitude": round(metadata.longitude, 6),
"latitude": round(metadata.latitude, 6) if metadata.latitude is not None else None,
"longitude": round(metadata.longitude, 6) if metadata.longitude is not None else None,
"raw_latitude_hex": f"0x{metadata.raw_latitude_hex}",
"raw_longitude_hex": f"0x{metadata.raw_longitude_hex}",
"satellites": None,