From 39992597cb92a43365983b3cc7b0b2f12e909ea8 Mon Sep 17 00:00:00 2001 From: SebF Date: Mon, 1 Nov 2021 21:42:22 +0100 Subject: [PATCH] =?UTF-8?q?suppression=20des=20m=C3=A9thodes=20de=20g?= =?UTF-8?q?=C3=A9ocodage=20inverse=20unitaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osm_vc63/utils.py | 88 ----------------------------------------------- rdoo.py | 1 - 2 files changed, 89 deletions(-) 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