Spaces:
Runtime error
Runtime error
Commit
·
c4b7f78
1
Parent(s):
dbd3890
Pytorch V0.30
Browse files- localisation.py +21 -35
localisation.py
CHANGED
@@ -1,41 +1,27 @@
|
|
1 |
-
import requests
|
2 |
import folium
|
3 |
from streamlit_folium import folium_static
|
4 |
import streamlit as st
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
response = requests.get(url)
|
10 |
-
if response.status_code == 200:
|
11 |
-
data = response.json()
|
12 |
-
records = data.get("records", [])
|
13 |
-
cleaned_data = []
|
14 |
-
for record in records:
|
15 |
-
fields = record.get("fields", {})
|
16 |
-
point_geo = fields.get("geolocalisation")
|
17 |
-
if point_geo and isinstance(point_geo, list) and len(point_geo) == 2:
|
18 |
-
lat, lon = point_geo # Directement extraire la latitude et la longitude
|
19 |
-
fields["latitude"], fields["longitude"] = lat, lon
|
20 |
-
cleaned_data.append(fields)
|
21 |
-
return cleaned_data
|
22 |
-
else:
|
23 |
-
st.error("Aucun enregistrement trouvé dans les données de l'API.")
|
24 |
-
return []
|
25 |
-
except requests.RequestException as e:
|
26 |
-
st.error(f"Erreur lors de la récupération des données de l'API: {e}")
|
27 |
-
return []
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
41 |
folium_static(m)
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import folium
|
2 |
from streamlit_folium import folium_static
|
3 |
import streamlit as st
|
4 |
|
5 |
+
def display_test_map():
|
6 |
+
# Coordonnées GPS de l'exemple fourni
|
7 |
+
lat, lon = 44.86091098994118, -0.6997150007542606
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Affichage des coordonnées GPS pour le test
|
10 |
+
st.write(f"Test d'affichage du point pour les coordonnées GPS : Latitude = {lat}, Longitude = {lon}")
|
11 |
+
|
12 |
+
# Création de la carte centrée sur les coordonnées avec un zoom approprié
|
13 |
+
m = folium.Map(location=[lat, lon], zoom_start=15)
|
14 |
+
|
15 |
+
# Ajout d'un marqueur pour ces coordonnées
|
16 |
+
folium.Marker(
|
17 |
+
[lat, lon],
|
18 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
19 |
+
popup="ARIANE GROUP OMNISPORTS RASSEMBLEMENT ASSOCIATIF",
|
20 |
+
).add_to(m)
|
21 |
+
|
22 |
+
# Affichage de la carte dans l'application Streamlit
|
23 |
folium_static(m)
|
24 |
+
|
25 |
+
# Remplacer temporairement le point d'entrée par display_test_map pour le test
|
26 |
+
if __name__ == "__main__":
|
27 |
+
display_test_map()
|