jibeproject / jibe-vis

Interactive visualisation app for exploring health impacts of urban planning scenarios based on large-scale transport and health simulation modelling.
MIT License
0 stars 0 forks source link

Cache map tiles #19

Open carlhiggs opened 3 months ago

carlhiggs commented 3 months ago

Currently, each time you re-load the map, the map tiles are reloaded --- in principle, that shouldn't be necessary as there are directions for using pmtiles with cache-ing on AWS, that we haven't yet successfully implemented.

This issue is to remind me to do this ( https://docs.protomaps.com/deploy/aws )

carlhiggs commented 3 weeks ago

@MohammadUT has made some progress with this, successfully implementing the Lambda/CloudFront/S3 environment on AWS as per pmtiles directions --- this now successfully loads data, although AJAX 502 timeout error is experienced on highly detailed map tiles (bi-directional street network, that was designed to stress test performance), resulting in tile drop outs. Some tweaking may be required. For now I haven't switched over to using the CloudFront tilejson URL that invokes the Lambda function, although it appears to work well for all except the street network data. I'll wait until @MohammadUT further investigates the 502 errors and performance aspects as discussed today, in case any modifications are required. Nice work implementing this so far @MohammadUT!

MohammadUT commented 2 weeks ago

Okay I noticed jibe_directional_network.pmtiles miss some zoom levels, for instance jibe_directional_network/9/462/313.mvt. I beleive there is an issue with the current jibe_directional_network.tiles as it hadn't been generated for different zoom levels (e.g., zoom level 9). So I regenerated a new .pmtiles based on the Geojson file (using tippecanoe) and it has all zoom levels including zoom level z9. I can also view that in pmtiles.io, and I can see change of details in different zoom levels. I have a feeling the previous issue in old jibe_directional_network.pmtile shouldn't be the case in new pmtile. However, when I uploaded the new pmtile (tiles/jibe_directional_network_mk.pmtiles) into S3, still I can't be able to load the jibe_directional_network.pmtile on map and got the 'Error: Source layer "network" does not exist on source "network" as specified by style layer "network_out".' This is for 'network_out' and 'network_rtn' part in stories.json file. So my question is how we can tweak the new generated .pmtiles to be compatible with our scripts (e.g., stories.json) in order to test and see whether it can load the tiles correctly? I believe the lambda is working well, the current issue is with our pmtile file, and once it's fixed, then we should see the optimised map tile loading using deployed lambda.

Screenshot 2024-10-21 at 22 59 03
MohammadUT commented 2 weeks ago

I could successfully load the network tiles with the jib_basemap with deployed lambda function! I can clearly see the performance of tile loading and it caches successfully and fast! This shows different zoom levels and the more zoom in the more level of detail it will show.

image
carlhiggs commented 2 weeks ago

This is great progress @MohammadUT thank you. I can see other challenges in the above image, in terms of dropping level of detail --- which is clearly a tradeoff of in terms of performance vs accuracy/completeness of representation. Ideally, we won't drop streets etc --- but this may be a separate issue to this one re caching. Sounds like maybe this issue about caching map tiles has been addressed, which is fantastic!

A seperate issue may be how to best construct highly detailed representations of street networks, that are meaningfully visible at both city scale while zoomed out, as well as zoomed in. The above image looks a bit problematic to me from a representation point of view. Ideally, when zoomed out, it should show a clear map of the distribution of the relevant variable (in this case Level of Traffic Stress) for the city:

image

how we can tweak the new generated .pmtiles to be compatible with our scripts

This is a separate issue, related to the question/images above illustrating challenges of levels of detail, about how we generate tiles using Tippecanoe. A pmtiles file contains layers that we reference (e.g. "-l network" might create a layer within the pmtiles file that we can refer to in our code). Ultimately, we should document all of this as we go -- and to date I have been doing this in a OneNote notebook, but am working on creating full documentation as per #39 , which will be addressed by including details and code for constructing specific data included in the visualisation in an online notebook file (see data-preparation, although, this is a work in progress). I'll aim to provide more details on data preparation for networks and use of Tippecanoe for pmtile generation in this document later this week.