Commit
·
aa166fc
1
Parent(s):
d94929a
Pytorch V0.19
Browse files- localisation.py +18 -11
localisation.py
CHANGED
|
@@ -8,21 +8,28 @@ def get_data():
|
|
| 8 |
if response.status_code == 200:
|
| 9 |
data = response.json()
|
| 10 |
records = data.get("records", [])
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
else:
|
| 13 |
return []
|
| 14 |
|
| 15 |
def display_map(data):
|
| 16 |
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
| 17 |
for item in data:
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
folium.
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
| 27 |
-
).add_to(m)
|
| 28 |
folium_static(m)
|
|
|
|
| 8 |
if response.status_code == 200:
|
| 9 |
data = response.json()
|
| 10 |
records = data.get("records", [])
|
| 11 |
+
cleaned_data = []
|
| 12 |
+
for record in records:
|
| 13 |
+
fields = record.get("fields", {})
|
| 14 |
+
# Assurez-vous que point_geo est un dictionnaire avec lat et lon.
|
| 15 |
+
point_geo = fields.get("geolocalisation")
|
| 16 |
+
if point_geo and isinstance(point_geo, list) and len(point_geo) == 2:
|
| 17 |
+
# Stockez directement lat et lon dans fields pour un accès facile.
|
| 18 |
+
fields["latitude"], fields["longitude"] = point_geo[0], point_geo[1]
|
| 19 |
+
cleaned_data.append(fields)
|
| 20 |
+
return cleaned_data
|
| 21 |
else:
|
| 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 |
+
# Utilisez directement latitude et longitude.
|
| 28 |
+
lat, lon = item.get("latitude"), item.get("longitude")
|
| 29 |
+
if lat and lon:
|
| 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)
|