Hacker News new | ask | show | jobs
by hkchad 2362 days ago
So I saw this post earlier to day and tried it on a dataset we have (fixed boundaries w/ some properties that change 4x/hr). We use the value of the properties for styling of the vector tiles. Currently the tiles are re-rendered every 4hrs (even though the data is updated every 15 min) using tippiecanoe, served by tileserver-gl and cached in cloudfront. So I wanted a way to get new data to users faster. But as you have noted this dynamic process crunchy posted IS SLOW, it takes about 3 minutes to paint the world on my brand new macbook pro (about 3 seconds w/ pre-rendered). Given the country boundaries do not change very often is there a way to change just the properties that actually needed updated in the already rendered vector tiles? Our pipeline takes about 45 min to run completely to regenerate the new tiles with updated properties. Or is there a better way to present this data? We started out w/ GeoJSON directly from the DB but the size of the files were huge, the vector tiles are 30% the size of GeoJSON. We were in the MTS private beta but they didn't have the 'update' process worked out yet so it was a full refresh each time.
2 comments

We will be releasing incremental updates to Tilesets API Beta (MTS) here shortly, reach out to us again and we can talk about having you test it out!
I haven't done this but I imagine you could put a service worker that has a fetch event listener that puts you in front of the raw tile data being cached. https://github.com/mapbox/mapbox-gl-js/issues/4326

From their you can serialize/deserialize the whole tile and map a new field (annoying), or if your clever... map your variable value fields lower in the values index array of the vt pbf. That way assuming you have a small number of unique style by values, you could get away with simply replacing a single byte representing that style value field with another value dictating a different style, for each feature in the vector tile.

That might be a little to abstract so tl:dr version put a listener in front of fetch. One byte represents the target dynamic field in each feature in the tile (if you have a small number of unique values). Replace that single byte with your desired target byte.