diff --git a/__pycache__/coord_to_intersections.cpython-38.pyc b/__pycache__/coord_to_intersections.cpython-38.pyc
index 1dd0f69fb0b5e7d19f9f57443b3aeb3fc98b014a..26e01917afeb2438f975e81a5ef0c71bafdf4b17 100644
Binary files a/__pycache__/coord_to_intersections.cpython-38.pyc and b/__pycache__/coord_to_intersections.cpython-38.pyc differ
diff --git a/__pycache__/request.cpython-38.pyc b/__pycache__/request.cpython-38.pyc
index e126e2c49ff5b895a5e38de12556d6ad9565c9af..454e263dc447ff9d2e00c723570c962dccb8a888 100644
Binary files a/__pycache__/request.cpython-38.pyc and b/__pycache__/request.cpython-38.pyc differ
diff --git a/__pycache__/request2.cpython-38.pyc b/__pycache__/request2.cpython-38.pyc
new file mode 100644
index 0000000000000000000000000000000000000000..2d6200b60d09ad0827b735dc5ac0aa896231d5ec
Binary files /dev/null and b/__pycache__/request2.cpython-38.pyc differ
diff --git a/__pycache__/research.cpython-38.pyc b/__pycache__/research.cpython-38.pyc
index ed2ca150e2e72ec77e82ae5798e6c587af0df0f5..95da01e8ab97a032581d32d5198493c24133f2be 100644
Binary files a/__pycache__/research.cpython-38.pyc and b/__pycache__/research.cpython-38.pyc differ
diff --git a/coord_to_intersections.py b/coord_to_intersections.py
index 72f068a27a4415a067da210f9c5679997422e5d0..4d518b1ccfc26a82a6672a7aeff195950b427b46 100644
--- a/coord_to_intersections.py
+++ b/coord_to_intersections.py
@@ -1,4 +1,6 @@
 from research import circular_research
+from copy import deepcopy
+
 def coord_to_inter(liste_coord,lat,long,main_street):
     dist=[]
     inter_street=[]
@@ -8,6 +10,7 @@ def coord_to_inter(liste_coord,lat,long,main_street):
         dist.append(d)
     while len(inter_street)<1 :
         candidat=liste_coord[dist.index(min(dist))]
+        #print(candidat)
         nom_de_rue=circular_research(candidat[1], candidat[0], main_street)
         if nom_de_rue== None :
             indice=dist.index(min(dist))
@@ -17,33 +20,123 @@ def coord_to_inter(liste_coord,lat,long,main_street):
             inter_street.append(nom_de_rue)
             inter_street_coord.append(candidat)
             indice=dist.index(min(dist))
+            d_1 = min(dist)
             dist.pop(indice)
             liste_coord.pop(indice)
+    #Calcul du tronçon de l'autre coté
+    liste_coord_admissibles = []
+    d_1_2 = []
+    dist2 = []
+    for i in range(len(liste_coord)):
+        #On prend la liste des intersection situé du second coté de l'arbe
+        d=(liste_coord[i][0]-inter_street_coord[0][0])**2 + (liste_coord[i][1]-inter_street_coord[0][1])**2
+        if d > dist[i] + d_1:
+            liste_coord_admissibles.append(liste_coord[i])
+            d_1_2.append(d)
+            dist2.append(dist[i])
     while len(inter_street)<2 :
+        candidat=liste_coord_admissibles[d_1_2.index(min(d_1_2))]
+        nom_de_rue=circular_research(candidat[1], candidat[0], main_street)
+        if nom_de_rue== None :
+            indice=d_1_2.index(min(d_1_2))
+            d_1_2.pop(indice)
+            liste_coord_admissibles.pop(indice)
+            dist2.pop(indice)
+        elif nom_de_rue==inter_street[0]:
+            indice=d_1_2.index(min(d_1_2))
+            d_1_2.pop(indice)
+            liste_coord_admissibles.pop(indice)
+            dist2.pop(indice)
+        else : 
+            inter_street.append(nom_de_rue)
+            inter_street_coord.append(candidat)
+            indice=d_1_2.index(min(d_1_2))
+            d_2 = dist2[indice]
+            liste_coord_admissibles.pop(indice)
+    print(inter_street)
+    liste_coord_admissibles2 = []
+    d_2_1 = []
+    #dist = fct_dist(liste_coord, lat, long)
+    for i in range(len(liste_coord)):
+        #On prend la liste des intersection situé du premier coté de l'arbe
+        d=(liste_coord[i][0]-inter_street_coord[1][0])**2 + (liste_coord[i][1]-inter_street_coord[1][1])**2
+        print(liste_coord[i])
+        print(d - dist[i] - d_2)
+        if d > dist[i] + d_2:  #+ 2* 10**(-12)
+            liste_coord_admissibles2.append(liste_coord[i])
+            d_1_2.append(d)
+    inter_street2 = ['', '']
+    c = 0
+    while inter_street != inter_street2:
+        if c % 2 == 0:
+            liste_coord_admissibles2 += [inter_street_coord[0]]
+            d_2_1 = fct_d_2_1(liste_coord_admissibles2, inter_street_coord)
+            #print(liste_coord_admissibles2)
+            #print(d_2_1)
+        else:
+            liste_coord_admissibles += [inter_street_coord[1]]
+            d_1_2 = fct_d_2_1(liste_coord_admissibles, inter_street_coord)
+            print(d_1_2)
+
+        inter_street2 = deepcopy(inter_street)
+        inter_street, inter_street_coord = opti_inter_street(c, main_street, liste_coord_admissibles, liste_coord_admissibles2, d_1_2, d_2_1, inter_street, inter_street_coord)
+        c +=1
+    return inter_street+inter_street_coord
+
+
+def opti_inter_street(c, main_street, liste_coord_admissibles, liste_coord_admissibles2, d_1_2, d_2_1, inter_street_init, inter_street_coord_init):
+    p = c % 2
+    if p == 0:
+        liste_coord = liste_coord_admissibles2
+        dist = d_2_1
+    else:
+        liste_coord = liste_coord_admissibles
+        dist = d_1_2
+    inter_street = deepcopy(inter_street_init)
+    inter_street_coord = deepcopy(inter_street_coord_init)
+    found = False
+    while not(found):
         candidat=liste_coord[dist.index(min(dist))]
-        dist_1_2= (candidat[0]-inter_street_coord[0][0])**2 + (candidat[1]-inter_street_coord[0][1])**2
-        dist_main_2= min(dist)
-        if dist_1_2<dist_main_2 :
+        nom_de_rue=circular_research(candidat[1], candidat[0], main_street)
+        if nom_de_rue== None :
             indice=dist.index(min(dist))
             dist.pop(indice)
             liste_coord.pop(indice)
-        else:
-            nom_de_rue=circular_research(candidat[1], candidat[0], main_street)
-            if nom_de_rue== None :
-                indice=dist.index(min(dist))
-                dist.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 : 
-                inter_street.append(nom_de_rue)
-                inter_street_coord.append(candidat)
-                indice=dist.index(min(dist))
-                dist.pop(indice)
-                liste_coord.pop(indice)
-    return inter_street+inter_street_coord
+        elif nom_de_rue==inter_street[p]:
+            indice=dist.index(min(dist))
+            dist.pop(indice)
+            liste_coord.pop(indice)
+            found = True
+        else : 
+            inter_street[p] = nom_de_rue
+            inter_street_coord[p] = candidat
+            indice=dist.index(min(dist))
+            liste_coord.pop(indice)
+            found = True
+    return inter_street, inter_street_coord
+
+def fct_d_1_2(liste_coord, inter_street_coord):
+    d_1_2 = []
+    for i in range(len(liste_coord)):
+        #On prend la liste des intersection situé du premier coté de l'arbe
+        d=(liste_coord[i][0]-inter_street_coord[0][0])**2 + (liste_coord[i][1]-inter_street_coord[0][1])**2
+        d_1_2.append(d)
+    return d_1_2
+
+def fct_d_2_1(liste_coord, inter_street_coord):
+    d_2_1 = []
+    for i in range(len(liste_coord)):
+        #On prend la liste des intersection situé du premier coté de l'arbe
+        d=(liste_coord[i][0]-inter_street_coord[1][0])**2 + (liste_coord[i][1]-inter_street_coord[1][1])**2
+        d_2_1.append(d)
+    return d_2_1
+
+def fct_dist(liste_coord, lat, long):
+    dist=[]
+    for inter in liste_coord:
+        d=(inter[0]-long)**2 + (inter[1]-lat)**2
+        dist.append(d)
+    return dist
 
 
 
diff --git a/main.py b/main.py
index ac07c1d8740a8e761efdfd2e7ef8ae9581970118..d0d277c67ae013cc726e9a26cf6b6d8fdd7b1f8b 100644
--- a/main.py
+++ b/main.py
@@ -1,20 +1,18 @@
 from request import requete_osm
 from coord_to_intersections import coord_to_inter
+from request2 import search_osm, all_intersect
 
 def tree_position(lat, lon):
     req = requete_osm(lat, lon)
     main_street = req['address']['road']
     city = req['address']['town']
-    intersections = req['geojson']['coordinates']
+    country = req['address']['country']
+    json = search_osm(main_street, city, country)
+    intersections = all_intersect(json)
     [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, 'coordonées début tronçon': coord_begin, 'coordonnées fin tronçon': coord_end}
 
 if __name__=="__main__":
-<<<<<<< HEAD
     lat = 48.89394122
     lon = 2.247959188
-=======
-    lat = 48.89227652
-    lon = 2.253773690
->>>>>>> 813f0fa0998be24636500d74894a86f50c568431
     print(tree_position(lat, lon))
\ No newline at end of file
diff --git a/request.py b/request.py
index c62b23770d731ae4a27b9182c0630e40793f2015..8978afd5b0074a525d7ea182393007f2e60a4da5 100644
--- a/request.py
+++ b/request.py
@@ -22,13 +22,14 @@ if __name__=="__main__":
 # intersection : 48.895307, 2.247367    48.894596, 2.247958      48.853994, 2.247177    48.894998, 2.247467
     #g = geocoder.osm([48.89, 2.247], method='reverse')
     params = {
-        'lat':48.894998,
-        'lon':2.247467,
+        'lat':48.89394122,
+        'lon':2.247959188,
         'format':'json',
         'zoom': 17,
         'polygon_geojson' : 1
     }
     req = requests.get("https://nominatim.openstreetmap.org/reverse",params) 
-
+    print(req.headers)
     reqJson = req.json()
-    print(reqJson)  #['geojson']['coordinates']
\ No newline at end of file
+    #print(reqJson)  #['geojson']['coordinates']
+
diff --git a/request2.py b/request2.py
new file mode 100644
index 0000000000000000000000000000000000000000..ad0879505316220707707ba9b99d356b6022659d
--- /dev/null
+++ b/request2.py
@@ -0,0 +1,46 @@
+import requests
+import json
+
+def search_osm(main_street, city, country):
+    params = {
+        'street' : main_street,
+        'city' : city,
+        'country' : country,
+        'polygon_geojson' : 1,
+        'format' : 'json',
+        'dedupe':0
+    }
+
+    req = requests.get("https://nominatim.openstreetmap.org/search?",params) 
+    reqJson = req.json()
+    return reqJson
+
+def all_intersect(json):
+    intersection = []
+    for road in json:
+        try:
+            inter = road['geojson']['coordinates']
+            intersection += inter
+        except KeyError:
+            pass
+    return intersection
+
+
+if __name__=="__main__": 
+
+    params = {
+        'street' : 'Avenue Gambetta',
+        'city' : 'Courbevoie',
+        'country' : 'France',
+        #'q' : '8 Avenue Gambetta, Courbevoie, France',
+        'polygon_geojson' : 1,
+        'format' : 'json',
+        'dedupe':0
+    }
+    req = requests.get("https://nominatim.openstreetmap.org/search?",params) 
+    #print(req.text)
+
+    reqJson = req.json()
+    print(reqJson)
+
+    #
\ No newline at end of file
diff --git a/research.py b/research.py
index b605890007240ead947516bf3f9e2ad265b72b86..2e42ee9f43be4b1d0394e9bc06ecadecadd9a7b3 100644
--- a/research.py
+++ b/research.py
@@ -6,7 +6,7 @@ def circular_research(lat, lon, main_street):
     if not(street == main_street) and not(street == ''):
         return street
     step = 10**(-5)
-    while step < 10**(-4):
+    while step < 4*10**(-5):
         for i in range(8):
             street = check_position(lat, lon, step, main_street, i)
             if not(street == main_street) and not(street == ''):