Skip to content

Commit

Permalink
Changes to the way the data is presented.
Browse files Browse the repository at this point in the history
  • Loading branch information
wliu416 committed Feb 16, 2020
1 parent bf5d37f commit 42dcdec
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
23 changes: 21 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import places as places
import PlacesAPI as placesApi
import userpref as userpref
import map

if __name__ == "__main__":
#Get user input
Expand Down Expand Up @@ -72,9 +73,27 @@
break
'''
if len(places) != 0:
good = placesApi.find_route([place['place_id'] for place in places])
print(placesApi.find_route([place['place_id'] for place in places]))
print("Done")

lst_loc = []
raw = good['origin_addresses']
raw.reverse()
for elements in raw:
lst_loc.append(elements)
raw2 = good['destination_addresses']
for e2 in raw2:
lst_loc.append(e2)
print("here is your itinerary, a list of addresses in order.")
print(lst_loc)


else:
print("Sorry, the algorithm did not return any results.")

print("The Algorithm has finished running. Enjoy your trip!")





#Call api functions
Expand Down
26 changes: 26 additions & 0 deletions map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import googlemaps
from datetime import datetime

gmaps = googlemaps.Client(key="AIzaSyBYhkmFKfz745tUYWf5CskwslxKan6M_-E")


# Request directions via public transit

def return_dir(locations):
now = datetime.now()
concat = ""
for loc in locations[1:-2]:
concat += loc + '|'
concat = concat[:-1]
directions_result = gmaps.directions(
locations[0],locations[-1],mode="walking",departure_time=now,waypoints=concat)
return directions_result


"""
if __name__ == '__main__':
print(return_dir(['Bahen Center', 'Myhal Center', 'Leslie Dan']))
acc = return_dir(['Bahen Center', 'Myhal Center', 'Leslie Dan'])
for legs in acc['legs']:
print(acc[legs]["html_instructions"])
"""

0 comments on commit 42dcdec

Please sign in to comment.