示例#1
0
def get_stops(lat, lon):
    """
    This method returns a list of stops near the specified latitude-longitude
    coordinates. This method can optionally specify a maximum distance (in 
    miles) a stop can be from the input coordinates. If none is specified the
    default is 1 mile.
    """
    distance = 1.0
    distance_list = request.args.getlist('distance')
    if 0 < len(distance_list):
        distance = float(distance_list[0])

    stops = stops_near_point(lat, lon, distance)
    if stops:
        return jsonify({'stops': [stop for stop in stops]})

    return jsonify({'error': 'No stops near ({0}, {1})'.format(lat, lon)})
示例#2
0
def get_departures(lat, lon):
    """
    This method returns a list of departures times for routes with departures
    from stops near the specified latitude-longitude coordinates as given by
    the 511.org real-time departure api
    (http://511.org/developer-resources_transit-api.asp).
    This method can optionally specify a maximum distance (in miles) a stop can
    be from the input coordinates. If none is specified the default is 1 mile.
    """
    # This method can optionally specify a maximum distance a stop can
    # be from the input coordinates.
    distance = 1.0
    distance_list = request.args.getlist('distance')
    if 0 < len(distance_list):
        distance = float(distance_list[0])

    stops = stops_near_point(lat, lon, distance)
    if stops:
        departures = [departures_at_stop(stop['stop_id']) for stop in stops]
        return jsonify({'departures': departures})

    return jsonify({'error': 'No stops near ({0}, {1})'.format(lat, lon)})