Skip to content

Instantly share code, notes, and snippets.

@pnorman
Created February 29, 2024 21:05
Show Gist options
  • Save pnorman/a7904a090c88af293adc42dfbd4e6e3b to your computer and use it in GitHub Desktop.
Save pnorman/a7904a090c88af293adc42dfbd4e6e3b to your computer and use it in GitHub Desktop.
tilekiln demo

Minutely Shortbread tiles

With this year being the year of OpenStreetMap vector maps I've been working on making vector tile maps that update minutely. Most maps don't need minutely updates and are fine with daily or, at most, weekly. Minutely updates on OpenStreetMap.org are a crucial part of the feedback cycle where mappers can see their edits right away and get inspired to map more often. Typically a mapper can make an edit and see their edit when reloading after 90-180 seconds, compared to the days or weeks of most OSM-based services, or the months or years of proprietary data sources.

Updating maps once a week can be done with a simple architecture that takes the OSM file for the planet and turns it into a single file containing all the tiles for the world. This can scale to daily updates, but not much faster. To do minutely updates we need to generate tiles one-by-one, since they change one-by-one. When combined with the caching requirements for osm.org, this is something no existing software solved.

For some time I've been working on Tilekiln, a small piece of software which leverages the existing vector tile generation of PostGIS, the standard geospatial database. Tilekiln is written specifically to meet the unique requirements of a default layer on osm.org. Recently, I've been working for the OSMF at setting up minutely updated vector tiles using the Shortbread schema. A schema is a set of definitions for what goes in the vector tiles, and Shortbread is a CC0 licensed schema that anyone can use and there are existing styles for.

My work has progressed to the stage where I've set up a demo server with the tiles where they are updated about once a minute. This can be viewed on a demo page and it should be fairly quick up until zoom 13, because everything is pre-generated. If you're outside Europe it might be a bit slower in places since there's only one backend server and it's in Europe.

The real point of this demo is not the map itself, but the tiles behind the map. If you want to try the vector tiles yourself in other software, you can use the URL https://demo.tilekiln.xyz/shortbread_v1/tilejson.json in any software that reads tilejson, or https://demo.tilekiln.xyz/shortbread_v1/{z}/{x}/{y}.mvt for a direct link to the tiles in MVT format. Please test the tiles directly - I'm very interested in unusual use cases!

Another behind the scenes part of the demo is testing monitoring. It's essential to have adequate monitoring of a system when it's in production, and Tilekiln comes with an exporter for Prometheus in order to monitor itself. You can view this online or look at an example query like number of z13 and z14 tiles in storage

As with any demo, there are a couple of technical issues. The big one is, as always, documentation. It exists but is not as complete as I would like and there's no equivalent to the switch2osm guides. The other that you might notice is that the caching isn't ideal, with caching on my server and then caching on the CDN with Fastly. Some more work needs to be done to optimize cachability and until that's done it might take 5-15 minutes to see an update even if it's been done on my server.

There is no SLA for this demo, and I can guarantee it will be offline at times for software updates. When the demo is finished the URLs will stop working, so I don't recommend releasing software that depends on it. This being said, you're welcome to use it for any use provided you display OpenStreetMap attribution and aren't upset when the demo stops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment