2019-12-11 14:26:25 +00:00
|
|
|
# Options to run with docker and docker-compose - ensure the container is destroyed on exit
|
2020-03-06 18:15:54 +00:00
|
|
|
# Containers run as the current user rather than root (so that created files are not root-owned)
|
|
|
|
DC_OPTS?=--rm -u $$(id -u $${USER}):$$(id -g $${USER})
|
2019-12-12 17:40:31 +00:00
|
|
|
|
2019-12-16 13:37:34 +00:00
|
|
|
# If running in the test mode, compare files rather than copy them
|
|
|
|
TEST_MODE?=no
|
|
|
|
ifeq ($(TEST_MODE),yes)
|
2020-01-23 02:55:22 +00:00
|
|
|
# create images in ./build/devdoc and compare them to ./layers
|
|
|
|
GRAPH_PARAMS=./build/devdoc ./layers
|
2019-12-16 13:37:34 +00:00
|
|
|
else
|
2020-01-23 02:55:22 +00:00
|
|
|
# update graphs in the ./layers dir
|
|
|
|
GRAPH_PARAMS=./layers
|
2019-12-16 13:37:34 +00:00
|
|
|
endif
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: all
|
2016-10-28 19:56:39 +00:00
|
|
|
all: build/openmaptiles.tm2source/data.yml build/mapping.yaml build/tileset.sql
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: help
|
2016-11-30 04:39:06 +00:00
|
|
|
help:
|
|
|
|
@echo "=============================================================================="
|
|
|
|
@echo " OpenMapTiles https://github.com/openmaptiles/openmaptiles "
|
|
|
|
@echo "Hints for testing areas "
|
|
|
|
@echo " make download-geofabrik-list # list actual geofabrik OSM extracts for download -> <<your-area>> "
|
|
|
|
@echo " make list # list actual geofabrik OSM extracts for download -> <<your-area>> "
|
|
|
|
@echo " ./quickstart.sh <<your-area>> # example: ./quickstart.sh madagascar "
|
|
|
|
@echo " "
|
|
|
|
@echo "Hints for designers:"
|
2018-07-27 13:32:44 +00:00
|
|
|
@echo " make start-postserve # start Postserver + Maputnik Editor [ see localhost:8088 ] "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo " make start-tileserver # start klokantech/tileserver-gl [ see localhost:8080 ] "
|
2016-11-30 04:39:06 +00:00
|
|
|
@echo " "
|
|
|
|
@echo "Hints for developers:"
|
2018-10-12 07:46:09 +00:00
|
|
|
@echo " make # build source code"
|
2016-11-30 04:39:06 +00:00
|
|
|
@echo " make download-geofabrik area=albania # download OSM data from geofabrik, and create config file"
|
2018-10-12 07:46:09 +00:00
|
|
|
@echo " make psql # start PostgreSQL console"
|
|
|
|
@echo " make psql-list-tables # list all PostgreSQL tables"
|
2017-01-20 22:30:02 +00:00
|
|
|
@echo " make psql-vacuum-analyze # PostgreSQL: VACUUM ANALYZE"
|
|
|
|
@echo " make psql-analyze # PostgreSQL: ANALYZE"
|
2016-12-04 00:37:28 +00:00
|
|
|
@echo " make generate-qareports # generate reports [./build/qareports]"
|
2020-01-23 02:55:22 +00:00
|
|
|
@echo " make generate-devdoc # generate devdoc including graphs for all layers [./layers/...]"
|
2018-10-12 07:46:09 +00:00
|
|
|
@echo " make import-sql-dev # start import-sql /bin/bash terminal"
|
|
|
|
@echo " make import-osm-dev # start import-osm /bin/bash terminal (imposm3)"
|
|
|
|
@echo " make clean-docker # remove docker containers, PG data volume"
|
|
|
|
@echo " make forced-clean-sql # drop all PostgreSQL tables for clean environment"
|
2016-12-06 17:43:32 +00:00
|
|
|
@echo " make docker-unnecessary-clean # clean unnecessary docker image(s) and container(s)"
|
2016-11-30 04:39:06 +00:00
|
|
|
@echo " make refresh-docker-images # refresh openmaptiles docker images from Docker HUB"
|
|
|
|
@echo " make remove-docker-images # remove openmaptiles docker images"
|
|
|
|
@echo " make pgclimb-list-views # list PostgreSQL public schema views"
|
2018-10-12 07:46:09 +00:00
|
|
|
@echo " make pgclimb-list-tables # list PostgreSQL public schema tables"
|
|
|
|
@echo " cat .env # list PG database and MIN_ZOOM and MAX_ZOOM information"
|
2019-03-22 08:34:00 +00:00
|
|
|
@echo " cat quickstart.log # backup of the last ./quickstart.sh"
|
2018-10-12 07:46:09 +00:00
|
|
|
@echo " make help # help about available commands"
|
2016-11-30 04:39:06 +00:00
|
|
|
@echo "=============================================================================="
|
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
.PHONY: init-dirs
|
|
|
|
init-dirs:
|
|
|
|
mkdir -p build && mkdir -p data && mkdir -p cache
|
2016-10-23 15:36:48 +00:00
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
build/openmaptiles.tm2source/data.yml: init-dirs
|
2019-03-29 21:15:42 +00:00
|
|
|
mkdir -p build/openmaptiles.tm2source
|
2019-12-20 17:09:08 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools generate-tm2source openmaptiles.yaml --host="postgres" --port=5432 --database="openmaptiles" --user="openmaptiles" --password="openmaptiles" > $@
|
2016-10-23 15:36:48 +00:00
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
build/mapping.yaml: init-dirs
|
2019-12-20 17:09:08 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools generate-imposm3 openmaptiles.yaml > $@
|
2019-03-22 08:34:00 +00:00
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
build/tileset.sql: init-dirs
|
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools generate-sql openmaptiles.yaml > $@
|
2016-10-23 15:36:48 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: clean
|
2016-10-23 15:36:48 +00:00
|
|
|
clean:
|
2020-03-06 18:15:54 +00:00
|
|
|
rm -rf build
|
2016-11-27 10:31:43 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: clean-docker
|
2016-11-28 22:15:47 +00:00
|
|
|
clean-docker:
|
|
|
|
docker-compose down -v --remove-orphans
|
|
|
|
docker-compose rm -fv
|
|
|
|
docker volume ls -q | grep openmaptiles | xargs -r docker volume rm || true
|
2020-03-06 18:15:54 +00:00
|
|
|
rm -rf cache
|
2016-11-28 22:15:47 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: db-start
|
2018-07-27 13:32:44 +00:00
|
|
|
db-start:
|
2019-12-11 14:26:25 +00:00
|
|
|
docker-compose up -d postgres
|
2019-12-12 17:40:31 +00:00
|
|
|
@echo "Wait for PostgreSQL to start..."
|
|
|
|
docker-compose run $(DC_OPTS) import-osm ./pgwait.sh
|
2017-01-20 22:30:02 +00:00
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
.PHONY: db-stop
|
|
|
|
db-stop:
|
|
|
|
docker-compose stop postgres
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: download-geofabrik
|
2020-03-06 18:15:54 +00:00
|
|
|
download-geofabrik: init-dirs
|
|
|
|
@echo =============== download-geofabrik =======================
|
|
|
|
@echo Download area: $(area)
|
|
|
|
@echo [[ example: make download-geofabrik area=albania ]]
|
|
|
|
@echo [[ list areas: make download-geofabrik-list ]]
|
|
|
|
docker-compose run $(DC_OPTS) import-osm ./download-geofabrik.sh $(area)
|
2016-11-28 23:27:44 +00:00
|
|
|
ls -la ./data/$(area).*
|
|
|
|
@echo "Generated config file: ./data/docker-compose-config.yml"
|
2016-12-04 00:37:28 +00:00
|
|
|
@echo " "
|
|
|
|
cat ./data/docker-compose-config.yml
|
|
|
|
@echo " "
|
2016-11-28 23:27:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: psql
|
2018-07-27 13:32:44 +00:00
|
|
|
psql: db-start
|
2019-12-11 14:26:25 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh
|
2017-11-10 20:28:12 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: import-osm
|
2019-03-22 08:34:00 +00:00
|
|
|
import-osm: db-start all
|
2019-12-11 14:26:25 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm
|
2018-01-16 08:53:59 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: import-sql
|
2019-03-22 08:34:00 +00:00
|
|
|
import-sql: db-start all
|
2019-12-12 17:40:31 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools import-sql
|
2018-07-27 07:53:39 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: import-osmsql
|
2020-03-06 18:15:54 +00:00
|
|
|
import-osmsql: db-start all import-osm import-sql
|
|
|
|
|
|
|
|
.PHONY: import-borders
|
|
|
|
import-borders: db-start
|
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools import-borders
|
|
|
|
|
|
|
|
.PHONY: import-water
|
|
|
|
import-water: db-start
|
|
|
|
docker-compose run $(DC_OPTS) import-water
|
|
|
|
|
|
|
|
.PHONY: import-natural-earth
|
|
|
|
import-natural-earth: db-start
|
|
|
|
docker-compose run $(DC_OPTS) import-natural-earth
|
|
|
|
|
|
|
|
.PHONY: import-lakelines
|
|
|
|
import-lakelines: db-start
|
|
|
|
docker-compose run $(DC_OPTS) import-lakelines
|
2018-01-16 08:53:59 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: generate-tiles
|
2020-03-06 18:15:54 +00:00
|
|
|
generate-tiles: init-dirs db-start all
|
2018-01-16 08:53:59 +00:00
|
|
|
rm -rf data/tiles.mbtiles
|
2018-07-27 07:53:39 +00:00
|
|
|
if [ -f ./data/docker-compose-config.yml ]; then \
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose -f docker-compose.yml -f ./data/docker-compose-config.yml \
|
|
|
|
run $(DC_OPTS) generate-vectortiles; \
|
2018-07-27 07:53:39 +00:00
|
|
|
else \
|
2019-12-11 14:26:25 +00:00
|
|
|
docker-compose run $(DC_OPTS) generate-vectortiles; \
|
2018-07-27 07:53:39 +00:00
|
|
|
fi
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools generate-metadata ./data/tiles.mbtiles
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: start-tileserver
|
2020-03-06 18:15:54 +00:00
|
|
|
start-tileserver: init-dirs
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo " "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo "***********************************************************"
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo "* "
|
|
|
|
@echo "* Download/refresh klokantech/tileserver-gl docker image"
|
|
|
|
@echo "* see documentation: https://github.com/klokantech/tileserver-gl"
|
|
|
|
@echo "* "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo "***********************************************************"
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo " "
|
2017-01-08 12:31:24 +00:00
|
|
|
docker pull klokantech/tileserver-gl
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo " "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo "***********************************************************"
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo "* "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo "* Start klokantech/tileserver-gl "
|
|
|
|
@echo "* ----------------------------> check localhost:8080 "
|
2017-01-11 08:46:19 +00:00
|
|
|
@echo "* "
|
2017-01-08 12:31:24 +00:00
|
|
|
@echo "***********************************************************"
|
|
|
|
@echo " "
|
2019-12-11 14:26:25 +00:00
|
|
|
docker run $(DC_OPTS) -it --name tileserver-gl -v $$(pwd)/data:/data -p 8080:80 klokantech/tileserver-gl
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: start-postserve
|
2019-12-12 17:40:31 +00:00
|
|
|
start-postserve: db-start
|
2018-07-27 13:32:44 +00:00
|
|
|
@echo " "
|
|
|
|
@echo "***********************************************************"
|
|
|
|
@echo "* "
|
2019-12-12 17:40:31 +00:00
|
|
|
@echo "* Bring up postserve at localhost:8090"
|
2018-07-27 13:32:44 +00:00
|
|
|
@echo "* "
|
|
|
|
@echo "***********************************************************"
|
|
|
|
@echo " "
|
|
|
|
docker-compose up -d postserve
|
|
|
|
docker pull maputnik/editor
|
|
|
|
@echo " "
|
|
|
|
@echo "***********************************************************"
|
|
|
|
@echo "* "
|
|
|
|
@echo "* Start maputnik/editor "
|
2019-12-12 17:40:31 +00:00
|
|
|
@echo "* ---> go to http://localhost:8088"
|
|
|
|
@echo "* ---> set 'data source' to http://localhost:8090"
|
2018-07-27 13:32:44 +00:00
|
|
|
@echo "* "
|
|
|
|
@echo "***********************************************************"
|
|
|
|
@echo " "
|
|
|
|
docker rm -f maputnik_editor || true
|
2019-12-11 14:26:25 +00:00
|
|
|
docker run $(DC_OPTS) --name maputnik_editor -d -p 8088:8888 maputnik/editor
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: generate-qareports
|
2016-12-04 00:37:28 +00:00
|
|
|
generate-qareports:
|
|
|
|
./qa/run.sh
|
|
|
|
|
2019-03-29 21:15:42 +00:00
|
|
|
# generate all etl and mapping graphs
|
2020-01-23 02:55:22 +00:00
|
|
|
.PHONY: generate-devdoc
|
2020-03-06 18:15:54 +00:00
|
|
|
generate-devdoc: init-dirs
|
2020-01-23 02:55:22 +00:00
|
|
|
mkdir -p ./build/devdoc && \
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools-latest sh -c \
|
2020-01-23 02:55:22 +00:00
|
|
|
'generate-etlgraph openmaptiles.yaml $(GRAPH_PARAMS) && \
|
|
|
|
generate-mapping-graph openmaptiles.yaml $(GRAPH_PARAMS)'
|
2018-07-27 07:53:39 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: import-sql-dev
|
2018-07-27 07:53:39 +00:00
|
|
|
import-sql-dev:
|
2019-12-12 17:40:31 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools bash
|
2018-07-27 07:53:39 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: import-osm-dev
|
2018-07-27 07:53:39 +00:00
|
|
|
import-osm-dev:
|
2019-12-11 14:26:25 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm /bin/bash
|
2018-07-27 13:32:44 +00:00
|
|
|
|
|
|
|
# the `download-geofabrik` error message mention `list`, if the area parameter is wrong. so I created a similar make command
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: list
|
2020-03-06 18:15:54 +00:00
|
|
|
list: download-geofabrik-list
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: download-geofabrik-list
|
2018-07-27 13:32:44 +00:00
|
|
|
download-geofabrik-list:
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm ./download-geofabrik-list.sh
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2020-01-22 21:16:38 +00:00
|
|
|
.PHONY: import-wikidata
|
|
|
|
import-wikidata:
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) openmaptiles-tools import-wikidata openmaptiles.yaml
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: psql-pg-stat-reset
|
2018-07-27 13:32:44 +00:00
|
|
|
psql-pg-stat-reset:
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -P pager=off -c 'SELECT pg_stat_statements_reset();'
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: forced-clean-sql
|
2018-07-27 13:32:44 +00:00
|
|
|
forced-clean-sql:
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 \
|
|
|
|
-c "DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA IF NOT EXISTS public;" \
|
|
|
|
-c "CREATE EXTENSION hstore; CREATE EXTENSION postgis; CREATE EXTENSION unaccent;" \
|
|
|
|
-c "CREATE EXTENSION fuzzystrmatch; CREATE EXTENSION osml10n; CREATE EXTENSION pg_stat_statements;" \
|
|
|
|
-c "GRANT ALL ON SCHEMA public TO public; COMMENT ON SCHEMA public IS 'standard public schema';"
|
|
|
|
|
|
|
|
.PHONY: list-views
|
|
|
|
list-views:
|
|
|
|
@docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -A -F"," -P pager=off -P footer=off \
|
|
|
|
-c "select schemaname, viewname from pg_views where schemaname='public' order by viewname;"
|
|
|
|
|
|
|
|
.PHONY: list-tables
|
|
|
|
list-tables:
|
|
|
|
@docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -A -F"," -P pager=off -P footer=off \
|
|
|
|
-c "select schemaname, tablename from pg_tables where schemaname='public' order by tablename;"
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2020-03-06 18:15:54 +00:00
|
|
|
.PHONY: psql-list-tables
|
|
|
|
psql-list-tables:
|
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -P pager=off -c "\d+"
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: psql-vacuum-analyze
|
2018-07-27 13:32:44 +00:00
|
|
|
psql-vacuum-analyze:
|
|
|
|
@echo "Start - postgresql: VACUUM ANALYZE VERBOSE;"
|
2020-03-06 18:15:54 +00:00
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -P pager=off -c 'VACUUM ANALYZE VERBOSE;'
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: psql-analyze
|
2018-07-27 13:32:44 +00:00
|
|
|
psql-analyze:
|
2020-03-06 18:15:54 +00:00
|
|
|
@echo "Start - postgresql: ANALYZE VERBOSE;"
|
|
|
|
docker-compose run $(DC_OPTS) import-osm ./psql.sh -v ON_ERROR_STOP=1 -P pager=off -c 'ANALYZE VERBOSE;'
|
2018-07-27 13:32:44 +00:00
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: list-docker-images
|
2018-07-27 13:32:44 +00:00
|
|
|
list-docker-images:
|
|
|
|
docker images | grep openmaptiles
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: refresh-docker-images
|
2018-07-27 13:32:44 +00:00
|
|
|
refresh-docker-images:
|
|
|
|
docker-compose pull --ignore-pull-failures
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: remove-docker-images
|
2018-07-27 13:32:44 +00:00
|
|
|
remove-docker-images:
|
|
|
|
@echo "Deleting all openmaptiles related docker image(s)..."
|
|
|
|
@docker-compose down
|
|
|
|
@docker images | grep "openmaptiles" | awk -F" " '{print $$3}' | xargs --no-run-if-empty docker rmi -f
|
|
|
|
@docker images | grep "osm2vectortiles/mapbox-studio" | awk -F" " '{print $$3}' | xargs --no-run-if-empty docker rmi -f
|
|
|
|
@docker images | grep "klokantech/tileserver-gl" | awk -F" " '{print $$3}' | xargs --no-run-if-empty docker rmi -f
|
|
|
|
|
2019-12-11 14:26:25 +00:00
|
|
|
.PHONY: docker-unnecessary-clean
|
2018-07-27 13:32:44 +00:00
|
|
|
docker-unnecessary-clean:
|
|
|
|
@echo "Deleting unnecessary container(s)..."
|
|
|
|
@docker ps -a | grep Exited | awk -F" " '{print $$1}' | xargs --no-run-if-empty docker rm
|
|
|
|
@echo "Deleting unnecessary image(s)..."
|
|
|
|
@docker images | grep \<none\> | awk -F" " '{print $$3}' | xargs --no-run-if-empty docker rmi
|