From 0493b77f0afb64407ee381b7c476c37e924ec3ba Mon Sep 17 00:00:00 2001 From: Falke Design Date: Fri, 8 Oct 2021 10:37:45 +0200 Subject: [PATCH] Add APPEND_MODE to import-osm (#365) If **APPEND_MODE** is set to true, `import-osm` can used to import multiple areas. The flag `-overwritecache` always clean up the cache and remove the existing data. With `-appendcache` the data will appended. #### Usage: To use it with `openmaptiles` it is enough to add the variable in the `.env`: ``` APPEND_MODE=true ``` Co-authored-by: Yuri Astrakhan --- bin/import-osm | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/bin/import-osm b/bin/import-osm index bc07c342..4175ab6d 100755 --- a/bin/import-osm +++ b/bin/import-osm @@ -14,29 +14,42 @@ export PGPORT="${POSTGRES_PORT:-${PGPORT:-5432}}" : "${DIFF_MODE:=true}" +: "${APPEND_MODE:=false}" function import_pbf() { local pbf_file="$1" - local diff_flag="" + + local extra_flags="" + local action_msg="" + local mode_msg="" + if [ "$DIFF_MODE" = true ]; then - diff_flag="-diff" - echo "Importing $pbf_file into $PGHOST:$PGPORT/$PGDATABASE using Imposm in DIFF mode..." + extra_flags="$extra_flags -diff" + mode_msg="NORMAL" + else + mode_msg="DIFF" + fi + + if [ "$APPEND_MODE" = true ]; then + extra_flags="$extra_flags -appendcache" + action_msg="Appending" else - echo "Importing $pbf_file into $PGHOST:$PGPORT/$PGDATABASE using Imposm in NORMAL mode..." + extra_flags="$extra_flags -overwritecache" + action_msg="Importing" fi + echo "$action_msg $pbf_file into $PGHOST:$PGPORT/$PGDATABASE using Imposm in $mode_msg mode..." imposm import \ -connection "postgis://$PGUSER:$PGPASSWORD@$PGHOST:$PGPORT/$PGDATABASE" \ -mapping "${IMPOSM_MAPPING_FILE:?}" \ - -overwritecache \ -diffdir "${IMPOSM_DIFF_DIR:?}" \ -cachedir "${IMPOSM_CACHE_DIR:?}" \ -read "$pbf_file" \ -deployproduction \ -write \ - $diff_flag \ - -config "${IMPOSM_CONFIG_FILE:?}" + -config "${IMPOSM_CONFIG_FILE:?}" \ + $extra_flags } function import_osm_with_first_pbf() {