Introducing Tilemaker: vector tiles without the stack
Vector tiles are the breakthrough technology for OpenStreetMap right now – enabling in-device rendering, fast style prototyping, full interactivity, and really awesome tech demos.
The manifesto was set out compellingly by Michal Migurski in 2013, who wrote of “the liberty of postgreslessness”:
“Data is one of OpenStreetMap’s biggest pain points. The latest planet file is 27GB, and getting OSM into the Postgres database can be a long and winding road… [vector tiles] offer a compelling way to use Mapnik or TileMill with no local datastore.”
Two years down the line, and he reviews the state of the art:
“It feels a bit like OSM raster rendering in 2006/07, when Mapnik was still impossible to install but a growing group of people like Dane were nudging it forward into general accessibility. I give vector tiles and vector rendering another 1-2 years before it tips from weird research and supervised, commercial deployment into wide use and hacking.”
Can we fast forward those “1-2 years”?
Today, most vector tile implementations are backed up by a Postgres database, because the vector tiles have to get their source data from somewhere. They are typically connected via a maze of twisty little NodeJS modules, all alike, and it's fair to say that NodeJS isn’t everyone's cup of tea. Between them, they conspire to make vector tiles less hackable for the independent cartographer or developer.
So I've written Tilemaker.
Tilemaker aims to make creating vector tiles as easy as “push button, receive bacon”. It's a command-line tool which takes a .pbf planet extract and makes vector tiles from it. There's no database, no stack.
You write your tile recipe in Lua, the same scripting language used by OSRM and osm2pgsql. For each OSM node or way, your script looks at its tags and says "put it in the railway layer" or "put it in the cycleway layer". Add a short JSON config file, and you're done:
tilemaker --output=test.mbtiles liechtenstein.osm.pbf
That’s all there is to it. One command line, instant vector tiles.
For Liechtenstein, OpenStreetMap's canonical small country, tiles are generated in around three seconds using the default recipe on a 2010 Mac mini. For London, it takes around two minutes, for Switzerland, 10 minutes (so I’m told!). RAM requirements mean it won't scale to whole continents or the full planet, but that's not the aim – for continually-updated worldwide data in production, you should choose a friendly vector tiles provider. Tilemaker simply allows you to create tiles to your own recipe, to hack and build community projects on.
You can download Tilemaker from GitHub. It'll build on OS X, Ubuntu and Fedora.
Posted on Monday 29 June 2015. Link.