ChristophS
commited on
Commit
•
470e155
1
Parent(s):
0eb9176
Visualization and data loading refactoring
Browse files- DataModel.py +1 -1
- Visualization.py +7 -1
- app.py +5 -5
DataModel.py
CHANGED
@@ -12,7 +12,7 @@ class DataModel:
|
|
12 |
self.crs_ll = 4326
|
13 |
self.sleep = 5
|
14 |
|
15 |
-
@st.cache_data
|
16 |
def get_data(_self, osm_id, radius=25):
|
17 |
"""
|
18 |
Method for getting and extracting data from backend
|
|
|
12 |
self.crs_ll = 4326
|
13 |
self.sleep = 5
|
14 |
|
15 |
+
@st.cache_data(show_spinner='Daten werden geladen ...')
|
16 |
def get_data(_self, osm_id, radius=25):
|
17 |
"""
|
18 |
Method for getting and extracting data from backend
|
Visualization.py
CHANGED
@@ -188,7 +188,13 @@ class Visualization:
|
|
188 |
)
|
189 |
|
190 |
return fig
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
def helper_plot_regions(self,):
|
193 |
return 'Rot markierte Bereiche zeigen Zeitbereiche an, deren Fahrtenanzahl zu gering ist um \
|
194 |
eine gute Einschätzung der gewählten Metrik abzubilden.'
|
|
|
188 |
)
|
189 |
|
190 |
return fig
|
191 |
+
|
192 |
+
def int2str(self, x):
|
193 |
+
return f"{int(x):_}".replace('_', '.')
|
194 |
+
|
195 |
+
def float2str(self, x):
|
196 |
+
return f"{float(x):_.2f}".replace('.', ',').replace('_', '.')
|
197 |
+
|
198 |
def helper_plot_regions(self,):
|
199 |
return 'Rot markierte Bereiche zeigen Zeitbereiche an, deren Fahrtenanzahl zu gering ist um \
|
200 |
eine gute Einschätzung der gewählten Metrik abzubilden.'
|
app.py
CHANGED
@@ -16,12 +16,12 @@ def main(edge_id):
|
|
16 |
# head metrics of the shapes
|
17 |
cols = st.columns([4,1])
|
18 |
metric_cols = cols[0].columns(5)
|
19 |
-
metric_cols[0].container(border=True).metric('Gesamtzahl Fahrten:', data['ride_id'].sum())
|
20 |
metric_cols[0].markdown(' ')
|
21 |
-
metric_cols[1].container(border=True).metric('Geschwindigkeit:', f"{data['speed'].mean()
|
22 |
-
metric_cols[2].container(border=True).metric('Erreichte Wunshgeschwindigkeit:', f"{100*data['norm_speed'].mean()
|
23 |
-
metric_cols[3].container(border=True).metric('Zeitverlust:', f"{data['time_loss'].mean()
|
24 |
-
metric_cols[4].container(border=True).metric('Wartezeit:', f"{100*data['waiting'].mean()
|
25 |
# show shape on map
|
26 |
with cols[1]:
|
27 |
st_folium(visu.create_map(geom), returned_objects=[], key=f'Map', width=500, height=300,)
|
|
|
16 |
# head metrics of the shapes
|
17 |
cols = st.columns([4,1])
|
18 |
metric_cols = cols[0].columns(5)
|
19 |
+
metric_cols[0].container(border=True).metric('Gesamtzahl Fahrten:', visu.int2str(data['ride_id'].sum()))
|
20 |
metric_cols[0].markdown(' ')
|
21 |
+
metric_cols[1].container(border=True).metric('Geschwindigkeit:', f"{visu.float2str(data['speed'].mean())}km/h")
|
22 |
+
metric_cols[2].container(border=True).metric('Erreichte Wunshgeschwindigkeit:', f"{visu.float2str(100*data['norm_speed'].mean())}%")
|
23 |
+
metric_cols[3].container(border=True).metric('Zeitverlust:', f"{visu.float2str(data['time_loss'].mean())}s")
|
24 |
+
metric_cols[4].container(border=True).metric('Wartezeit:', f"{visu.float2str(100*data['waiting'].mean())}s")
|
25 |
# show shape on map
|
26 |
with cols[1]:
|
27 |
st_folium(visu.create_map(geom), returned_objects=[], key=f'Map', width=500, height=300,)
|