Pirmin Kalberer @implgeo
State of the Map Europe 2024 Łódź
Lazy mapper (55 changesets in 15 years)
FOSSGIS e.V. board (German OSM chapter)
GIS developer
ocean
, water_polygons
,
water_lines
, water_lines_labels
,…boundaries
, boundary_labels
,
place_labels
land
, sites
, buildings
,
addresses
streets
, street_labels
,
bridges
, aerialways
, ferries
,
…public_transport
, pois
colorful, full featured map
gray, full featured map
light basemap
git clone https://github.com/shortbread-tiles/shortbread-tilemaker
cd shortbread-tilemaker
# Download additional data (water polygons, etc.). Requires ogr2ogr!
./get-shapefiles.sh
# Download OSM extract
curl -sSfO --output-dir data https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
docker run --rm -v $PWD:/var/tm -w /var/tm versatiles/versatiles-tilemaker \
tilemaker --config config.json --process process.lua \
--input data/liechtenstein-latest.osm.pbf --output data/shortbread.pmtiles
osm2pgsql-gen
for generalization in databaseosm2pgsql-replication
for incremental updatesgit clone https://github.com/osm2pgsql-dev/osm2pgsql-themepark.git
# Start database
docker run -d --name postgis -p 127.0.0.1:5432:5432 \
-e POSTGRES_DB=osm -e POSTGRES_USER=osm -e POSTGRES_PASSWORD=osm postgis/postgis
# Download OSM extract
mkdir data
curl -sSfO --output-dir data https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
# Import OSM extract
docker run --rm --network=host -v $PWD/osm2pgsql-themepark:/osm2pgsql-themepark:ro -v $PWD/data:/data \
-e LUA_PATH="/osm2pgsql-themepark/lua/?.lua;;" \
-e PGHOST=127.0.0.1 -e PGUSER=osm -e PGPASSWORD=osm iboates/osm2pgsql:1.11.0 \
osm2pgsql -d osm -S /osm2pgsql-themepark/config/shortbread_gen.lua -O flex --slim \
/data/liechtenstein-latest.osm.pbf
# Download and import additional data (water polygons, etc.). Requires ogr2ogr!
PGHOST=127.0.0.1 PGUSER=osm PGPASSWORD=osm ./osm2pgsql-themepark/themes/external/download-and-import.sh \
data osm oceans ocean
# Generalize
docker run --rm --network=host -v $PWD/osm2pgsql-themepark:/osm2pgsql-themepark:ro \
-e LUA_PATH="/osm2pgsql-themepark/lua/?.lua;;" \
-e PGHOST=127.0.0.1 -e PGUSER=osm -e PGPASSWORD=osm iboates/osm2pgsql:1.11.0 \
osm2pgsql-gen -d osm -S /osm2pgsql-themepark/config/shortbread_gen.lua
local BBOX = true
in
shortbread_gen.lua
write_config('bbox-config.toml')
to
write_config('/data/bbox-config.toml')
when running with
Dockerosm2pgsql
Mapbox / MapLibre GL JSON: https://maplibre.org/maplibre-style-spec/
Maputnik Editor (maplibre.org/maputnik)
# Generate Shortbread tiles
docker run --rm --user=$UID -v $PWD/data:/data ghcr.io/onthegomap/planetiler shortbread.yml \
--download --area=liechtenstein --output=/data/shortbread.pmtiles
# Download Versatiles Styles + Assets
mkdir -p styles assets/sprites
wget -O - https://github.com/versatiles-org/versatiles-style/releases/latest/download/styles.tar.gz | tar xz -C styles
wget -O - https://github.com/versatiles-org/versatiles-style/releases/latest/download/sprites.tar.gz | tar xz -C assets/sprites
# Replace tile source with PMTiles URL
jq '.sources."versatiles-shortbread".url="pmtiles:///shortbread.pmtiles" | del(.sources."versatiles-shortbread".tiles)' \
styles/colorful.json > styles/colorful-pmtiles.json
# Make sprite URL relative
sed --in-place -e 's!https://tiles.versatiles.org/assets/sprites!/assets/sprites!g' styles/*.json
index.html:
<!DOCTYPE html>
<html>
<head>
<title>MapLibre Viewer</title>
<script src='https://unpkg.com/maplibre-gl@4.5.0/dist/maplibre-gl.js'></script>
<link href='https://unpkg.com/maplibre-gl@4.5.0/dist/maplibre-gl.css' rel='stylesheet' />
<script src="https://unpkg.com/pmtiles@3.0.6/dist/pmtiles.js"></script>
<style>
body { margin: 0; }
#map { height: 100vh; width: 100vw;}
</style>
</head>
<body>
<div id="map"/>
<script>
let protocol = new pmtiles.Protocol();
maplibregl.addProtocol("pmtiles", protocol.tile);
var map = new maplibregl.Map({
container: 'map',
style: 'styles/colorful-pmtiles.json'
});
</script>
</body>
</html>
# Upload to site supporting HTTP Range Requests
scp -r . example.com:
# Or deploy to a hosting provider like Github pages
MapLibre with Shortbread PMTiles.
Pirmin Kalberer