Spaces: Runtime error
Runtime error
LaurentTRIPIED
commited on
Commit
•
09e0db5
1
Parent(s):
3c1cd3f
Pytorch v.49
Browse files- localisation.py +9 -9
localisation.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import requests
|
2 |
-
import
|
3 |
from streamlit_folium import folium_static
|
4 |
import streamlit as st
|
5 |
from data_manager import get_data
|
@@ -7,23 +7,23 @@ from data_manager import get_data
|
|
7 |
def display_map():
|
8 |
data, _ = get_data()
|
9 |
if data:
|
10 |
-
m =
|
11 |
for item in data:
|
12 |
try:
|
13 |
-
# Supposons que 'point_geo' est une liste [lat, lon]
|
14 |
point_geo = item.get('point_geo', [])
|
15 |
if point_geo:
|
16 |
-
# Extraction de lat et lon par indexation de la liste, en supposant l'ordre correct [lat, lon]
|
17 |
lat, lon = point_geo
|
18 |
lat, lon = float(lat), float(lon)
|
19 |
-
# Vérification que lat et lon sont valides
|
20 |
if lat and lon:
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
except (ValueError, TypeError, IndexError):
|
23 |
-
# Gestion des erreurs pour la conversion en float, format de données inattendu, ou index manquant
|
24 |
continue
|
25 |
folium_static(m)
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
-
|
29 |
-
display_map(data)
|
|
|
1 |
import requests
|
2 |
+
from folium import Map, Marker, Icon
|
3 |
from streamlit_folium import folium_static
|
4 |
import streamlit as st
|
5 |
from data_manager import get_data
|
|
|
7 |
def display_map():
|
8 |
data, _ = get_data()
|
9 |
if data:
|
10 |
+
m = Map(location=[44.84474, -0.60711], zoom_start=12)
|
11 |
for item in data:
|
12 |
try:
|
|
|
13 |
point_geo = item.get('point_geo', [])
|
14 |
if point_geo:
|
|
|
15 |
lat, lon = point_geo
|
16 |
lat, lon = float(lat), float(lon)
|
|
|
17 |
if lat and lon:
|
18 |
+
popup_content = f"<b>{item.get('nom_courant_denomination', 'Sans nom')}</b><br>" \
|
19 |
+
f"<b>Action RSE</b><br>" \
|
20 |
+
f"{item.get('action_rse', 'Non spécifiée')}"
|
21 |
+
Marker([lat, lon],
|
22 |
+
popup=popup_content,
|
23 |
+
icon=Icon(color='green', icon='leaf', prefix='fa')).add_to(m)
|
24 |
except (ValueError, TypeError, IndexError):
|
|
|
25 |
continue
|
26 |
folium_static(m)
|
27 |
|
28 |
if __name__ == "__main__":
|
29 |
+
display_map()
|
|