-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload_road_data.sh
executable file
·42 lines (34 loc) · 1.15 KB
/
load_road_data.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
#!/bin/bash
load_road_data () {
roadnodeCreated=false;
roadlinkCreated=false;
motorwayJunctionCreated=false;
for i in $(find road_data/data -type f -name '*.shp'); do
echo "Processing $i"
fileName=${i:18}
fileNameWithoutExtension=${fileName%.*}
tableName=${fileNameWithoutExtension,,}
if [ $tableName == "roadnode" ]; then createDatabaseTable $roadnodeCreated $tableName; fi;
if [ $tableName == "roadlink" ]; then createDatabaseTable $roadlinkCreated $tableName; fi;
if [ $tableName == "motorwayjunction" ]; then createDatabaseTable $motorwayJunctionCreated $tableName; fi;
shp2pgsql -s 27700 -a $i roads.$tableName | psql -h localhost -d roads -U admin -e;
done;
createGeomIndexes
createDBDump
}
createDatabaseTable() {
if "$1" = true
then
:
else
shp2pgsql -s 27700 -p $i roads.$2 | psql -h localhost -d roads -U admin;
$1=true;
fi;
}
createGeomIndexes() {
psql -h localhost -d roads -U admin -f create_gist_indexes.sql
}
createDBDump() {
pg_dump -h localhost -U admin -Fc -v -O roads > ./db_data/os_open_roads.dump
}
load_road_data