From 2a8f5bbb002c940116e786a425a4b43de143ef2b Mon Sep 17 00:00:00 2001 From: Jack Greenlee Date: Fri, 2 Aug 2024 13:08:34 -0400 Subject: [PATCH] store the entire nominatim response; not just 'address' --- emission/analysis/intake/cleaning/clean_and_resample.py | 2 +- emission/core/wrapper/cleanedplace.py | 2 +- emission/individual_tests/TestNominatim.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/emission/analysis/intake/cleaning/clean_and_resample.py b/emission/analysis/intake/cleaning/clean_and_resample.py index 85d1df378..db5b0d02c 100644 --- a/emission/analysis/intake/cleaning/clean_and_resample.py +++ b/emission/analysis/intake/cleaning/clean_and_resample.py @@ -254,7 +254,7 @@ def get_filtered_place(raw_place): reverse_geocoded_json = eco.Geocoder.get_json_reverse(filtered_place_data.location.coordinates[1], filtered_place_data.location.coordinates[0]) if reverse_geocoded_json is not None: - filtered_place_data['geocoded_address'] = reverse_geocoded_json['address'] + filtered_place_data['reverse_geocode'] = reverse_geocoded_json filtered_place_data.display_name = format_result(reverse_geocoded_json) except KeyError as e: logging.info("nominatim result does not have an address, skipping") diff --git a/emission/core/wrapper/cleanedplace.py b/emission/core/wrapper/cleanedplace.py index 9dd552340..b347bf582 100644 --- a/emission/core/wrapper/cleanedplace.py +++ b/emission/core/wrapper/cleanedplace.py @@ -12,7 +12,7 @@ class Cleanedplace(ecwp.Place): props = ecwp.Place.props props.update( {"raw_places": ecwb.WrapperBase.Access.WORM, # raw places that were combined to from this cleaned place - "geocoded_address": ecwb.WrapperBase.Access.WORM, # the 'address' field of the OSM reverse geocoding result + "reverse_geocode": ecwb.WrapperBase.Access.WORM, # the 'address' field of the OSM reverse geocoding result "display_name": ecwb.WrapperBase.Access.WORM # The human readable name for this place }) diff --git a/emission/individual_tests/TestNominatim.py b/emission/individual_tests/TestNominatim.py index 1ad31a9d7..361d99299 100644 --- a/emission/individual_tests/TestNominatim.py +++ b/emission/individual_tests/TestNominatim.py @@ -65,10 +65,10 @@ def test_get_filtered_place(self): actual_display_name = fake_place_data.__getattr__("display_name") expected_display_name = "Dorrance Street, Providence" self.assertEqual(expected_display_name, actual_display_name) - actual_geocoded_address = fake_place_data["geocoded_address"] - expected_geocoded_address = {'road': 'Dorrance Street', 'city': 'Providence', 'postcode': '02903'} - for k in expected_geocoded_address: - self.assertEqual(expected_geocoded_address[k], actual_geocoded_address[k]) + actual_reverse_geocode = fake_place_data["reverse_geocode"] + expected_address = {'road': 'Dorrance Street', 'city': 'Providence', 'postcode': '02903'} + for k in expected_address: + self.assertEqual(expected_address[k], actual_reverse_geocode['address'][k]) #Testing make_url_geo, which creates a query URL from the input string. def test_make_url_geo(self):