GraphHopper

GraphHopper is a routing engine for OpenStreetMap. It can be used as a Java library or as a standalone web server.

Please refer to the official documentation on how to use the web server’s API.


License

License information can be found here

Installation

First of all, start with creating a directory for GraphHopper and enter it:

[isabell@stardust ~]$ mkdir ~/graphhopper
[isabell@stardust ~]$ cd ~/graphhopper
[isabell@stardust graphhopper]$

Before actually installing GraphHopper, a .osm.pbf map file must be downloaded into this directory. Such files can be found at Geofabrik (more information), for example. In order to minimize resource usage, please choose only a small map, preferably at district level.

Warning

A map of Berlin will be used as an example. Please replace the map names according to your needs. Choose small maps in order to not overuse the shared resources.

[isabell@stardust graphhopper]$ wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
[isabell@stardust graphhopper]$

Next, you should download the default configuration file.

[isabell@stardust graphhopper]$ wget -O config.yml https://raw.githubusercontent.com/graphhopper/graphhopper/4.x/config-example.yml
[isabell@stardust graphhopper]$

In order to make GraphHopper work with Uberspace web backends, change the bind_host setting in the server section of this configuration file from localhost to 0.0.0.0. Additionally, you should set the setting graph.dataaccess to MMAP in order to reduce RAM usage. Feel free to make further changes as you see fit.

Finally, you can download the actual GraphHopper Java archive:

[isabell@stardust graphhopper]$ wget https://graphhopper.com/public/releases/graphhopper-web-4.0.jar
[isabell@stardust graphhopper]$

Setup Daemon

Create the file ~/etc/services.d/graphhopper.ini with the following content:

Note

Remember to use your own username instead of isabell and adjust the file names according to the used version and map.

[program:graphhopper]
command=java -Ddw.graphhopper.datareader.file=berlin-latest.osm.pbf -jar graphhopper-web-4.0.jar server config.yml
directory=%(ENV_HOME)s/graphhopper
autostart=true
autorestart=true

After creating the configuration, tell supervisord to refresh its configuration and start the service:

[isabell@stardust ~]$ supervisorctl reread
SERVICE: available
[isabell@stardust ~]$ supervisorctl update
SERVICE: added process group
[isabell@stardust ~]$ supervisorctl status
SERVICE                            RUNNING   pid 26020, uptime 0:03:14
[isabell@stardust ~]$

Setup Web Backend

Note

GraphHopper is running on port 8989.

To make the application accessible from the outside, configure a web backend:

[isabell@stardust ~]$ uberspace web backend set / --http --port <port>
Set backend for / to port <port>; please make sure something is listening!
You can always check the status of your backend using "uberspace web backend list".
[isabell@stardust ~]$

Map Tiles

A map interface should now be available at https://isabell.uber.space/. You will probably see messages that your map tiles API key is invalid. In case you only need to use the GraphHopper Routing API, you can ignore this warning. In the upper right-hand corner, there’s a layer button, where you can choose the map tiles provider. The option “OpenStreetMap” likely works without further configuration. Further information on map tiles configuration can be found in a guide by GraphHopper.

Updates

Note

Check the update feed regularly to stay informed about the newest version.

To update GraphHopper, follow the installation procedure described above.


Tested with GraphHopper 4.0, Uberspace 7.11.5

Written by: Thomas S. <https://github.com/Thomas--S/>