diff --git a/main.py b/main.py index b9f5f2c..25b2e94 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,7 @@ #import places as places import PlacesAPI as placesApi import userpref as userpref +import map if __name__ == "__main__": #Get user input @@ -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 diff --git a/map.py b/map.py new file mode 100644 index 0000000..d45e56e --- /dev/null +++ b/map.py @@ -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"]) + """