Spaces:
Sleeping
Sleeping
MaxAtoms
commited on
Commit
·
d59e9e4
1
Parent(s):
2fd6b6e
Re-add shared.py
Browse filesSome additional minor clean-up
- app/app.py +4 -21
- app/shared.py +2 -0
app/app.py
CHANGED
@@ -1,14 +1,12 @@
|
|
1 |
import faicons as fa
|
2 |
-
import sys
|
3 |
-
import os
|
4 |
from ipyleaflet import Map, Marker, LayerGroup, Circle, Icon, AwesomeIcon, DivIcon, basemaps, GeoJSON
|
5 |
|
6 |
import matplotlib.pyplot as plt
|
7 |
|
8 |
from pandas.core.frame import functools
|
9 |
# Load data and compute static values
|
10 |
-
from borgarlina3_leaflet import
|
11 |
-
from shared import app_dir
|
12 |
from shinywidgets import render_widget
|
13 |
|
14 |
from shiny import reactive, render
|
@@ -18,8 +16,6 @@ from shiny.express import input, ui
|
|
18 |
from data_processing.data_provider import Data_provider
|
19 |
|
20 |
initBackend = Data_provider()
|
21 |
-
def getScore(cords):
|
22 |
-
pass
|
23 |
|
24 |
def generateStops(year):
|
25 |
geojson_file = f"given_data/cityline_geojson/cityline_{year}.geojson"
|
@@ -30,7 +26,6 @@ def generateStops(year):
|
|
30 |
gpdStops, _, all_small_areas = load_and_preprocess_data(geojson_file, pop_file, smallarea_file, dwellings_file)
|
31 |
|
32 |
points = []
|
33 |
-
stopData = {}
|
34 |
# Assuming your GeoDataFrame is named 'gdf'
|
35 |
for _, row in gpdStops.iterrows():
|
36 |
point = row["geometry"]
|
@@ -106,13 +101,6 @@ with ui.layout_columns(col_widths=[8, 4]):
|
|
106 |
def map():
|
107 |
return Map(
|
108 |
basemap=basemaps.CartoDB.Positron)
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
with ui.layout_column_wrap(width="450px"):
|
118 |
with ui.layout_columns(col_widths=(6, 6), min_height="450px"):
|
@@ -333,11 +321,6 @@ with ui.layout_columns(col_widths=[8, 4]):
|
|
333 |
|
334 |
# Return the figure for rendering in Shiny
|
335 |
return fig
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
|
342 |
ui.include_css(app_dir / "styles.css")
|
343 |
|
@@ -459,7 +442,7 @@ def reset_marker(index, **kwargs):
|
|
459 |
|
460 |
@reactive.effect
|
461 |
def centerMap():
|
462 |
-
|
463 |
map.widget.zoom = 11.8
|
464 |
map.widget.center = (64.11,-21.90)
|
465 |
|
@@ -501,4 +484,4 @@ def lineScore():
|
|
501 |
)
|
502 |
lines[key] = score["final_score"]
|
503 |
|
504 |
-
return lines
|
|
|
1 |
import faicons as fa
|
|
|
|
|
2 |
from ipyleaflet import Map, Marker, LayerGroup, Circle, Icon, AwesomeIcon, DivIcon, basemaps, GeoJSON
|
3 |
|
4 |
import matplotlib.pyplot as plt
|
5 |
|
6 |
from pandas.core.frame import functools
|
7 |
# Load data and compute static values
|
8 |
+
from borgarlina3_leaflet import load_and_preprocess_data
|
9 |
+
from shared import app_dir
|
10 |
from shinywidgets import render_widget
|
11 |
|
12 |
from shiny import reactive, render
|
|
|
16 |
from data_processing.data_provider import Data_provider
|
17 |
|
18 |
initBackend = Data_provider()
|
|
|
|
|
19 |
|
20 |
def generateStops(year):
|
21 |
geojson_file = f"given_data/cityline_geojson/cityline_{year}.geojson"
|
|
|
26 |
gpdStops, _, all_small_areas = load_and_preprocess_data(geojson_file, pop_file, smallarea_file, dwellings_file)
|
27 |
|
28 |
points = []
|
|
|
29 |
# Assuming your GeoDataFrame is named 'gdf'
|
30 |
for _, row in gpdStops.iterrows():
|
31 |
point = row["geometry"]
|
|
|
101 |
def map():
|
102 |
return Map(
|
103 |
basemap=basemaps.CartoDB.Positron)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
with ui.layout_column_wrap(width="450px"):
|
106 |
with ui.layout_columns(col_widths=(6, 6), min_height="450px"):
|
|
|
321 |
|
322 |
# Return the figure for rendering in Shiny
|
323 |
return fig
|
|
|
|
|
|
|
|
|
|
|
324 |
|
325 |
ui.include_css(app_dir / "styles.css")
|
326 |
|
|
|
442 |
|
443 |
@reactive.effect
|
444 |
def centerMap():
|
445 |
+
_ = input.reset()
|
446 |
map.widget.zoom = 11.8
|
447 |
map.widget.center = (64.11,-21.90)
|
448 |
|
|
|
484 |
)
|
485 |
lines[key] = score["final_score"]
|
486 |
|
487 |
+
return lines
|
app/shared.py
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
from pathlib import Path
|
2 |
+
app_dir = Path(__file__).parent
|