Spaces:
Running
Running
LaurentTRIPIED
commited on
Commit
•
d63f1d2
1
Parent(s):
3a5c93a
Pytorch v.40
Browse files- app.py +17 -1
- localisation.py +0 -20
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
import streamlit as st
|
2 |
from organisations_engagees import display_organisations_engagees
|
3 |
-
from localisation import display_map
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def main():
|
6 |
st.sidebar.title("Navigation")
|
7 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
|
|
1 |
import streamlit as st
|
2 |
from organisations_engagees import display_organisations_engagees
|
3 |
+
from localisation import display_map
|
4 |
|
5 |
+
def get_data():
|
6 |
+
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
7 |
+
try:
|
8 |
+
response = requests.get(url)
|
9 |
+
response.raise_for_status() # Cela va déclencher une exception pour les réponses non-200
|
10 |
+
data = response.json()
|
11 |
+
records = data.get("records", [])
|
12 |
+
if records:
|
13 |
+
return [record.get("fields") for record in records]
|
14 |
+
else:
|
15 |
+
st.error("Aucun enregistrement trouvé dans les données de l'API.")
|
16 |
+
return []
|
17 |
+
except requests.RequestException as e:
|
18 |
+
st.error(f"Erreur lors de la récupération des données de l'API: {e}")
|
19 |
+
return []
|
20 |
+
|
21 |
def main():
|
22 |
st.sidebar.title("Navigation")
|
23 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])
|
localisation.py
CHANGED
@@ -3,26 +3,6 @@ import folium
|
|
3 |
from streamlit_folium import folium_static
|
4 |
import streamlit as st
|
5 |
|
6 |
-
# Supposons que cette fonction fonctionne correctement et n'a pas besoin d'être modifiée.
|
7 |
-
def get_data():
|
8 |
-
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
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 |
-
# Vérifiez que 'geolocalisation' ou un autre champ contient les coordonnées
|
17 |
-
geoloc = fields.get("geolocalisation")
|
18 |
-
if geoloc and isinstance(geoloc, list) and len(geoloc) == 2:
|
19 |
-
lat, lon = geoloc
|
20 |
-
cleaned_data.append({"lat": lat, "lon": lon, "name": fields.get("nom_courant_denomination", "Inconnu")})
|
21 |
-
return cleaned_data
|
22 |
-
else:
|
23 |
-
st.error(f"Failed to fetch data. Status code: {response.status_code}")
|
24 |
-
return []
|
25 |
-
|
26 |
def display_map(data):
|
27 |
if not data:
|
28 |
st.write("No data available to display on the map.")
|
|
|
3 |
from streamlit_folium import folium_static
|
4 |
import streamlit as st
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
def display_map(data):
|
7 |
if not data:
|
8 |
st.write("No data available to display on the map.")
|