Spaces:
Runtime error
Runtime error
Commit
·
74004b8
1
Parent(s):
61ab29f
Pytorch V0.28
Browse files- localisation.py +13 -30
localisation.py
CHANGED
|
@@ -1,39 +1,22 @@
|
|
| 1 |
import requests
|
| 2 |
-
import
|
| 3 |
-
from streamlit_folium import folium_static
|
| 4 |
|
| 5 |
def get_data():
|
| 6 |
-
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=
|
| 7 |
response = requests.get(url)
|
| 8 |
if response.status_code == 200:
|
| 9 |
data = response.json()
|
| 10 |
records = data.get("records", [])
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
else:
|
|
|
|
| 21 |
return []
|
| 22 |
-
|
| 23 |
-
def display_map(data):
|
| 24 |
-
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 25 |
-
for item in data:
|
| 26 |
-
lat = item.get('latitude')
|
| 27 |
-
lon = item.get('longitude')
|
| 28 |
-
if lat and lon:
|
| 29 |
-
lat, lon = float(lat), float(lon) # S'assurer que les coordonnées sont des flottants
|
| 30 |
-
folium.Marker(
|
| 31 |
-
[lat, lon],
|
| 32 |
-
icon=folium.Icon(color="green", icon="leaf"),
|
| 33 |
-
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
| 34 |
-
).add_to(m)
|
| 35 |
-
folium_static(m)
|
| 36 |
-
|
| 37 |
-
if __name__ == "__main__":
|
| 38 |
-
data = get_data()
|
| 39 |
-
display_map(data)
|
|
|
|
| 1 |
import requests
|
| 2 |
+
import streamlit as st
|
|
|
|
| 3 |
|
| 4 |
def get_data():
|
| 5 |
+
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=10" # Récupère seulement les 10 premiers pour le test
|
| 6 |
response = requests.get(url)
|
| 7 |
if response.status_code == 200:
|
| 8 |
data = response.json()
|
| 9 |
records = data.get("records", [])
|
| 10 |
+
if records: # Vérifie si des enregistrements ont été trouvés
|
| 11 |
+
# Test d'impression pour les 3 premiers enregistrements
|
| 12 |
+
for record in records[:3]:
|
| 13 |
+
st.write(record) # Imprime le record complet pour inspection
|
| 14 |
+
fields = record.get("fields", {})
|
| 15 |
+
point_geo = fields.get("geolocalisation")
|
| 16 |
+
st.write("point_geo:", point_geo) # Imprime spécifiquement point_geo
|
| 17 |
+
else:
|
| 18 |
+
st.error("Aucun enregistrement trouvé dans les données de l'API.")
|
| 19 |
+
return []
|
| 20 |
else:
|
| 21 |
+
st.error(f"Échec de la récupération des données de l'API. Statut: {response.status_code}")
|
| 22 |
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|