Пример #1
0
 def test_create_db(self):
     cities.create_db()
     query = cities.find('London')
     results = list(query)
     self.failIf(len(results) == 0)
     full_names = [c.full_name for c in results]
     self.failIf('London, ENG (United Kingdom)' not in full_names)
Пример #2
0
 def test_find(self):
     cities.create_db()
     query = cities.find('London')
     results = list(query)
     self.failIf(len(results) == 0)
     full_names = [c.full_name for c in results]
     self.failIf('London, ENG (United Kingdom)' not in full_names)
Пример #3
0
def cities_json():
    MIN_QUERY_LENGTH = 2
    NUM_RESULTS = 5

    query = request.args.get('q', '')
    if len(query) < MIN_QUERY_LENGTH: abort(400)
    return Response(json.dumps([
        {'name': city.full_name,
         'lat': city.latitude,
         'long': city.longitude}
        for city in cities.find(query)[:NUM_RESULTS]
    ]), mimetype='application/json')
Пример #4
0
def cities_json():
    MIN_QUERY_LENGTH = 2
    NUM_RESULTS = 5

    query = request.args.get('q', '')
    if len(query) < MIN_QUERY_LENGTH: abort(400)
    return Response(json.dumps([
        {'name': city.full_name,
         'lat': city.latitude,
         'long': city.longitude}
        for city in cities.find(query)[:NUM_RESULTS]
    ]), mimetype='application/json')
Пример #5
0
def main():

    # test functions
    '''
    city or adress("1600 Amphitheatre Parkway, Mountain View, CA")
    address=input("Enter address: ")
    print("\n")
    cord=locationlatlng(address,apikey)
    cord=cord.split(",")

    temp=elevation(cord[0],cord[1],apikey)
    print("this is temp"+str(temp))
    '''

    locations = cities.find()
    el = []
    place = []

    # throw locations in fucntions to find there respective elevations
    for city in locations:
        cord = locationlatlng(city, apikey)
        cord = cord.split(",")
        place.append(city)
        el.append(elevationlatlng(cord[0], cord[1], apikey))

    # create dictionary
    city_stats = {"City": place, "Elevation(m)": el}

    # create pandas Dataframe with previous dictionary inside
    dft = pd.DataFrame(city_stats)

    # print dataframe without index
    print(dft.to_string(index=False))

    # use matplotlib to display the scatter between elevations and cities
    plt.scatter(place, el)
    plt.ylabel('Meters(Elevation)')
    plt.xlabel('Cities')
    plt.show()