-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.sh
executable file
·96 lines (79 loc) · 3.49 KB
/
init.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /bin/bash
# see http://wiki.openstreetmap.org/wiki/Osm2pgsql
# -c create new
# -G Generate multi-geometry features
# -U dbuser
# -d dbname
# -C cache size
# -S style-file
if [ ! "$(docker ps -q -f name=postgis)" ]; then
if [ "$(docker ps -aq -f status=exited -f name=postgis)" ]; then
echo "removing old postgis container"
docker rm postgis
fi
# run your container
echo "starting postgis container"
docker run -d \
--name postgis \
-p 5432:5432 \
--user "$(id -u):$(id -g)" \
-v /etc/passwd:/etc/passwd:ro \
-v /media/mapdata/pgdata_henry:/media/mapdata/pgdata_henry \
-v $(pwd)/pg-config/postgis-import.conf:/etc/postgresql/postgresql.conf \
-e PGDATA=/media/mapdata/pgdata_henry \
img-postgis:0.8 -c 'config_file=/etc/postgresql/postgresql.conf'
else echo "postgis container already running"
fi
while ! pg_isready -h localhost -p 5432 > /dev/null 2> /dev/null; do
echo "waiting for database"
sleep 1
done
src="/media/henry/Tools/map/data/dummy.osm.pbf"
dbname="world"
param="-C 10000 -G -v --number-processes 4 --slim"
style="styles/osm2pgsql.style"
# psql -U postgres -h localhost -c "DROP DATABASE IF EXISTS $dbname;"
# psql -U postgres -h localhost -c "COMMIT;"
# psql -U postgres -h localhost -c "CREATE DATABASE $dbname WITH ENCODING='UTF8' CONNECTION LIMIT=-1;"
#
# psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis;"
# psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis_topology;"
# psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis_sfcgal;"
# psql -U postgres -h localhost -d $dbname -c "ALTER DATABASE $dbname SET postgis.backend = sfcgal;"
#
# osm2pgsql $param -U postgres -H localhost -d $dbname -c -S $style $src
#
#
# shp2pgsql -s 3785 /media/mapdata/henry/TileGenerator/data/shp/admin-6-land-boundaries-DE.shp public.admin6_de | psql -U postgres -h localhost -d $dbname
#
# shp2pgsql -s 3785 /media/mapdata/henry/TileGenerator/data/shp/admin-4-land-boundaries-DE.shp public.admin4 | psql -U postgres -h localhost -d $dbname
#
# shp2pgsql -s 3785 /media/mapdata/henry/TileGenerator/data/shp/admin-2-land-boundaries.shp public.admin2 | psql -U postgres -h localhost -d $dbname
#
# shp2pgsql -s 3785 /media/mapdata/henry/TileGenerator/data/shp/admin-2-land-boundaries-simplified.shp public.admin2_simplified | psql -U postgres -h localhost -d $dbname
shadefolder=/media/ramdisk
style="styles/contours.style"
dbname="contours"
psql -U postgres -h localhost -c "DROP DATABASE IF EXISTS $dbname;"
psql -U postgres -h localhost -c "COMMIT;"
psql -U postgres -h localhost -c "CREATE DATABASE $dbname WITH ENCODING='UTF8' CONNECTION LIMIT=-1;"
psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis;"
psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis_topology;"
psql -U postgres -h localhost -d $dbname -c "CREATE EXTENSION postgis_sfcgal;"
psql -U postgres -h localhost -d $dbname -c "ALTER DATABASE $dbname SET postgis.backend = sfcgal;"
cnt=0
for file in $shadefolder/*clip_local-source.osm.pbf
do
base=`basename $file .pbf`
echo "importing" $base.pbf
if (($cnt == 0)) ; then
echo "creating"
time osm2pgsql -s -C 12000 --verbose --number-processes 8 -U postgres -H localhost -d $dbname --create -S $style $file
else
echo "appending"
time osm2pgsql -s -C 12000 --verbose --number-processes 8 -U postgres -H localhost -d $dbname --append -S $style $file
fi
echo ""
cnt=$(($cnt+1))
done
echo "all done"