Spaces:
Running
Running
LaurentTRIPIED
commited on
Commit
•
61ab29f
1
Parent(s):
9a800ac
Pytorch V0.27
Browse files- localisation.py +8 -6
localisation.py
CHANGED
@@ -11,11 +11,10 @@ def get_data():
|
|
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 |
-
|
18 |
-
fields["latitude"], fields["longitude"] =
|
19 |
cleaned_data.append(fields)
|
20 |
return cleaned_data
|
21 |
else:
|
@@ -26,12 +25,15 @@ def display_map(data):
|
|
26 |
for item in data:
|
27 |
lat = item.get('latitude')
|
28 |
lon = item.get('longitude')
|
29 |
-
if lat
|
30 |
-
|
31 |
-
lat, lon = float(lat), float(lon)
|
32 |
folium.Marker(
|
33 |
[lat, lon],
|
34 |
icon=folium.Icon(color="green", icon="leaf"),
|
35 |
popup=item.get('nom_courant_denomination', 'Information non disponible'),
|
36 |
).add_to(m)
|
37 |
folium_static(m)
|
|
|
|
|
|
|
|
|
|
11 |
cleaned_data = []
|
12 |
for record in records:
|
13 |
fields = record.get("fields", {})
|
|
|
14 |
point_geo = fields.get("geolocalisation")
|
15 |
if point_geo and isinstance(point_geo, list) and len(point_geo) == 2:
|
16 |
+
lat, lon = point_geo # Directement extraire la latitude et la longitude
|
17 |
+
fields["latitude"], fields["longitude"] = lat, lon
|
18 |
cleaned_data.append(fields)
|
19 |
return cleaned_data
|
20 |
else:
|
|
|
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)
|