Skip to content
Snippets Groups Projects
Commit 6068f925 authored by Alexandre Pradeilles's avatar Alexandre Pradeilles
Browse files

ajout exceptions

parents 5e2b4543 813f0fa0
No related branches found
No related tags found
No related merge requests found
...@@ -33,12 +33,17 @@ def coord_to_inter(liste_coord,lat,long,main_street): ...@@ -33,12 +33,17 @@ def coord_to_inter(liste_coord,lat,long,main_street):
indice=dist.index(min(dist)) indice=dist.index(min(dist))
dist.pop(indice) dist.pop(indice)
liste_coord.pop(indice) liste_coord.pop(indice)
elif nom_de_rue==inter_street[0]:
indice=dist.index(min(dist))
dist.pop(indice)
liste_coord.pop(indice)
else : else :
inter_street.append(nom_de_rue) inter_street.append(nom_de_rue)
inter_street_coord.append(candidat)
indice=dist.index(min(dist)) indice=dist.index(min(dist))
dist.pop(indice) dist.pop(indice)
liste_coord.pop(indice) liste_coord.pop(indice)
return inter_street return inter_street+inter_street_coord
......
...@@ -6,10 +6,15 @@ def tree_position(lat, lon): ...@@ -6,10 +6,15 @@ def tree_position(lat, lon):
main_street = req['address']['road'] main_street = req['address']['road']
city = req['address']['town'] city = req['address']['town']
intersections = req['geojson']['coordinates'] intersections = req['geojson']['coordinates']
[begin,end] = coord_to_inter(intersections, lat, lon, main_street) [begin,end,coord_begin, coord_end] = coord_to_inter(intersections, lat, lon, main_street)
return {'lat':lat, 'lon':lon, 'ville':city, 'rue':main_street, 'début tronçon': begin, 'fin tronçon':end} return {'lat':lat, 'lon':lon, 'ville':city, 'rue':main_street, 'début tronçon': begin, 'fin tronçon':end, 'coordonées début tronçon': coord_begin, 'coordonnées fin tronçon': coord_end}
if __name__=="__main__": if __name__=="__main__":
<<<<<<< HEAD
lat = 48.89394122 lat = 48.89394122
lon = 2.247959188 lon = 2.247959188
=======
lat = 48.89227652
lon = 2.253773690
>>>>>>> 813f0fa0998be24636500d74894a86f50c568431
print(tree_position(lat, lon)) print(tree_position(lat, lon))
\ No newline at end of file
import geocoder
import requests import requests
def geocode(city):
g = geocoder.osm(city)
return (g.y,g.x)
def requete_osm(lat, lon): def requete_osm(lat, lon):
params = { params = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment