-
Notifications
You must be signed in to change notification settings - Fork 0
/
import_osm.sh
executable file
·50 lines (36 loc) · 2.24 KB
/
import_osm.sh
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
set -e
PROGPATH=$(dirname "$0")
source $PROGPATH/env.sh
pbf_file="$1"
MAPPING_YAML=build/mapping.yaml
LAST_UPDATE_SQL=build/last_update.sql
readonly PG_CONNECT="postgis: user=$POSTGRES_USER password=$POSTGRES_PASSWORD host=$POSTGRES_HOST port=$POSTGRES_PORT dbname=$POSTGRES_DB"
echo $PG_CONNECT
mkdir -p "$IMPOSM_CACHE_DIR"
./generate_mapping.py layers build
echo "DROP SCHEMA backup CASCADE;" | psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER" || true
imposm import \
-connection "$PG_CONNECT" \
-mapping "$MAPPING_YAML" \
-overwritecache \
-cachedir "$IMPOSM_CACHE_DIR" \
-read "$pbf_file" \
-deployproduction \
-write
echo "DROP SCHEMA backup CASCADE;" | psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER" || true
#################################
# update sql
#psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER" < "$UPDATE_SQL"
#parallel --lb --halt now,fail=1 'cat {} | psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER"' ::: build/layer*sql
parallel --lb --halt now,fail=1 'cat {} | psql --echo-queries --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER"' ::: build/layer*sql
#################################
# handle large polygons in osm_landcover_processed_polygon
AREA="1e+10"
for table in osm_landcover_processed_polygon_z12 osm_landcover_processed_polygon_z13 osm_landcover_processed_polygon ; do
echo Processing $table
python split-large-polygons/split_large_polygons.py -t $table -c geometry -i row_id -a $AREA -s 3857
echo "CLUSTER $table USING ${table}_geometry_idx;" | psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER"
echo
done
psql --echo-queries -v ON_ERROR_STOP=1 --host="$POSTGRES_HOST" --port="$POSTGRES_PORT" --dbname="$POSTGRES_DB" --username="$POSTGRES_USER" < "$LAST_UPDATE_SQL"