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"])