From 27aea631bf124dde808296f6efbef6a6cdc7465d Mon Sep 17 00:00:00 2001 From: SebF Date: Sat, 9 Oct 2021 15:28:41 +0200 Subject: [PATCH] =?UTF-8?q?d=C3=A9placement=20de=20logique=20dans=20la=20m?= =?UTF-8?q?=C3=A9thode=20de=20requ=C3=AAtage=20overpass?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- recup_donnees_OSM_Overpass.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/recup_donnees_OSM_Overpass.py b/recup_donnees_OSM_Overpass.py index 56bacf3..27a2a8d 100644 --- a/recup_donnees_OSM_Overpass.py +++ b/recup_donnees_OSM_Overpass.py @@ -147,10 +147,19 @@ def nettoyage_json_pour_umap(data, overpass_query_fields): return export_json -def run_overpass_query(query) : +def run_overpass_query(critere, aire_de_recherche) : """Envoie la requête Overpass et retourne la réponse JSON.""" + + overpass_query = """[out:json]; + ( + """+critere+""" + ); + out center; + """ + overpass_query = overpass_query.replace("aire_de_recherche", aire_de_recherche) - response = requests.get(overpass_url, params={'data': query}) + print("Execution requete overpass : \n" + overpass_query) + response = requests.get(overpass_url, params={'data': overpass_query}) if (response.status_code != 200) : raise errors.Overpass_error(response.status_code) @@ -173,21 +182,7 @@ def run_reverse_geocoding(lat, lon) : def executer_requete_et_exporter_resultats(nom_req, critere, aire_de_recherche, overpass_query_fields) : - print ("Nom requête : "+nom_req) - - overpass_query = """[out:json]; - ( - """+critere+""" - ); - out center; - """ - - overpass_query = overpass_query.replace("aire_de_recherche", aire_de_recherche) - - - print("Execution requete overpass : \n"+overpass_query) - - data = run_overpass_query(overpass_query) + data = run_overpass_query(critere, aire_de_recherche) nb_elements = len(data["elements"])