Skip to content

Commit

Permalink
Merge pull request #2 from kasethi23/eta_api
Browse files Browse the repository at this point in the history
Update eta.py after group demo
  • Loading branch information
rodrigotiscareno authored Mar 16, 2024
2 parents c7ed123 + 687bd85 commit 8f26425
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions eta_microservice/eta.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ class ETAQuery():
def __init__(self, lat, lon):
self.lat = lat
self.lon = lon
self.route_model = pd.read_csv(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../eta_microservice/data/route_model_db.csv')))
self.checkpoint_model = pd.read_csv(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../eta_microservice/data/checkpoint_model_db.csv')))
route_model_path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'eta_microservice', 'data', 'route_model_db.csv')) #changed it for interoperability between unix and windows
checkpoint_model_path = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'eta_microservice', 'data', 'checkpoint_model_db.csv'))
# Read CSV files
self.route_model = pd.read_csv(route_model_path)
self.checkpoint_model = pd.read_csv(checkpoint_model_path)

self.checkpoint_coords = self.checkpoint_model.loc[:, ['latitude', 'longitude']].values.tolist()
self.ckpt_to_route_model_index = self.checkpoint_model.loc[:, ['route_model_index']].values.tolist()
self.eta_to_checkpoint = []
Expand Down Expand Up @@ -88,4 +92,7 @@ def get_time_to_point(self, lat, lon):
@return: float representing the time it takes to reach a given point
"""
closest_point = self.find_closest_point(lat, lon)
return self.eta[closest_point['checkpoint']]
return self.eta[closest_point['checkpoint']]



0 comments on commit 8f26425

Please sign in to comment.