File size: 2,379 Bytes
bdbfec0
c6aa119
 
fadc8f0
 
bdbfec0
895d632
fadc8f0
 
c6aa119
 
 
 
881a55d
c6aa119
881a55d
4b29661
fadc8f0
c6aa119
fadc8f0
 
881a55d
fadc8f0
c6aa119
 
895d632
 
 
 
 
 
 
 
 
4b29661
895d632
fadc8f0
 
 
a776231
fadc8f0
a776231
 
 
 
fadc8f0
 
 
 
 
 
a776231
fadc8f0
c6aa119
fadc8f0
e09c0f9
c6aa119
fadc8f0
 
 
 
 
 
 
895d632
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import streamlit as st
import pandas as pd
import requests
import folium
from streamlit_folium import folium_static

# Fonction pour récupérer les données de l'API
def get_data():
    url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
    response = requests.get(url)
    if response.status_code == 200:
        data = response.json()
        records = data.get("records", [])
        return [record["fields"] for record in records], data.get("nhits", 0)
    else:
        return [], 0

# Fonction pour l'onglet "Organisations engagées"
def display_organisations_engagees():
    st.markdown("## OPEN DATA RSE")
    st.markdown("### Découvrez les organisations engagées RSE de la métropole de Bordeaux")
    
    data, _ = get_data()
    if data:
        df = pd.DataFrame(data)
        df = df.rename(columns={
            "nom_courant_denomination": "Nom",
            "commune": "Commune",
            "libelle_section_naf": "Section NAF",
            "tranche_effectif_entreprise": "Effectif",
            "action_rse": "Action RSE"
        })
        df = df[["Nom", "Commune", "Section NAF", "Effectif", "Action RSE"]]
        st.dataframe(df, width=None, height=None)

# Fonction pour afficher la carte
def display_map():
    data, _ = get_data()
    if data:
        m = folium.Map(location=[44.84474, -0.60711], zoom_start=12)
        for item in data:
            if 'point_geo' in item and item['point_geo']:
                lat = float(item['point_geo']['lat'])
                lon = float(item['point_geo']['lon'])
                folium.Marker([lat, lon], popup=item.get("nom_courant_denomination", "Sans nom")).add_to(m)
        folium_static(m)

# Fonction pour l'onglet "Dialoguer avec l'assistant IA RSE bziiit"
def display_dialogue():
    st.markdown("# Patientez quelques heures encore... :)")

# Main function orchestrating the app UI
def main():
    st.sidebar.title("Navigation")
    app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Carte", "Dialoguer avec l'assistant IA RSE bziiit"])

    if app_mode == "Organisations engagées":
        display_organisations_engagees()
    elif app_mode == "Carte":
        display_map()
    elif app_mode == "Dialoguer avec l'assistant IA RSE bziiit":
        display_dialogue()

if __name__ == "__main__":
    main()