mirror of
https://github.com/Vale54321/BigData.git
synced 2025-12-13 02:49:32 +01:00
fix read_adsb_lonlat_by_aircraft function
This commit is contained in:
committed by
GitHub
parent
5bcdb1a0fd
commit
71e874676a
@@ -28,23 +28,25 @@ def catalan_list(n: int) -> List[int]:
|
|||||||
|
|
||||||
|
|
||||||
def read_adsb_lonlat_by_aircraft(path: str) -> Dict[str, Tuple[List[float], List[float]]]:
|
def read_adsb_lonlat_by_aircraft(path: str) -> Dict[str, Tuple[List[float], List[float]]]:
|
||||||
flights: Dict[str, Tuple[List[float], List[float]]] = {}
|
flights = {}
|
||||||
with open(path, "r", encoding="utf-8") as f:
|
with open(path, "r", encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
parts = line.strip().split()
|
raw = line.strip()
|
||||||
|
if not raw:
|
||||||
|
continue
|
||||||
|
# CSV mit Kommas bevorzugen, sonst whitespace
|
||||||
|
parts = [p.strip() for p in raw.split(",")] if "," in raw else raw.split()
|
||||||
if len(parts) < 6:
|
if len(parts) < 6:
|
||||||
continue
|
continue
|
||||||
ac_id = parts[0]
|
ac_id = parts[0]
|
||||||
# parts[4] = lat, parts[5] = lon (laut Aufgabenbeschreibung)
|
|
||||||
try:
|
try:
|
||||||
lat = float(parts[4])
|
lat = float(parts[4])
|
||||||
lon = float(parts[5])
|
lon = float(parts[5])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
if ac_id not in flights:
|
lons, lats = flights.setdefault(ac_id, ([], []))
|
||||||
flights[ac_id] = ([], [])
|
lons.append(lon)
|
||||||
flights[ac_id][0].append(lon)
|
lats.append(lat)
|
||||||
flights[ac_id][1].append(lat)
|
|
||||||
return flights
|
return flights
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user