Spaces:
Runtime error
Runtime error
LaurentTRIPIED
commited on
Commit
·
46f8b87
1
Parent(s):
eb2ba11
Pytorch v.33
Browse files
__pycache__/localisation.cpython-312.pyc
CHANGED
Binary files a/__pycache__/localisation.cpython-312.pyc and b/__pycache__/localisation.cpython-312.pyc differ
|
|
__pycache__/organisations_engagees.cpython-312.pyc
CHANGED
Binary files a/__pycache__/organisations_engagees.cpython-312.pyc and b/__pycache__/organisations_engagees.cpython-312.pyc differ
|
|
localisation.py
CHANGED
@@ -4,37 +4,35 @@ from streamlit_folium import folium_static
|
|
4 |
import streamlit as st
|
5 |
|
6 |
def get_data():
|
7 |
-
# URL de l'API
|
8 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
return []
|
24 |
-
except requests.exceptions.RequestException as e:
|
25 |
-
st.error("Erreur lors de la connexion à l'API : {}".format(e))
|
26 |
return []
|
27 |
|
28 |
def display_map(data):
|
29 |
-
# Initialise la carte
|
30 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
31 |
-
# Ajoute un marqueur pour chaque élément dans 'data'
|
32 |
for item in data:
|
33 |
-
|
34 |
-
|
35 |
-
lat, lon
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
).add_to(m)
|
40 |
folium_static(m)
|
|
|
|
|
|
|
|
|
|
|
|
4 |
import streamlit as st
|
5 |
|
6 |
def get_data():
|
|
|
7 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
8 |
+
response = requests.get(url)
|
9 |
+
if response.status_code == 200:
|
10 |
+
data = response.json()
|
11 |
+
records = data.get("records", [])
|
12 |
+
cleaned_data = []
|
13 |
+
for record in records:
|
14 |
+
fields = record.get("fields", {})
|
15 |
+
# Assumer que 'geolocalisation' contient directement les coordonnées [lat, lon]
|
16 |
+
if 'geolocalisation' in fields:
|
17 |
+
lat, lon = fields['geolocalisation']
|
18 |
+
cleaned_data.append({"lat": lat, "lon": lon, "name": fields.get("nom_courant_denomination", "Inconnu")})
|
19 |
+
return cleaned_data
|
20 |
+
else:
|
21 |
+
st.error("Failed to fetch data")
|
|
|
|
|
|
|
22 |
return []
|
23 |
|
24 |
def display_map(data):
|
|
|
25 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
|
|
26 |
for item in data:
|
27 |
+
lat, lon = item["lat"], item["lon"]
|
28 |
+
folium.Marker(
|
29 |
+
[lat, lon],
|
30 |
+
popup=item["name"],
|
31 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
32 |
+
).add_to(m)
|
|
|
33 |
folium_static(m)
|
34 |
+
|
35 |
+
# Cette partie est pour exécuter le test directement dans ce fichier, si désiré
|
36 |
+
if __name__ == "__main__":
|
37 |
+
data = get_data()
|
38 |
+
display_map(data)
|