-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport-osm.sh
More file actions
executable file
·27 lines (22 loc) · 902 Bytes
/
import-osm.sh
File metadata and controls
executable file
·27 lines (22 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
set -e
if [ -z "$DIRECTORY_OF_OSM_FILES" ]
then
echo "\$DIRECTORY_OF_OSM_FILES must be specified, gets mounted to container"
exit 1
fi
if [ -z "$OSM_FILE" ]
then
echo "\$OSM_FILE must be specified (e.g. \"planet.osm.pbf\"), gets imported"
exit 1
fi
NUM_CORES=$(getconf _NPROCESSORS_ONLN)
FREE_MEM=$(free -m | awk '/^Mem:/{print $4}')
PROB_SAFE_MEM=$(($FREE_MEM / 6 * 4))
docker run -it --rm \
--network mapping-stack_default \
-e PGPASS=secretmapping \
--link $(docker-compose ps -q postgis):pg \
-v $DIRECTORY_OF_OSM_FILES:/osm \
-v "$(pwd)"/openstreetmap-carto:/transforms openfirmware/osm2pgsql \
-c "osm2pgsql --create --slim --hstore --style /transforms/openstreetmap-carto.style --tag-transform-script /transforms/openstreetmap-carto.lua --cache $PROB_SAFE_MEM --number-processes $NUM_CORES --database osm --username osm --host pg --port 5432 /osm/$OSM_FILE"