示例#1
0
def get_next_best_stations(phone_number):
    user = User(phone_number)

    stations = station_api.get_best_station(user.station_lat, user.station_lon)
    user.add_event("get_next_best_station")
    user.add_event("get_next_best_station_result", stations['second']['bike']['location_name'])

    return stations['second']
示例#2
0
def get_closest_station (phone_number, addr):
    #hack 1, add Toronto at the end (Should probably be doing this in the geocode api instead sohow
    #hack 2, Weird results if Yonge doesn't have a street at the end, Yonge and Bloor doesn't resolve correctly
    address = addr.replace("Toronto", "").replace("toronto", "").replace("yonge", "yonge st").replace("Yonge", "Yonge St")
    user = User(phone_number)


    coordinates = geo_api.convert_address_to_geo(address)

    #Latitude Longitude
    station = station_api.get_best_station(coordinates['Latitude'], coordinates['Longitude'])

    if (station['first']['distance'] < 5):
        user.add_stations(address, station['first']['location_name'], coordinates['Latitude'], coordinates['Longitude'])
        user.add_event("search", address)
        user.add_event("search_result", station['first']['location_name'])

        return station['first']
    else:
        return None