Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 5.3 - new bbox value #1012

Merged
merged 6 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
TILESET_FILE=openmaptiles.yaml

# Use 3-part patch version to ignore patch updates, e.g. 5.0.0
TOOLS_VERSION=5.2
TOOLS_VERSION=5.3

# Make sure these values are in sync with the ones in .env-postgres file
PGDATABASE=openmaptiles
Expand All @@ -13,8 +13,9 @@ PGPASSWORD=openmaptiles
PGHOST=postgres
PGPORT=5432

# By default, tile generation is done for the full extent of the given area.
# Modify BBOX below to overwrite it.
# BBOX may get overwritten by the computed bbox of the specific area:
# make generate-bbox-file
# By default, the Makefile will use the content of data/$(area).bbox file if it exists.
BBOX=-180.0,-85.0511,180.0,85.0511

# Which zooms to generate in make generate-tiles
Expand Down
60 changes: 44 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,32 @@ ifeq ($(strip $(DIFF_MODE)),true)
export IMPOSM_CONFIG_FILE = data/$(area).repl.json
endif

# download-osm generates this file with metadata about the file
AREA_DC_CONFIG_FILE ?= data/$(area).dc-config.yml
# Load area-specific bbox file that gets generated by the download-osm --bbox
AREA_BBOX_FILE ?= data/$(area).bbox
ifneq (,$(wildcard $(AREA_BBOX_FILE)))
cat := $(if $(filter $(OS),Windows_NT),type,cat)
BBOX := $(shell $(cat) ${AREA_BBOX_FILE})
export BBOX
endif

ifeq ($(strip $(area)),)
define assert_area_is_given
@echo ""
@echo "ERROR: $(AREA_ERROR)"
@echo ""
@echo " make $@ area=<area-id>"
@echo ""
@echo "To download an area, use make download <area-id>"
@echo "To list downloadable areas, use make list-geofabrik and/or make list-bbbike"
@exit 1
endef
else
ifneq ($(strip $(AREA_INFO)),)
define assert_area_is_given
@echo "$(AREA_INFO)"
endef
endif
endif

#
# TARGETS
Expand Down Expand Up @@ -185,7 +208,7 @@ help:
@echo " make download-geofabrik area=albania # download OSM data from geofabrik.de and create config file"
@echo " make download-osmfr area=asia/qatar # download OSM data from openstreetmap.fr and create config file"
@echo " make download-bbbike area=Amsterdam # download OSM data from bbbike.org and create config file"
@echo " make generate-dc-config # scan data file and generate tile generation config file with bbox"
@echo " make generate-bbox-file # compute bounding box of a data file and store it in a file"
@echo " make psql # start PostgreSQL console"
@echo " make psql-list-tables # list all PostgreSQL tables"
@echo " make vacuum-db # PostgreSQL: VACUUM ANALYZE"
Expand Down Expand Up @@ -295,10 +318,12 @@ ifeq (,$(wildcard $(PBF_FILE)))
@echo "Downloading $(DOWNLOAD_AREA) with replication support into $(PBF_FILE) and $(IMPOSM_CONFIG_FILE) from $(if $(OSM_SERVER),$(OSM_SERVER),any source)"
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools download-osm $(OSM_SERVER) "$(DOWNLOAD_AREA)" \
--imposm-cfg "$(IMPOSM_CONFIG_FILE)" \
--bbox "$(AREA_BBOX_FILE)" \
--output "$(PBF_FILE)"
else
@echo "Downloading $(DOWNLOAD_AREA) into $(PBF_FILE) from $(if $(OSM_SERVER),$(OSM_SERVER),any source)"
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools download-osm $(OSM_SERVER) "$(DOWNLOAD_AREA)" \
--bbox "$(AREA_BBOX_FILE)" \
--output "$(PBF_FILE)"
endif
@echo ""
Expand All @@ -320,16 +345,13 @@ else
endif
endif

.PHONY: generate-dc-config
generate-dc-config:
.PHONY: generate-bbox-file
generate-bbox-file:
@$(assert_area_is_given)
ifeq (,$(wildcard $(AREA_DC_CONFIG_FILE)))
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c ' \
download-osm make-dc "$(PBF_FILE)" \
--make-dc "$(AREA_DC_CONFIG_FILE)" \
--id "$(area)"'
ifeq (,$(wildcard $(AREA_BBOX_FILE)))
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools download-osm bbox "$(PBF_FILE)" "$(AREA_BBOX_FILE)"
else
@echo "Configuration file $(AREA_DC_CONFIG_FILE) already exists, no need to regenerate."
@echo "Configuration file $(AREA_BBOX_FILE) already exists, no need to regenerate."
endif

.PHONY: psql
Expand Down Expand Up @@ -375,17 +397,14 @@ import-sql: all start-db-nowait
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools sh -c 'pgwait && import-sql' | \
awk -v s=": WARNING:" '1{print; fflush()} $$0~s{print "\n*** WARNING detected, aborting"; exit(1)}'

ifneq ($(wildcard $(AREA_DC_CONFIG_FILE)),)
DC_CONFIG_TILES := -f docker-compose.yml -f $(AREA_DC_CONFIG_FILE)
endif
.PHONY: generate-tiles
generate-tiles: all start-db
@$(assert_area_is_given)
@echo "Generating tiles into $(MBTILES_LOCAL_FILE) (will delete if already exists)..."
@rm -rf "$(MBTILES_LOCAL_FILE)"
$(DOCKER_COMPOSE) $(DC_CONFIG_TILES) run $(DC_OPTS) generate-vectortiles
$(DOCKER_COMPOSE) run $(DC_OPTS) generate-vectortiles
@echo "Updating generated tile metadata ..."
$(DOCKER_COMPOSE) $(DC_CONFIG_TILES) run $(DC_OPTS) openmaptiles-tools \
$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools \
mbtiles-tools meta-generate "$(MBTILES_LOCAL_FILE)" $(TILESET_FILE) --auto-minmax --show-ranges

.PHONY: start-tileserver
Expand Down Expand Up @@ -534,3 +553,12 @@ test-perf-null: init-dirs
.PHONY: build-test-pbf
build-test-pbf: init-dirs
docker-compose run $(DC_OPTS) openmaptiles-tools /tileset/.github/workflows/build-test-data.sh

.PHONY: debug
debug: ## Use this target when developing Makefile itself to verify loaded environment variables
@$(assert_area_is_given)
@echo file_exists = $(wildcard $(AREA_BBOX_FILE))
@echo AREA_BBOX_FILE = $(AREA_BBOX_FILE) , $$AREA_ENV_FILE
@echo BBOX = $(BBOX) , $$BBOX
@echo MIN_ZOOM = $(MIN_ZOOM) , $$MIN_ZOOM
@echo MAX_ZOOM = $(MAX_ZOOM) , $$MAX_ZOOM
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ services:
DIFF_MODE: ${DIFF_MODE}
MIN_ZOOM: ${MIN_ZOOM}
MAX_ZOOM: ${MAX_ZOOM}
#Provide BBOX from *.bbox file if exists, else from .env
BBOX: ${BBOX}
# Imposm configuration file describes how to load updates when enabled
IMPOSM_CONFIG_FILE: ${IMPOSM_CONFIG_FILE}
# Which files to use during import-borders processing
Expand Down
4 changes: 3 additions & 1 deletion quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,15 @@ make test-perf-null

echo " "
echo "-------------------------------------------------------------------------------------"

if [[ "$(source .env ; echo "$BBOX")" = "-180.0,-85.0511,180.0,85.0511" ]]; then
if [[ "$area" != "planet" ]]; then
echo "====> : Compute bounding box for tile generation"
make generate-dc-config ${MIN_ZOOM:+MIN_ZOOM="${MIN_ZOOM}"} ${MAX_ZOOM:+MAX_ZOOM="${MAX_ZOOM}"}
make generate-bbox-file ${MIN_ZOOM:+MIN_ZOOM="${MIN_ZOOM}"} ${MAX_ZOOM:+MAX_ZOOM="${MAX_ZOOM}"}
else
echo "====> : Skipping bbox calculation when generating the entire planet"
fi

else
echo "====> : Bounding box is set in .env file"
fi
Expand Down