New generate-dc-config target, rm QUICKSTART_MIN/MAX_ZOOM (#915)

* Set `MAX_ZOOM` to 7 by default.
* Remove `QUICKSTART_MIN/MAX_ZOOM` - unneeded complexity with two env vars. We can just use `MIN_ZOOM` and `MAX_ZOOM`. See also #261
* Generate dc-config yaml file with a new `make generate-dc-config` step. It will compute BBOX based on the downloaded data file. This step is not needed for planet generation.
* Generate Imposm replication file only when `DIFF_MODE` is `true`. Not needed otherwise. If the data source does not support it, it will throw an error.
This commit is contained in:
Yuri Astrakhan
2020-06-04 15:45:04 -04:00
committed by GitHub
parent 1486b7e0cb
commit 1a9f6132c3
6 changed files with 57 additions and 50 deletions

View File

@@ -51,6 +51,12 @@ endif
# Set OpenMapTiles host
OMT_HOST := http://$(firstword $(subst :, ,$(subst tcp://,,$(DOCKER_HOST))) localhost)
# This defines an easy $(newline) value to act as a "\n". Make sure to keep exactly two empty lines after newline.
define newline
endef
#
# Determine area to work on
@@ -161,6 +167,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 psql # start PostgreSQL console"
@echo " make psql-list-tables # list all PostgreSQL tables"
@echo " make vacuum-db # PostgreSQL: VACUUM ANALYZE"
@@ -255,41 +262,35 @@ OSM_SERVER=$(patsubst download,,$(patsubst download-%,%,$@))
.PHONY: $(ALL_DOWNLOADS)
$(ALL_DOWNLOADS): init-dirs
@$(assert_area_is_given)
ifeq (,$(wildcard $(PBF_FILE)))
ifneq ($(strip $(url)),)
$(if $(OSM_SERVER),$(error url parameter can only be used with the 'make download area=... url=...'))
$(if $(OSM_SERVER),$(error url parameter can only be used with non-specific download target:$(newline) make download area=$(area) url="$(url)"$(newline)))
endif
@echo "Downloading $(area) into $(PBF_FILE) from $(if $(OSM_SERVER),$(OSM_SERVER),any source)"
ifeq (,$(wildcard $(PBF_FILE)))
@echo "Downloading $(DOWNLOAD_AREA) into $(PBF_FILE) from $(if $(OSM_SERVER),$(OSM_SERVER),any source)"
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c ' \
download-osm $(OSM_SERVER) $(DOWNLOAD_AREA) \
--minzoom $$QUICKSTART_MIN_ZOOM \
--maxzoom $$QUICKSTART_MAX_ZOOM \
--make-dc $(AREA_DC_CONFIG_FILE) \
--imposm-cfg $(IMPOSM_CONFIG_FILE) \
--output $(PBF_FILE) \
2>&1 \
| tee /tmp/download.out ; \
exit_code=$${PIPESTATUS[0]} ; \
if [[ "$$exit_code" != "0" ]]; then \
if grep -q "Imposm config file cannot be generated from this source" /tmp/download.out; then \
echo "WARNING: $(IMPOSM_CONFIG_FILE) could not be generated, but it is only needed to apply updates." ; \
else \
exit $$exit_code ; \
fi ; \
if [[ "$$DIFF_MODE" == "true" ]]; then \
download-osm $(OSM_SERVER) "$(DOWNLOAD_AREA)" \
--imposm-cfg "$(IMPOSM_CONFIG_FILE)" \
--output "$(PBF_FILE)" ; \
else \
download-osm $(OSM_SERVER) "$(DOWNLOAD_AREA)" \
--output "$(PBF_FILE)" ; \
fi'
@echo ""
else
@echo "Data files $(PBF_FILE) already exists, skipping the download."
endif
.PHONY: generate-dc-config
generate-dc-config:
@$(assert_area_is_given)
ifeq (,$(wildcard $(AREA_DC_CONFIG_FILE)))
@echo "Data file $(PBF_FILE) already exists, but the $(AREA_DC_CONFIG_FILE) is not, generating..."
@$(DOCKER_COMPOSE) run $(DC_OPTS) openmaptiles-tools bash -c ' \
download-osm make-dc $(PBF_FILE) \
--minzoom $$QUICKSTART_MIN_ZOOM \
--maxzoom $$QUICKSTART_MAX_ZOOM \
--make-dc $(AREA_DC_CONFIG_FILE) \
download-osm make-dc "$(PBF_FILE)" \
--make-dc "$(AREA_DC_CONFIG_FILE)" \
--id "$(area)"'
else
@echo "Data files $(PBF_FILE) and $(AREA_DC_CONFIG_FILE) already exists, skipping the download."
endif
@echo "Configuration file $(AREA_DC_CONFIG_FILE) already exists, no need to regenerate."
endif
.PHONY: psql