-
Notifications
You must be signed in to change notification settings - Fork 1
/
osrm.sh
executable file
·51 lines (43 loc) · 1.89 KB
/
osrm.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
#!/bin/sh
OSRM_DATA_PATH="/data"
_sig() {
kill -TERM $child 2>/dev/null
}
trap _sig SIGKILL SIGTERM SIGHUP SIGINT EXIT
if [ ! -f $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm.hsgr ]; then
if [ ! -f $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf ]; then
echo "Downloading $OSRM_MAP_NAME from $OSRM_MAP_URL"
wget -O $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf $OSRM_MAP_URL
reteval=$?
if [ ${reteval} -ne 0 ]; then
echo "$OSRM_MAP_NAME download to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf failed"
exit 1;
fi
FILESIZE=$(stat -c%s "$OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf")
echo "$OSRM_MAP_NAME downloaded to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf ($FILESIZE bytes)"
fi
echo "Extracting the Road Network from $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf using $OSRM_EXT_PROFILE profile"
osrm-extract -p /opt/$OSRM_EXT_PROFILE.lua $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf
reteval=$?
if [ ${reteval} -ne 0 ]; then
echo "$OSRM_MAP_NAME extraction to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm failed"
exit 1;
fi
FILESIZE=$(stat -c%s "$OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm")
echo "$OSRM_MAP_NAME extracted to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm ($FILESIZE bytes)"
echo "Deleting $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf"
rm $OSRM_DATA_PATH/$OSRM_MAP_NAME.osm.pbf
echo "Creating the Hierarchy from $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm"
osrm-contract $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm
if [ ${reteval} -ne 0 ]; then
echo "$OSRM_MAP_NAME hierarchy precomputation to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm.hsgr failed"
exit 1;
fi
FILESIZE=$(stat -c%s "$OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm.hsgr")
echo "$OSRM_MAP_NAME hierarchy precomputed to $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm.hsgr ($FILESIZE bytes)"
echo "$OSRM_MAP_NAME.osm.pbf pre-processing ended"
fi
echo "Starting routing engine HTTP server"
osrm-routed $OSRM_DATA_PATH/$OSRM_MAP_NAME.osrm $OSRM_API_PARAMS &
child=$!
wait "$child"