forked from VATGER-Nav/mapbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_process.py
More file actions
84 lines (69 loc) · 2.19 KB
/
batch_process.py
File metadata and controls
84 lines (69 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
"""
Batch process multiple airports from OSM to GNG format
Usage: python batch_process.py
"""
import subprocess
import sys
# Define airports to process
AIRPORTS = [
{'icao': 'CYHZ', 'name': 'Halifax', 'fir': 'CZQM'},
{'icao': 'CYYT', 'name': 'St Johns', 'fir': 'CZQX'},
{'icao': 'CYQM', 'name': 'Greater Moncton', 'fir': 'CZQM'},
{'icao': 'CYSJ', 'name': 'Saint John', 'fir': 'CZQM'},
{'icao': 'CYFC', 'name': 'Fredericton', 'fir': 'CZQM'},
]
def process_airport(airport):
"""Process a single airport"""
icao = airport['icao']
name = airport['name']
fir = airport['fir']
print(f"\n{'='*60}")
print(f"Processing {icao} - {name} ({fir})")
print(f"{'='*60}")
cmd = [
'python',
'osm_to_gng_direct.py',
icao,
'--name', name,
'--fir', fir,
'--output', f'output/{icao}_gng.kml'
]
try:
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
print(result.stdout)
return True
except subprocess.CalledProcessError as e:
print(f"ERROR processing {icao}:", file=sys.stderr)
print(e.stderr, file=sys.stderr)
return False
def main():
"""Process all airports"""
print("CZQM/CZQX Airport Ground Network Batch Processor")
print(f"Processing {len(AIRPORTS)} airports...\n")
# Create output directory if needed
import os
os.makedirs('output', exist_ok=True)
success_count = 0
failed = []
for airport in AIRPORTS:
if process_airport(airport):
success_count += 1
else:
failed.append(airport['icao'])
# Summary
print(f"\n{'='*60}")
print(f"SUMMARY")
print(f"{'='*60}")
print(f"Successful: {success_count}/{len(AIRPORTS)}")
if failed:
print(f"Failed: {', '.join(failed)}")
else:
print("All airports processed successfully!")
print(f"\nOutput files in: output/")
print(f"\nNext steps:")
print(f" 1. Review KML files in Google Earth (optional)")
print(f" 2. Import each *_gng.kml file into GNG")
print(f" 3. Export to EuroScope format")
if __name__ == "__main__":
main()