Setting up a Flight Contest maps server.

Descriptions and tools based on following projects

Virtual server requirements

  • RAM: 60GB (not dynamic)

  • SSD: 2TB

  • CPU: 16

  • OS: Ubuntu 18.04 LTS 64bit

such as: Strato V-Server Linux V80-60

Software installation

SSH login with user root

ssh -l root <server-dns-name>

If first login, change password with passwd

Install Ubuntu updates

apt update
apt upgrade

If something has been installed run

sync;sync;shutdown -r now

Install tools, libraries and fonts

apt-get install nano git-core cmake
apt-get install zip unzip tar wget bzip2 mc
apt-get install libboost-all-dev build-essential autoconf libtool
apt-get install libosmium2-dev libprotozero-dev rapidjson-dev libboost-program-options-dev
apt-get install zlib1g-dev libexpat1-dev pandoc
apt-get install libxml2-dev libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev
apt-get install munin-node munin libprotobuf-c0-dev protobuf-c-compiler libfreetype6-dev
apt-get install libtiff5-dev libicu-dev libgdal-dev libcairo-dev libcairomm-1.0-dev libagg-dev
apt-get install devscripts libjson-perl libipc-sharelite-perl libgd-perl debhelper
apt-get install liblua5.2-dev lua5.1 liblua5.1-dev lua5.3 liblua5.3-dev
apt-get install ttf-unifont fonts-noto

Install Postgres database server

apt-get install postgresql postgresql-contrib postgis
nano /etc/postgresql/10/main/postgresql.conf

In nano you can search with Ctrl-w.
Check or edit the following values

shared_buffers = 128MB
work_mem = 256MB
maintenance_work_mem = 256MB
autovacuum = off

Save with Ctrl-x then y then Enter

nano /etc/sysctl.conf

At the top, after the other kernel-definitions, insert the following and save it


Restart server

sync;sync;shutdown -r now

Check successfully restart

who -b

Install Mapnik renderer

apt-get install libmapnik3.0 libmapnik-dev mapnik-utils python-mapnik unifont

Compile and install osm2pgsql

mkdir ~/src
cd ~/src
git clone git://
cd osm2pgsql
mkdir build && cd build
cmake ..
make install

Install Osmium

apt-get install osmium-tool

Configure Python 3 as default

nano ~/.bashrc

Insert the following at the bottom and save it

alias python=python3


source ~/.bashrc

Check Python version with

python --version

Install phyghtmap

apt-get install python3-setuptools python3-matplotlib python3-bs4 python3-numpy python3-gdal
cd ~/src
tar -xvzf phyghtmap_2.10.orig.tar.gz
cd phyghtmap-2.10
python3 install

Install gdal

apt-get install gdal-bin python-gdal

Configure users and roles

Create user gis with group gis and directory /home/gis.

adduser gis

Add role gis to Postgres database server

sudo -u postgres -i
createuser --createdb gis -s

Create data

SSH login with user gis

ssh -l gis <server-dns-name>

Start screen


You may close SSH console while command is running. After new SSH login continue with

screen -r

Close screen with


Create data folder

cd ~
mkdir data

Download and install Flight Contest maps server

cd ~/data
cd ~
unzip ~/data/

Download and install water polygons

cd ~/data
cd ~/fcmaps/otm/mapnik
mkdir data
cd ~/fcmaps/otm/mapnik/data
unzip ~/data/
unzip ~/data/
cd ~/fcmaps/otm-dev/mapnik
ln -s ~/fcmaps/otm/mapnik/data .

OSM data

Download data (Europe)

cd ~/data
mkdir osm && cd osm

Create database gis2

dropdb gis2
createdb gis2
psql -d gis2 -c 'CREATE EXTENSION postgis;'

Load OSM data into OSM database (~/data/osm/*.pbf → gis2)
(Germany, Austria, Switzerland, parts of France, Poland, Czech Republic, Slovakia, Hungary)

osm2pgsql -d gis2 --slim --drop --flat-nodes=FILENAME --bbox 1.0,42.0,24.0,55.0 --style ~/fcmaps/osm2pgsql/ ~/data/osm/europe-latest.osm.pbf

Wait…​ (22h)


cd ~/fcmaps/otm-dev/mapnik/tools/
psql gis2 < arealabel.sql
psql gis2 < stationdirection.sql
psql gis2 < viewpointdirection.sql
psql gis2 < pitchicon.sql
psql -d gis2 -c 'ALTER TABLE planet_osm_point ADD COLUMN otm_isolation text;'

Wait…​ (12h)

Activate new databases gis and lowzoom

dropdb gisold
dropdb lowzoomold
psql -d postgres -c 'ALTER DATABASE gis RENAME TO gisold;'
psql -d postgres -c 'ALTER DATABASE gis2 RENAME TO gis;'
psql -d postgres -c 'ALTER DATABASE lowzoom RENAME TO lowzoomold;'
psql -d postgres -c 'ALTER DATABASE lowzoom2 RENAME TO lowzoom;'

Check database size

psql -d postgres -c "SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;"

Contour data

cd ~/data
mkdir srtm
cd ~/data/srtm
nano list.txt

Insert the following (for Germany)

Save it and continue with

wget -i list.txt

Move zip files to folder germany and unpack all

mkdir germany && mv N*.zip germany && mv M*.zip germany && mv L*.zip germany
for zipfile in germany/*.zip; do unzip -j -o "$zipfile" -d germany/unpacked; done

Fill all voids (*.hgt → *.hgt.tif)

for hgtfile in germany/unpacked/*.hgt; do $hgtfile $hgtfile.tif; done

Merge into one huge tif (*.hgt.tif → raw.tif) -n 32767 -co BIGTIFF=YES -co TILED=YES -co COMPRESS=LZW -co PREDICTOR=2 -o germany/unpacked/raw.tif germany/unpacked/*.hgt.tif

Convert into Mercator projection, interpolate and shrink (raw.tif → 90.tif)

gdalwarp -co BIGTIFF=YES -co TILED=YES -co COMPRESS=LZW -co PREDICTOR=2 -t_srs "+proj=merc +ellps=sphere +R=6378137 +a=6378137 +units=m" -r bilinear -tr 90 90 germany/unpacked/raw.tif germany/unpacked/90.tif

Create 10m contour data (90.tif → lon*.pbf) (high memory consumption)

phyghtmap --step=10 --start-node-id=1000000000 --start-way-id=1000000000 --max-nodes-per-tile=0 --no-zero-contour --pbf germany/unpacked/90.tif
tif: 14844 x 23256 points, Lon 6...18°, Lat 44...56°

Wait…​ (4h)

Do these steps for other countries (with different folders and ids). Because of memory consumption of phyghtmap only max. 6 zip files.

France (node-id=3000000000)
tif: 14844 x 21493 points, Lon -6...6°, Lat 40...52°

South Africa (node-id=2000000000)
Lon 14...36°, Lat -35...-24°


Create database contours2

createdb contours2
psql -d contours2 -c 'CREATE EXTENSION postgis;'

Load contour data into contour database (all generated pbf files must be loaded together in one step)

osm2pgsql -d contours2 --slim --cache 12000 --number-processes 10 --style ~/fcmaps/osm2pgsql/ ~/data/srtm/lon*.pbf

Wait…​ (4h)

Activate new database contours

dropdb contoursold
psql -d postgres -c 'ALTER DATABASE contours RENAME TO contoursold;'
psql -d postgres -c 'ALTER DATABASE contours2 RENAME TO contours;'

Check database size

psql -d postgres -c "SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;"

Configure server

Check server ressources

Find out database size

psql -d postgres -c "SELECT pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size FROM pg_database;"

gis: 190GB, contours: 80GB, lowzoom: 800MB (Germany, Austria, Switzerland, France, South Africa)

Display free disk space


Display free ram

free -m

SSH login with user root

ssh -l root <server-dns-name>

Restart server

sync;sync;shutdown -r now

Check successfully restart

who -b

Run services

SSH login with user gis

Configure services as executable

cd ~/fcmaps
chmod +x printmaps_buildservice
chmod +x printmaps_webservice

Start services manually

nohup ./printmaps_buildservice 1>./logs/printmaps_buildservice.out 2>&1 &
nohup ./printmaps_webservice 1>./logs/printmaps_webservice.out 2>&1 &

Test web service


Search running service processes

ps -Af | grep "printmaps_"

Terminate running service processes

kill <pid>

Show log files

cat ./logs/printmaps_buildservice.log
cat ./logs/printmaps_webservice.log

Install services autostart

SSH login with user root

cd /etc/systemd/system

Create service description of build service

nano fcmaps_build.service
Description=Flight Contest maps build service

ExecStart=/home/gis/fcmaps/printmaps_buildservice ./printmaps_buildservice.yaml


Create service description of web service

nano fcmaps_web.service
Description=Flight Contest maps web service

ExecStart=/home/gis/fcmaps/printmaps_webservice ./printmaps_webservice.yaml


Enable autostart

systemctl enable fcmaps_build.service
systemctl enable fcmaps_web.service

Restart server

sync;sync;shutdown -r now

Check successfully restart

who -b

Configure Flight Contest

Add printserverapi in → Extras → Settings → Config

flightcontest {
  contestmap {
    printserverapi = "http://<server-dns-name>:8181/api/beta2/maps"

and restart Flight Contest.

Test map generation with → Routes → <Route> → OSM Contest Map.