LaurentTRIPIED commited on
Commit
3f5c5c5
1 Parent(s): 438c1ea

Pytorch V0.19

Browse files
Files changed (1) hide show
  1. 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
- return [record.get("fields") for record in records]
 
 
 
 
 
 
 
 
 
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
- point_geo = item.get('point_geo')
19
- if isinstance(point_geo, dict):
20
- lon = point_geo.get('lon')
21
- lat = point_geo.get('lat')
22
- if lon and lat:
23
- folium.Marker(
24
- [lat, lon],
25
- icon=folium.Icon(color="green", icon="leaf"),
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)