diff --git a/osm_vc63/utils.py b/osm_vc63/utils.py index 68a9965..03a09b0 100644 --- a/osm_vc63/utils.py +++ b/osm_vc63/utils.py @@ -149,94 +149,6 @@ class Utils: return response.json() - def run_reverse_geocoding(self, lat, lon): - """Retourne une adresse JSON à partir d'une position GPS.""" - - url = self.geo_api_url + "/reverse/" - - response = requests.get(url, params={"lon": str(lon), "lat": str(lat)}) - - if response.status_code != 200: - raise errors.GeoApiError(response.status_code) - - return response.json() - - def run_reverse_geocoding_csv(self, lat, lon): - """Retourne une adresse JSON à partir d'une position GPS.""" - - url = self.geo_api_url + "/reverse/" - - response = requests.get(url, params={"lon": str(lon), "lat": str(lat)}) - - if response.status_code != 200: - raise errors.GeoApiError(response.status_code) - - return response.json() - - def geocodage(self, data): - """Renseigne une adresse pour chaque élément de data""" - - for element in data["elements"]: - - if element["type"] == "node": - rev_geocode = self.run_reverse_geocoding(element["lat"], element["lon"]) - else: - rev_geocode = self.run_reverse_geocoding( - element["center"]["lat"], element["center"]["lon"] - ) - - api_adresse = rev_geocode["features"][0] - - element["tags"]["api_adresse:geometry:coordinates:lon"] = api_adresse[ - "geometry" - ]["coordinates"][0] - element["tags"]["api_adresse:geometry:coordinates:lat"] = api_adresse[ - "geometry" - ]["coordinates"][1] - - element["tags"]["api_adresse:properties:label"] = api_adresse["properties"][ - "label" - ] - element["tags"]["api_adresse:properties:score"] = api_adresse["properties"][ - "score" - ] - - if "housenumber" in api_adresse["properties"]: - element["tags"]["api_adresse:properties:housenumber"] = api_adresse[ - "properties" - ]["housenumber"] - - element["tags"]["api_adresse:properties:type"] = api_adresse["properties"][ - "type" - ] - - element["tags"]["api_adresse:properties:name"] = api_adresse["properties"][ - "name" - ] - element["tags"]["api_adresse:properties:postcode"] = api_adresse[ - "properties" - ]["postcode"] - element["tags"]["api_adresse:properties:citycode"] = api_adresse[ - "properties" - ]["citycode"] - element["tags"]["api_adresse:properties:city"] = api_adresse["properties"][ - "city" - ] - - if "street" in api_adresse["properties"]: - element["tags"]["api_adresse:properties:street"] = api_adresse[ - "properties" - ]["street"] - - element["tags"]["api_adresse:properties:attribution"] = rev_geocode[ - "attribution" - ] - element["tags"]["api_adresse:properties:licence"] = rev_geocode["licence"] - - logging.info("Géocodage inversé terminé") - - return data - def geocodage_csv(self, data): """ Renseigne une adresse pour chaque élément de data diff --git a/rdoo.py b/rdoo.py index adc8f9d..09b4d2a 100644 --- a/rdoo.py +++ b/rdoo.py @@ -169,7 +169,6 @@ def main(): if nb_resultats > 0: if args.geocoding_inverse: # géocodage inverse - # data = utils.geocodage(data) data = utils.geocodage_csv(data) # traduction