diff --git a/dkroutingtool/src/py/server.py b/dkroutingtool/src/py/server.py index da4684b..9b04383 100644 --- a/dkroutingtool/src/py/server.py +++ b/dkroutingtool/src/py/server.py @@ -154,8 +154,7 @@ def download(session_id: str=''): @app.get('/request_map/') def request_map(minlat, minlon, maxlat, maxlon): - stateful_info['bounding_box'] = [minlat, minlon, maxlat, maxlon] - + request_template = f''' [out:xml] [bbox:{minlon},{minlat}, {maxlon}, {maxlat}]; @@ -171,6 +170,7 @@ def request_map(minlat, minlon, maxlat, maxlon): opened.write(r.text) os.environ['osm_filename'] = 'ui_map' temporary_build_profiles() + stateful_info['bounding_box'] = [minlat, minlon, maxlat, maxlon] return {'message': 'Done'} @@ -220,4 +220,4 @@ def temporary_build_profiles(osmpbf=False): if __name__ == '__main__': - uvicorn.run(app, host='0.0.0.0', port=5001) \ No newline at end of file + uvicorn.run(app, host='0.0.0.0', port=5001) diff --git a/dkroutingtool/src/py/ui/dashboard.py b/dkroutingtool/src/py/ui/dashboard.py index 70c80a3..4c5bd00 100644 --- a/dkroutingtool/src/py/ui/dashboard.py +++ b/dkroutingtool/src/py/ui/dashboard.py @@ -572,6 +572,11 @@ def main(): if bound_check(tuple(bounding_box), old_bounding_box): st.write(':heavy_check_mark: The currently available map covers the desired area, no need to redownload it unless you edited OSM since the last download') + elif area < 0.2 and 'alreadydownloaded' not in st.session_state: + st.session_state['alreadydownloaded'] = True + with st.spinner("Downloading the road network. Please wait..."): + request_map(bounding_box) + st.rerun() else: st.error(f"It would be recommended to download the area as you have locations in your input data outside the currently downloaded area. The size is {round(area,2)} in Cartesian square units, be mindful that values above 0.2 may lead to the download taking many minutes") @@ -744,4 +749,4 @@ def update_data(): if __name__ == '__main__': - main() \ No newline at end of file + main()