forked from Olav63/outils_OSM
déplacement et commentaire des méthodes
This commit is contained in:
parent
eeac2f26aa
commit
72135e0f36
@ -68,9 +68,42 @@ trad_bicycle_parking = {
|
||||
"floor": "Sol",
|
||||
"handlebar_holder": "Accroche-guidons"}
|
||||
|
||||
# ----------------------------------------------
|
||||
|
||||
def sauvegarde_ods(fields, data, dossier, nom_req):
|
||||
"""Sauvegarde de la requête"""
|
||||
|
||||
ODSdataSheet = OrderedDict()
|
||||
ODSdata = []
|
||||
ODSdata.append(fields.keys())
|
||||
index_line = 2
|
||||
|
||||
for element in data["elements"]:
|
||||
line = []
|
||||
index_col = 0
|
||||
|
||||
for field in fields.keys():
|
||||
if field in element["tags"]:
|
||||
if field == "capacity":
|
||||
val = element["tags"][field]
|
||||
line.append(int(val) if val.isdigit() else val)
|
||||
else:
|
||||
line.append(element["tags"][field])
|
||||
else:
|
||||
line.append("")
|
||||
index_col = index_col + 1
|
||||
|
||||
ODSdata.append(line)
|
||||
index_line = index_line + 1
|
||||
|
||||
ODSdataSheet.update({"resultats": ODSdata})
|
||||
|
||||
save_data(dossier + nom_req + ".ods", ODSdataSheet)
|
||||
|
||||
print("Sauvegarde résultats format ODS pour " + nom_req)
|
||||
|
||||
|
||||
def run_overpass_query(query) :
|
||||
"""Envoie la requête Overpass et retourne la réponse JSON."""
|
||||
|
||||
response = requests.get(overpass_url, params={'data': query})
|
||||
|
||||
@ -81,6 +114,7 @@ def run_overpass_query(query) :
|
||||
|
||||
|
||||
def run_reverse_geocoding(lat, lon) :
|
||||
"""Retourne une adresse JSON à partir d'une position GPS."""
|
||||
|
||||
url = geo_api_url + "/reverse/"
|
||||
|
||||
@ -91,14 +125,6 @@ def run_reverse_geocoding(lat, lon) :
|
||||
|
||||
return (response.json())
|
||||
|
||||
# ----------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def executer_requete_et_exporter_resultats(nom_req, critere, aire_de_recherche, overpass_query_fields) :
|
||||
|
||||
print ("Nom requête : "+nom_req)
|
||||
@ -221,45 +247,9 @@ def executer_requete_et_exporter_resultats(nom_req, critere, aire_de_recherche,
|
||||
|
||||
# ===========================================
|
||||
|
||||
sauvegarde_ods(overpass_query_fields, data, nom_req)
|
||||
sauvegarde_ods(overpass_query_fields, data, dossier_sauvegarde, nom_req)
|
||||
|
||||
|
||||
def sauvegarde_ods(overpass_query_fields, data, nom_req):
|
||||
ODSdataSheet = OrderedDict()
|
||||
|
||||
ODSdata = []
|
||||
|
||||
ODSdata.append(overpass_query_fields.keys())
|
||||
|
||||
index_line = 2
|
||||
|
||||
for element in data["elements"]:
|
||||
|
||||
line = []
|
||||
|
||||
index_col = 0
|
||||
|
||||
# if (element["type"] == "node") :
|
||||
for field in overpass_query_fields.keys():
|
||||
if field in element["tags"]:
|
||||
if field == "capacity":
|
||||
val = element["tags"][field]
|
||||
line.append(int(val) if val.isdigit() else val)
|
||||
else:
|
||||
line.append(element["tags"][field])
|
||||
else:
|
||||
line.append("")
|
||||
index_col = index_col + 1
|
||||
|
||||
ODSdata.append(line)
|
||||
index_line = index_line + 1
|
||||
|
||||
ODSdataSheet.update({"resultats": ODSdata})
|
||||
|
||||
save_data(dossier_sauvegarde + nom_req + ".ods", ODSdataSheet)
|
||||
|
||||
print("Sauvegarde résultats format ODS pour " + nom_req)
|
||||
|
||||
|
||||
def main():
|
||||
for req in requetes.reqs:
|
||||
@ -287,3 +277,5 @@ def main():
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user