Commit 82cd86aec961df420b54366776d5bb2ce2dac2aa

Authored by Antoine Goutenoir
1 parent 7ef5bc95
Exists in master

feat: add the latitude and longitude to the CSV

Showing 1 changed file with 10 additions and 1 deletions   Show diff stats
flaskr/controllers/main_controller.py
... ... @@ -537,6 +537,8 @@ def compute(): # process the queue of estimation requests
537 537 'city': _key,
538 538 'country': _get_country_key(_destination),
539 539 'address': _destination.address,
  540 + 'latitude': _destination.latitude,
  541 + 'longitude': _destination.longitude,
540 542 'footprint': 0.0,
541 543 'distance': 0.0,
542 544 'train_trips': 0,
... ... @@ -576,9 +578,11 @@ def compute(): # process the queue of estimation requests
576 578 city_train_trips = cities_dict_first_model[city]['train_trips']
577 579 city_plane_trips = cities_dict_first_model[city]['plane_trips']
578 580 cities_mean_dict[city] = {
579   - 'address': destinations_by_city_key[city].address,
580 581 'city': city,
581 582 'country': _get_country_key(destinations_by_city_key[city]),
  583 + 'address': destinations_by_city_key[city].address,
  584 + 'latitude': destinations_by_city_key[city].latitude,
  585 + 'longitude': destinations_by_city_key[city].longitude,
582 586 'footprint': city_mean_foot,
583 587 'distance': city_mean_dist,
584 588 'train_trips': city_train_trips,
... ... @@ -656,6 +660,8 @@ def compute(): # process the queue of estimation requests
656 660 city_results['city'] = city_key
657 661 city_results['country'] = country_key
658 662 city_results['address'] = destination.address
  663 + city_results['latitude'] = destination.latitude
  664 + city_results['longitude'] = destination.longitude
659 665 result_cities.append(city_results)
660 666  
661 667 result_cities = sorted(result_cities, key=lambda c: int(c['footprint']))
... ... @@ -756,6 +762,7 @@ def consult_estimation(public_id, extension):
756 762 cw = csv.writer(si, quoting=csv.QUOTE_ALL)
757 763 cw.writerow([
758 764 u"city", u"country", u"address",
  765 + u"latitude", u"longitude",
759 766 u"co2_kg",
760 767 u"distance_km",
761 768 u"plane trips_amount",
... ... @@ -768,6 +775,8 @@ def consult_estimation(public_id, extension):
768 775 city['city'].encode(OUT_ENCODING),
769 776 city['country'].encode(OUT_ENCODING),
770 777 city['address'].encode(OUT_ENCODING),
  778 + city['latitude'],
  779 + city['longitude'],
771 780 round(city['footprint'], 3),
772 781 round(city['distance'], 3),
773 782 city['plane_trips'],
... ...