def get_program_stations_by_geoindex(program, longitude, latitude, max_count=0, max_distance=None): """Returns stations for the given program. Uses a max count or max distance to search from the given location. """ stations = mongo_dao.get_program_stations_by_geoindex(program, longitude, latitude, max_count, max_distance) return stations
def get_random_program_stations(program, max_count=150, min_count=0, random_count=False, max_distance=None): """Generates a random coordinate and uses this coordinate to create a random set of stations that are near that coordinate. Options include: change max_count (default 150), use random_count=True and specify a max_count and min_count to get a random number of stations between the two values, and specify a max search distance. """ coordinate = utils.get_random_coordinate() longitude = coordinate["longitude"] latitude = coordinate["latitude"] if random_count: max_count = utils.get_random_integer(min_count, max_count) stations = mongo_dao.get_program_stations_by_geoindex(program, longitude, latitude, max_count, max_distance) stations = utils.sort_dictionary_list_on_key(stations, 'id') return stations