File size: 1,552 Bytes
c5b60b4
d0661bd
c4b812c
d63f1d2
9ee810a
d63f1d2
 
 
 
c5b60b4
 
 
 
 
 
 
 
 
 
 
d63f1d2
c5b60b4
d63f1d2
 
c5b60b4
d63f1d2
c5b60b4
0527fa6
a631fd0
82ba0e3
c4b812c
bb3771a
82ba0e3
bb3771a
82ba0e3
 
0527fa6
 
10118ca
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
import requests  # Ajoutez cette ligne au début de votre fichier
import streamlit as st
from organisations_engagees import display_organisations_engagees
from localisation import display_map

def get_data():
    url = "https://opendata.bordeaux-metropole.fr/api/records/1.0/search/?dataset=met_etablissement_rse&q=&rows=100"
    try:
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            records = data.get("records", [])
            cleaned_data = []
            for record in records:
                fields = record.get("fields", {})
                geoloc = fields.get("geolocalisation")
                if geoloc and isinstance(geoloc, list) and len(geoloc) == 2:
                    lat, lon = geoloc
                    cleaned_data.append({"lat": lat, "lon": lon, "name": fields.get("nom_courant_denomination", "Inconnu")})
            return cleaned_data
        else:
            st.error(f"Failed to fetch data. Status code: {response.status_code}")
            return []
    except requests.RequestException as e:
        st.error(f"Error occurred: {e}")
        return []

def main():
    st.sidebar.title("Navigation")
    app_mode = st.sidebar.radio("Choisissez l'onglet", ["Organisations engagées", "Localisation des Entreprises"])

    data = get_data()
    if app_mode == "Organisations engagées":
        display_organisations_engagees(data)
    elif app_mode == "Localisation des Entreprises":
        display_map(data)

if __name__ == "__main__":
    main()