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