forked from graphhopper/graphhopper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·106 lines (91 loc) · 2.82 KB
/
run.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
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
JAVA=$JAVA_HOME/bin/java
if [ "x$JAVA_HOME" = "x" ]; then
JAVA=java
fi
vers=`$JAVA -version 2>&1 | grep "java version" | awk '{print $3}' | tr -d \"`
echo "using java $vers from $JAVA_HOME"
FILE=$1
ALGO=$2
CLASS=$3
if [ "x$ALGO" = "xui" ]; then
CLASS=com.graphhopper.ui.MiniGraphUI
else
CLASS=com.graphhopper.reader.OSMReader
fi
if [ "x$ALGO" = "x" ]; then
ALGO=astar
fi
if [ "x$FILE" = "x" ]; then
FILE=unterfranken.osm
fi
# file without extension if any
NAME="${FILE%.*}"
OSM=$NAME.osm
GRAPH=$NAME-gh
VERSION=`grep "<name>" -A 1 pom.xml | grep version | cut -d'>' -f2 | cut -d'<' -f1`
JAR=target/graphhopper-$VERSION-jar-with-dependencies.jar
# file without path
TMP=$(basename "$FILE")
TMP="${TMP%.*}"
#echo $TMP - $FILE - $NAME
if [ "$TMP" = "unterfranken" ]; then
LINK="http://download.geofabrik.de/openstreetmap/europe/germany/bayern/unterfranken.osm.bz2"
JAVA_OPTS_IMPORT="-XX:PermSize=20m -XX:MaxPermSize=20m -Xmx500m -Xms500m"
JAVA_OPTS=$JAVA_OPTS_IMPORT
SIZE=3000000
elif [ "$TMP" = "germany" ]; then
LINK=http://download.geofabrik.de/openstreetmap/europe/germany.osm.bz2
# For import we need a lot more memory. For the mmap storage you need to lower this in order to use off-heap memory.
JAVA_OPTS_IMPORT="-XX:PermSize=10m -XX:MaxPermSize=10m -Xmx2200m -Xms2200m"
JAVA_OPTS="-XX:PermSize=20m -XX:MaxPermSize=20m -Xmx1900m -Xms1900m"
SIZE=35000000
elif [ -f $OSM ]; then
LINK=""
JAVA_OPTS_IMPORT="-XX:PermSize=20m -XX:MaxPermSize=20m -Xmx1000m -Xms1000m"
JAVA_OPTS=$JAVA_OPTS_IMPORT
SIZE=10000000
else
echo "Sorry, your osm file $OSM was not found ... exiting"
exit
fi
if [ ! -f "config.properties" ]; then
cp config-example.properties config.properties
fi
if [ ! -f "$OSM" ]; then
echo "No OSM file found or specified. Press ENTER to grab one from internet."
echo "Press CTRL+C if you do not have enough disc space or you don't want to download several MB."
read -e
BZ=$OSM.bz2
rm $BZ &> /dev/null
echo "## now downloading OSM file from $LINK"
# curl or wget
DOWNLOADER=`which curl`
if [ "x$DOWNLOADER" = "x" ]; then
wget -O $BZ $LINK
else
curl -O $LINK
fi
echo "## extracting $BZ"
bzip2 -d $BZ
if [ ! -f "$OSM" ]; then
echo "ERROR couldn't download or extract OSM file $OSM ... exiting"
exit
fi
else
echo "## using existing osm file $OSM"
fi
if [ ! -f "$JAR" ]; then
echo "## now building graphhopper jar: $JAR"
#mvn clean
mvn -DskipTests=true install assembly:single > /dev/null
returncode=$?
if [[ $returncode != 0 ]] ; then
echo "## compilation failed"
exit $returncode
fi
else
echo "## existing jar found $JAR"
fi
echo "## now running $CLASS. algo=$ALGO. JAVA_OPTS=$JAVA_OPTS"
$JAVA $JAVA_OPTS -cp $JAR $CLASS config=config.properties osmreader.graph-location=$GRAPH osmreader.osm=$OSM osmreader.size=$SIZE osmreader.algo=$ALGO