Introduction

A blog post by  Clément Gayvallet of JawgMaps shows how minimalist OpenStreeMap Mapbox vector  tiles can be generated using PostGIS. The post misses details of an essential step (how to add an sql function to a Docker image). The solution described below seems to work (see map).

JawgMaps


On Ubuntu 18.04LTS with PostGIS-3 and postgreSQL -10, installed using simply the command:

  • sudo apt-get postgresql-10-postgis-3

for user "ertert", I give terminal commands "as is" (i.e., with unedited paths).

Create and cd to a directory, say "osm-mvt", and following the blog post, create a network:

  • docker network create mvt

where "mvt" is going to be the Postgresql database name and username (not the usual "gis").

A helper function is needed. Copy the Bbox function to a file called "z_bbox.sql" and create a "Dockerfile" containing:


    FROM mdillon/postgis

COPY ./z_bbox.sql /docker-entrypoint-initdb.d/

EXPOSE 5432


A mapping.json file is also needed so copy mapping to /home/ertert/osm-mvt.

Now build the Docker image:

  • docker build -t dillon .

and run:

  • docker run -d --name postgis -e POSTGRES_USER=mvt --network mvt dillon

For the map we'll use Paris, JawgMaps's home town:

  • wget http://download.geofabrik.de/europe/france/ile-de-france-latest.osm.pbf

and import into the database using Imposum:

  • docker run --network mvt --rm -v $(pwd)/cache:/tmp/imposm3 -v $(pwd)/ile-de-france-latest.osm.pbf:/opt/imposm3/ile-de-france-latest.osm.pbf -v $(pwd)/mapping.json:/opt/imposm3/mapping.json jawg/imposm3 import -mapping mapping.json -read ile-de-france-latest.osm.pbf -overwritecache -write -connection 'postgis://mvt:mvt@postgis/mvt'
Tiles


There is a script to generate the tiles. Copy generate-tiles to /ertert/osm-mvt and run:

  • ./generate-tiles.sh

Before execution, since the name and user of the database are changed, the three lines of the type:

  • docker exec postgis psql gis gis -tq -c "$(admin $z $x $y)" | xxd -r -p ;

need to be changed to:

  • docker exec postgis psql mvt mvt -tq -c "$(admin $z $x $y)" | xxd -r -p ;

Tiles are created in a folder called "tiles". I use apache2 as a web server so I simply copied the content of "files" to a directory called "/var/www/html/jawg"

An index file is available. The file ("index.html") needs to be copied to /var/www/html/jawg

The tiles can be seen at maps.peterboswell.net/jawg as part of a project that is looking into the application of OpenStreetMap technologies for project-based construction activities in various contexts.

9 September 2020


Email: peter@peterboswell.com
Phone: +41792989666
Skype: live:petergboswell
WhatsApp: PeterBoswellcom
Messenger: petergboswell
Telegram: PeterBoswellBot
LinkedIn
Facebook
Twitter
OneName