GraphHopper is a fast and Open Source routing engine written in Java. The sources are at Github and you can try it online. Some months ago Java itself was ported to Raspberry Pi (ARM) and the latest versions even have the JDK from Oracle preinstalled. So there is no reason to not trying GraphHopper on Raspberry Pi as today my device arrived! I was using NOOBS and installed Raspbian where the JDK from Oracle and git-core were already installed. If you have an older release do:
sudo apt-get install oracle-java7-jdk
Now the GraphHopper setup itself is done with 4 easy steps, you’ll need internet access for downloading some files as well as for displaying the tiles:
- git clone https://github.com/graphhopper/graphhopper/
- # Avoid the “-server” option and reduce the default memory usage for graphhopper. E.g. for Berlin you can do:
export JAVA_OPTS=”-Xmx100m -Xms100m”; cd graphhopper
- ./graphhopper.sh import europe_germany_berlin.pbf
# This will take a bit and if it is finished you’ll see “[INFO] Started Jetty Server”
# Under the hood it will do:
# 1. get maven
# 2. compile GraphHopper (takes 10min!?)
# 3. install a smaller area ‘Berlin’ (6min for import, 5min for CH preparation). You can avoid this if you create the GraphHopper files on your Desktop which is a lot faster and then copy them to your Raspberry Pi via scp -r europe_germany_berlin-gh pi@raspberrypi:/home/pi/graphhopper/
# 4. start a server at localhost:8989
- Now you can access the started server via your browser e.g. from Raspberry Pi itself with iceweasel or chromium-browser (midori won’t work)
If this doesn’t work try http://localhost:8989/ or connect Pi to your LAN and access GraphHopper web from your Desktop via the same URL.
Here is a screenshot – via tiles from Lyrk:
Raspberry Pi has less limitations compared to Android!
- You have a JDK 7 from Oracle, not the Dalvik thing which supports Java 5 only. So you can do even the GraphHopper file creation (“import”) directly on the mobile machine although this will be slower (factor 5-10) compared to my laptop. Also you can out of the box start and use a server on the machine. Sharing GraphHopper routing on Android is currently no out-of-the-box-solution but one should be able to make it working too.
- You have a fully working Debian distribution with nice ‘apt-get’ capabilities
- You can use all the available RAM and not only the 32MB which is a limitation per App on Android. So routing will be faster because until the 500MB (limit on Raspberry Pi) you can use the in-memory settings of GraphHopper or if using the slower MMAP setting then Raspberry Pi will load more data into the RAM compared to Android.
- On Android you can have offline maps via the mapsforge project. You couldn’t do the same for Raspberry Pi but there is now a branch called ‘rescue’ which enables you to have offline maps for Raspberry Pi. This branch already works, but is not yet released.
- For full maps you will need a separate monitor – e.g. this here? And address search which is currently only possible via online service.