Spaces:
Sleeping
Sleeping
souvik0306
commited on
Commit
•
bb56ab3
1
Parent(s):
f393e1f
Refactor airport data loading and update airport options
Browse files- app.py +3 -3
- flight_distance.py +7 -9
app.py
CHANGED
@@ -4,9 +4,9 @@ from map_generator import *
|
|
4 |
from flight_distance import *
|
5 |
from optimize import *
|
6 |
from weather import *
|
7 |
-
|
8 |
-
airport_df = pd.
|
9 |
-
aircraft_df = pd.read_csv(r'aircraft.csv')
|
10 |
|
11 |
airport_options = [f"{row['IATA']} - {row['Airport_Name']} - {row['Country']}" for _, row in airport_df.iterrows()]
|
12 |
airports_dict = {row['IATA']: row['Airport_Name'] for _, row in airport_df.iterrows()} # For map display
|
|
|
4 |
from flight_distance import *
|
5 |
from optimize import *
|
6 |
from weather import *
|
7 |
+
|
8 |
+
airport_df = pd.read_csv(r'airport.csv')
|
9 |
+
aircraft_df = pd.read_csv(r'aircraft.csv')
|
10 |
|
11 |
airport_options = [f"{row['IATA']} - {row['Airport_Name']} - {row['Country']}" for _, row in airport_df.iterrows()]
|
12 |
airports_dict = {row['IATA']: row['Airport_Name'] for _, row in airport_df.iterrows()} # For map display
|
flight_distance.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pandas as pd
|
2 |
from math import radians, sin, cos, sqrt, asin
|
|
|
3 |
|
4 |
### Modular Flight Calculation Functions ###
|
5 |
|
@@ -23,15 +24,12 @@ def get_airport_lat_long(identifiers):
|
|
23 |
"""
|
24 |
Get latitude and longitude for a list of airport identifiers (IATA codes).
|
25 |
"""
|
26 |
-
csv_file = 'airport.csv'
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
except FileNotFoundError:
|
33 |
-
# If parquet file is not found, fall back to reading the CSV file
|
34 |
-
df = pd.read_csv(csv_file)
|
35 |
|
36 |
df_filtered = df[df['Airport_Name'].isin(identifiers) | df['IATA'].isin(identifiers)]
|
37 |
lat_long_dict = {row['IATA']: (row['Lat'], row['Long']) for _, row in df_filtered.iterrows()}
|
|
|
1 |
import pandas as pd
|
2 |
from math import radians, sin, cos, sqrt, asin
|
3 |
+
import time
|
4 |
|
5 |
### Modular Flight Calculation Functions ###
|
6 |
|
|
|
24 |
"""
|
25 |
Get latitude and longitude for a list of airport identifiers (IATA codes).
|
26 |
"""
|
27 |
+
csv_file = 'airport.csv'
|
28 |
+
|
29 |
+
start_time = time.time()
|
30 |
+
df = pd.read_csv(csv_file)
|
31 |
+
read_time = time.time() - start_time
|
32 |
+
print(f"CSV file read in {read_time:.4f} seconds")
|
|
|
|
|
|
|
33 |
|
34 |
df_filtered = df[df['Airport_Name'].isin(identifiers) | df['IATA'].isin(identifiers)]
|
35 |
lat_long_dict = {row['IATA']: (row['Lat'], row['Long']) for _, row in df_filtered.iterrows()}
|