Paul’s Blog

A blog without a good name

Creating Tarballs

With all the tiles generated and optimized, they just need to be packaged in a tarball. Before creating them, we want to create some files with metadata about what was used to generate the tiles. The commit of the stylesheet and the timestamp of the planet file can be extracted with a couple of commands.

osmium fileinfo -g 'header.option.osmosis_replication_timestamp' "${PLANET_FILE}" > osm_tiles/timestamp
git -C openstreetmap-carto rev-parse HEAD > osm_tiles/commit

Not every user will want all the zooms, so I’m creating multiple tarballs, going from zoom 0 to zoom 6, 0 to 8, and 0 to 10. This duplicates data between the files, but makes them more useful since only one file needs downloading.

tar will pack all of the tiles into one file, and can optionally compress them. Compressing a png won’t normally save space, but compressing a bunch of PNGs, many of which are identical will save space.

GZIP='--rsyncable --best' tar -C osm_tiles --create --gzip --file tarballs/z6.tar.gz commit timestamp 0 1 2 3 4 5 6
GZIP='--rsyncable --best' tar -C osm_tiles --create --gzip --file tarballs/z8.tar.gz commit timestamp 0 1 2 3 4 5 6 7 8
GZIP='--rsyncable --best' tar -C osm_tiles --create --gzip --file tarballs/z10.tar.gz commit timestamp 0 1 2 3 4 5 6 7 8 9 10