forked from Olav63/outils_OSM
formattage avec Black
This commit is contained in:
parent
16ed9aa07b
commit
7cfe3d3327
@ -25,7 +25,7 @@ from osm_vc63 import errors
|
||||
from osm_vc63 import requetes
|
||||
from osm_vc63.utils import Utils
|
||||
|
||||
overpass_url="http://overpass-api.de/api/interpreter"
|
||||
overpass_url = "http://overpass-api.de/api/interpreter"
|
||||
geo_api_url = "https://api-adresse.data.gouv.fr"
|
||||
dossier_sauvegarde = "resultats/"
|
||||
|
||||
@ -42,8 +42,7 @@ retry_delay = 120
|
||||
# id Romagnat : 138269
|
||||
|
||||
# l'id de l'area se calcule en ajoutant 3600000000 au numéro de l'objet OSM
|
||||
aire_de_recherche = str(3600000000+110866)
|
||||
|
||||
aire_de_recherche = str(3600000000 + 110866)
|
||||
|
||||
|
||||
# ----------------------------------------------
|
||||
@ -67,22 +66,20 @@ trad_bicycle_parking = {
|
||||
"rope": "Câble",
|
||||
"two-tier": "Deux étages",
|
||||
"floor": "Sol",
|
||||
"handlebar_holder": "Accroche-guidons"}
|
||||
"handlebar_holder": "Accroche-guidons",
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def executer_requete_et_exporter_resultats(nom_req, critere, aire_de_recherche, overpass_query_fields) :
|
||||
def executer_requete_et_exporter_resultats(
|
||||
nom_req, critere, aire_de_recherche, overpass_query_fields
|
||||
):
|
||||
|
||||
utils = Utils(overpass_url, geo_api_url, dossier_sauvegarde)
|
||||
data = utils.run_overpass_query(critere, aire_de_recherche)
|
||||
|
||||
nb_elements = len(data["elements"])
|
||||
|
||||
print("Nombre d'elements : "+str(nb_elements))
|
||||
print("Nombre d'elements : " + str(nb_elements))
|
||||
"""
|
||||
print("Géocodage inversé : ", end="", flush=True)
|
||||
|
||||
@ -135,36 +132,34 @@ def executer_requete_et_exporter_resultats(nom_req, critere, aire_de_recherche,
|
||||
export_json = utils.nettoyage_json_pour_umap(data, overpass_query_fields)
|
||||
|
||||
# Sauvegarde
|
||||
os.makedirs(dossier_sauvegarde, exist_ok = True)
|
||||
os.makedirs(dossier_sauvegarde, exist_ok=True)
|
||||
|
||||
utils.as_json(export_json, nom_req)
|
||||
utils.as_ods(overpass_query_fields, data, nom_req)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
for req in requetes.reqs:
|
||||
|
||||
for nb_essai in range(max_retry): # on tente max_retry fois
|
||||
for nb_essai in range(max_retry): # on tente max_retry fois
|
||||
try:
|
||||
executer_requete_et_exporter_resultats(
|
||||
req.nom, req.critere, aire_de_recherche, req.champs
|
||||
)
|
||||
break
|
||||
except errors.Api_error:
|
||||
|
||||
|
||||
if nb_essai == max_retry:
|
||||
print("trop d'erreurs d'API - abandon")
|
||||
exit()
|
||||
|
||||
|
||||
print("erreur API - on retente dans " + str(retry_delay) + "s")
|
||||
|
||||
|
||||
time.sleep(retry_delay)
|
||||
|
||||
|
||||
print("Fini")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user