-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·36 lines (27 loc) · 1.07 KB
/
setup
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
#!/usr/bin/env bash
root_dir=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
# check if osm4routing is installed
if ! [ "$( command -v osm4routing)" ]; then
printf "osm4routing not installed. Please install using 'cargo install osm4routing'.\nSee instructions on installing cargo here: https://doc.rust-lang.org/cargo/getting-started/installation.html\nexiting...\n" >&2
exit 1
fi
# check arguments
if ! [ $# -gt 1 ]; then
printf "Please provide a path to an OSM file and a name to be used as the table name for that dataset.\n" >&2
exit 1
fi
path=$1
name=$2
echo "Creating edges and nodes..."
mkdir -p $root_dir/data
cd $root_dir/data
osm4routing $path
mkdir -p $root_dir/init_db
# create sql scripts from templates
for f in $root_dir/template/*.sql; do
filebase=$(basename $f)
table=$name envsubst < $f > $root_dir/init_db/$filebase
done
# lastly, create an import script for importing into existing PostGIS instance
table=$name data_path=$root_dir/data envsubst '${table} ${data_path}' < $root_dir/template/import > $root_dir/import.sh
chmod u+x $root_dir/import.sh