Commit
·
10118ca
1
Parent(s):
565bcde
Carte GPS
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import requests
|
|
| 4 |
import folium
|
| 5 |
from streamlit_folium import folium_static
|
| 6 |
|
| 7 |
-
# Fonction pour récupérer les données de l'API
|
| 8 |
def get_data():
|
| 9 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
| 10 |
response = requests.get(url)
|
|
@@ -23,28 +23,36 @@ def display_organisations_engagees():
|
|
| 23 |
data, _ = get_data()
|
| 24 |
if data:
|
| 25 |
df = pd.DataFrame(data)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
# Fonction pour afficher la carte
|
| 31 |
def display_map():
|
| 32 |
data, _ = get_data()
|
| 33 |
if data:
|
| 34 |
-
|
| 35 |
-
m = folium.Map(location=[44.8378, -0.5792], zoom_start=12)
|
| 36 |
-
# Ajout des entreprises sur la carte
|
| 37 |
for item in data:
|
| 38 |
-
if '
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
folium_static(m)
|
| 42 |
|
| 43 |
# Fonction pour l'onglet "Dialoguer avec l'assistant IA RSE bziiit"
|
| 44 |
def display_dialogue():
|
| 45 |
st.markdown("# Patientez quelques heures encore... :)")
|
| 46 |
|
| 47 |
-
#
|
| 48 |
def main():
|
| 49 |
st.sidebar.title("Navigation")
|
| 50 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Carte", "Dialoguer avec l'assistant IA RSE bziiit"])
|
|
@@ -57,4 +65,4 @@ def main():
|
|
| 57 |
display_dialogue()
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
| 60 |
-
main()
|
|
|
|
| 4 |
import folium
|
| 5 |
from streamlit_folium import folium_static
|
| 6 |
|
| 7 |
+
# Fonction pour récupérer les données de l'API
|
| 8 |
def get_data():
|
| 9 |
url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
|
| 10 |
response = requests.get(url)
|
|
|
|
| 23 |
data, _ = get_data()
|
| 24 |
if data:
|
| 25 |
df = pd.DataFrame(data)
|
| 26 |
+
df = df.rename(columns={
|
| 27 |
+
"nom_courant_denomination": "Nom",
|
| 28 |
+
"commune": "Commune",
|
| 29 |
+
"libelle_section_naf": "Section NAF",
|
| 30 |
+
"tranche_effectif_entreprise": "Effectif",
|
| 31 |
+
"action_rse": "Action RSE"
|
| 32 |
+
})
|
| 33 |
+
df = df[["Nom", "Commune", "Section NAF", "Effectif", "Action RSE"]]
|
| 34 |
+
st.dataframe(df, width=None, height=None)
|
| 35 |
|
| 36 |
+
# Fonction pour afficher la carte
|
| 37 |
def display_map():
|
| 38 |
data, _ = get_data()
|
| 39 |
if data:
|
| 40 |
+
m = folium.Map(location=[44.837789, -0.57918], zoom_start=12)
|
|
|
|
|
|
|
| 41 |
for item in data:
|
| 42 |
+
if 'point_geo' in item and item['point_geo'] is not None:
|
| 43 |
+
lat = item['point_geo']['lat']
|
| 44 |
+
lon = item['point_geo']['lon']
|
| 45 |
+
folium.Marker(
|
| 46 |
+
[lat, lon],
|
| 47 |
+
popup=item.get("Nom", "Sans nom")
|
| 48 |
+
).add_to(m)
|
| 49 |
folium_static(m)
|
| 50 |
|
| 51 |
# Fonction pour l'onglet "Dialoguer avec l'assistant IA RSE bziiit"
|
| 52 |
def display_dialogue():
|
| 53 |
st.markdown("# Patientez quelques heures encore... :)")
|
| 54 |
|
| 55 |
+
# Main function to orchestrate the app UI
|
| 56 |
def main():
|
| 57 |
st.sidebar.title("Navigation")
|
| 58 |
app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Carte", "Dialoguer avec l'assistant IA RSE bziiit"])
|
|
|
|
| 65 |
display_dialogue()
|
| 66 |
|
| 67 |
if __name__ == "__main__":
|
| 68 |
+
main()
|