Spaces:
Running
Running
LaurentTRIPIED
commited on
Commit
•
2d7498a
1
Parent(s):
188de0e
Pytorch V0.16 (old v0.13)
Browse files
app.py
CHANGED
@@ -10,21 +10,8 @@ def get_data():
|
|
10 |
if response.status_code == 200:
|
11 |
data = response.json()
|
12 |
records = data.get("records", [])
|
13 |
-
|
14 |
-
st.error("Aucun enregistrement trouvé dans les données de l'API.")
|
15 |
-
return []
|
16 |
-
cleaned_data = []
|
17 |
-
for record in records:
|
18 |
-
fields = record.get("fields", {})
|
19 |
-
point_geo = fields.get("geolocalisation")
|
20 |
-
if point_geo and isinstance(point_geo, list) and len(point_geo) == 2:
|
21 |
-
lat, lon = point_geo
|
22 |
-
fields["latitude"] = lat
|
23 |
-
fields["longitude"] = lon
|
24 |
-
cleaned_data.append(fields)
|
25 |
-
return cleaned_data
|
26 |
else:
|
27 |
-
st.error(f"Échec de la récupération des données de l'API. Statut: {response.status_code}")
|
28 |
return []
|
29 |
|
30 |
def display_organisations_engagees(data):
|
@@ -45,13 +32,16 @@ def display_organisations_engagees(data):
|
|
45 |
def display_map(data):
|
46 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
47 |
for item in data:
|
48 |
-
|
49 |
-
if
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
folium_static(m)
|
56 |
|
57 |
def main():
|
|
|
10 |
if response.status_code == 200:
|
11 |
data = response.json()
|
12 |
records = data.get("records", [])
|
13 |
+
return [record.get("fields") for record in records]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
else:
|
|
|
15 |
return []
|
16 |
|
17 |
def display_organisations_engagees(data):
|
|
|
32 |
def display_map(data):
|
33 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
34 |
for item in data:
|
35 |
+
point_geo = item.get('point_geo')
|
36 |
+
if isinstance(point_geo, dict):
|
37 |
+
lon = point_geo.get('lon')
|
38 |
+
lat = point_geo.get('lat')
|
39 |
+
if lon and lat:
|
40 |
+
folium.Marker(
|
41 |
+
[lat, lon],
|
42 |
+
icon=folium.Icon(color="green", icon="leaf"),
|
43 |
+
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
44 |
+
).add_to(m)
|
45 |
folium_static(m)
|
46 |
|
47 |
def main():
|