### Quickstart Docker import with osm2pgsql-themepark Source: https://shortbread-tiles.org/make-vectortiles/osm2pgsql Quickstart using Docker: clone the osm2pgsql-themepark repository, start a PostGIS container, download a Liechtenstein OSM extract, and import it with osm2pgsql in flex mode using the Shortbread config. Requires Docker and network access to GitHub and Geofabrik. ```bash git 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 ``` -------------------------------- ### Docker quickstart for tilemaker Source: https://shortbread-tiles.org/make-vectortiles/tilemaker Clones the shortbread-tilemaker repository, downloads shapefiles, downloads an OSM extract for Liechtenstein, and runs tilemaker in a Docker container to produce a PMTiles file. Requires ogr2ogr for the shapefile download step. ```bash 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 ``` -------------------------------- ### Run BBOX tile server with PostGIS Source: https://shortbread-tiles.org/make-vectortiles/bbox Starts the BBOX tile server using a PostGIS database connection and a configuration file. Requires the BBOX_DATASOURCE_DB environment variable and the bbox-tile-server command. ```bash BBOX_DATASOURCE_DB=postgres://osm:osm@127.0.0.1/osm bbox-tile-server -c data/bbox-config.toml serve ``` -------------------------------- ### Serve PostGIS tiles with style Source: https://shortbread-tiles.org/make-vectortiles/bbox Downloads a style, modifies it to point to the local tile server, and starts the BBOX server with static assets. The sed command replaces the remote tile URL with the local one. ```bash mkdir styles curl -L https://github.com/versatiles-org/versatiles-style/releases/latest/download/styles.tar.gz \ | tar xz -C styles colorful.json sed 's!https://tiles.versatiles.org/tiles/osm/{z}/{x}/{y}!http://localhost:8080/xyz/osm/{z}/{x}/{y}.pbf!g' styles/colorful.json > styles/colorful-local.json BBOX_DATASOURCE_DB=postgres://osm:osm@127.0.0.1/osm BBOX_ASSETS__STATIC='[{dir="../styles",path="/styles"}]' bbox-tile-server -c data/bbox-config.toml serve ``` -------------------------------- ### Install ogr2ogr on Debian/Ubuntu Source: https://shortbread-tiles.org/make-vectortiles/tilemaker Installs gdal-bin, which provides ogr2ogr, on Debian/Ubuntu systems. Required for the get-shapefiles.sh script. ```bash sudo apt install gdal-bin ``` -------------------------------- ### Install ogr2ogr on Fedora Source: https://shortbread-tiles.org/make-vectortiles/tilemaker Installs gdal, which provides ogr2ogr, on Fedora systems. Required for the get-shapefiles.sh script. ```bash sudo dnf install gdal ``` -------------------------------- ### Prepare directories Source: https://shortbread-tiles.org/publishing Creates the required directory structure for the publishing workflow. ```bash mkdir -p data public/styles public/assets/sprites ``` -------------------------------- ### Run Planetiler with Docker to Create Shortbread PMTiles Source: https://shortbread-tiles.org/make-vectortiles/planetiler Creates a data directory and runs Planetiler in Docker with the Shortbread config, downloading Liechtenstein data and outputting a PMTiles file. Uses the current user ID and mounts the local data directory. ```bash mkdir data docker run --rm --user=$UID -v $PWD/data:/data ghcr.io/onthegomap/planetiler shortbread.yml \ --download --area=liechtenstein --output=/data/shortbread.pmtiles ``` -------------------------------- ### Generalize with osm2pgsql-gen Source: https://shortbread-tiles.org/make-vectortiles/osm2pgsql Downloads and imports additional data (e.g., water polygons) using the themepark's external script (requires ogr2ogr), then runs osm2pgsql-gen to generalize the data in the database. Uses the same Docker container and Shortbread config as the import step. ```bash # 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 ``` -------------------------------- ### Serve MBTiles or PMTiles with style Source: https://shortbread-tiles.org/make-vectortiles/bbox Downloads a style, modifies it for local tiles, and serves either an MBTiles or PMTiles file. The final command opens the style in Maputnik. ```bash mkdir styles curl -L https://github.com/versatiles-org/versatiles-style/releases/latest/download/styles.tar.gz \ | tar xz -C styles colorful.json sed 's!https://tiles.versatiles.org/tiles/osm/{z}/{x}/{y}!http://localhost:8080/xyz/shortbread/{z}/{x}/{y}.pbf!g' \ styles/colorful.json > styles/colorful-local.json # Serve MBTiles BBOX_ASSETS__STATIC='[{dir="styles",path="/styles"}]' bbox-tile-server serve data/shortbread.mbtiles # Serve PMTiles BBOX_ASSETS__STATIC='[{dir="styles",path="/styles"}]' bbox-tile-server serve data/shortbread.pmtiles # Open in Maputnik xdg-open "https://maplibre.org/maputnik/?style=http://localhost:8080/styles/colorful-local.json#15/47.1377/9.5188" ``` -------------------------------- ### Generate Shortbread tiles using Planetiler Source: https://shortbread-tiles.org/publishing Runs Planetiler to generate Shortbread tiles as a PMTiles archive for Liechtenstein, then moves the output to the public directory. ```bash docker run --rm --user=$UID -v $PWD/data:/data ghcr.io/onthegomap/planetiler shortbread.yml \ --download --area=liechtenstein --output=/data/shortbread.pmtiles mv data/shortbread.pmtiles public/ ``` -------------------------------- ### Generate tiles with tilemaker Source: https://shortbread-tiles.org/make-vectortiles/tilemaker Runs tilemaker with the shortbread config and process Lua scripts, specifying a bounding box and input/output files. Produces an MBTiles file named shortbread-tiles.mbtiles. The --bbox option can be omitted if the input PBF contains a bounding box header. ```bash tilemaker --config config.json --process process.lua --bbox -180,-90,180,90 \ --input OSM_FILE.osm.pbf --output shortbread-tiles.mbtiles ``` -------------------------------- ### Viewer index.html Source: https://shortbread-tiles.org/publishing HTML page that loads MapLibre GL and PMTiles, adds the pmtiles protocol, and initializes a map with the modified style. ```html