Skip to content

Commit

Permalink
Add APPEND_MODE to import-osm (#365)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Falke-Design and nyurik authored Oct 8, 2021
1 parent 9918a00 commit 0493b77
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions bin/import-osm
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 0493b77

Please sign in to comment.