|
|
|
@ -1,5 +1,26 @@
|
|
|
|
|
#https://www.geeksforgeeks.org/python-calculate-distance-between-two-places-using-geopy/ |
|
|
|
|
#https://openflights.org/data.html |
|
|
|
|
def DownloadAirports(): |
|
|
|
|
import os |
|
|
|
|
if not os.path.isfile('airports.dat'): |
|
|
|
|
print("No airports.dat file, downloading now") |
|
|
|
|
try: |
|
|
|
|
import requests |
|
|
|
|
url = 'https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat' |
|
|
|
|
airports = requests.get(url) |
|
|
|
|
|
|
|
|
|
open('airports.dat', 'wb').write(airports.content) |
|
|
|
|
except: |
|
|
|
|
raise("Error getting airports.dat or storing") |
|
|
|
|
else: |
|
|
|
|
#Writes current date to airports.dat to show when it was aqquired |
|
|
|
|
import datetime |
|
|
|
|
date = datetime.datetime.now() |
|
|
|
|
with open('airports.dat', 'a') as airports: |
|
|
|
|
airports.write("#" + str(date)) |
|
|
|
|
print("Successfully got airports.dat") |
|
|
|
|
elif os.path.isfile('airports.dat'): |
|
|
|
|
print("Already Have airports.dat, continuing") |
|
|
|
|
def getClosestAirport(latitude, longitude): |
|
|
|
|
import json |
|
|
|
|
import csv |
|
|
|
|