forked from wiedehopf/tar1090-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathap.py
34 lines (25 loc) · 848 Bytes
/
ap.py
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
import json, re
ap = {}
with open("airports.json") as jsonFile:
ap = json.load(jsonFile)
out = {}
table = ap['airports']
for a in table:
if 'icao_code' in a and 'coordinates' in a:
dupe = 0
icao = a['icao_code']
if not re.search(r'\d', icao, 0):
if icao in out:
print(icao)
print(out[icao])
dupe = 1
if not 'faa_lid' in a:
continue
out[icao] = [a['coordinates']['latitude'], a['coordinates']['longitude']]
if dupe == 1:
print(out[icao])
if 'iata_code' in a and 'coordinates' in a:
iata = a['iata_code']
out[iata] = [a['coordinates']['latitude'], a['coordinates']['longitude']]
with open('lookup.json', 'w') as outFile:
json.dump(out, outFile)