GraphHopper an Open Source and Flexible Alternative to Google Maps API

Update: No need to install and maintain GraphHopper on your own expensive hardware. Sign up to the GraphHopper Directions API for business which makes it very easy, cost effective and reliable to consume GraphHopper routes with always up-to-date software and OpenStreetMap data.

On Monday we released version 0.2 of GraphHopper an Open Source road routing engine. GraphHopper is comparable fast to Google or Bing Maps, but if you use it in a LAN or directly from within your application it is a lot faster as it avoids the round trip over the internet, but furthermore if you need one-to-many or even many-to-many routes then GraphHopper is orders of magnitude faster. In this blog entry I’ll show you how to get everything you need to setup GraphHopper on your own servers. Hosting GraphHopper on your own servers also means: you can query it as much as YOU like, currently this means 300 to 600 queries per second which is dependent on your hardware, of course. This is measured from real life car routes larger than 100km. Now, as you’ll set up a fault tolerant system with at least two servers this means you can put a load of over 100 mio requests per day on your system. This is 1000 times more than the limit of the Google Maps Business API and again: for one/many-to-many the benefits are even larger.

1. Install GraphHopper

Do so, either via our quick start docs or directly from the source which is my preferred way as you can easily stay up-to-date and try out minor code changes a lot faster. Although it will require that you’ve installed git and the JDK:

$ git clone git://
$ cd graphhopper
$ ./ web europe_germany_berlin.pbf

You should see this console output: console-berlin-gh It will start a jetty server on port 8989 – so if no exception occured you can go to http://localhost:8989 and if you clicked on two positions you should see the route for a car (default – can be changed in browser-berlin-gh

2. World Wide Routing Service

I assume you need car, pedestrian and bicycle routing for your personal world wide routing service. For this routing service you need two runtime servers (to make the system fault tolerant) and for each at least 52GB RAM. Additionally you need one ‘smaller’ preparation server with at least 32GB of RAM to prepare the graph for fast routing – you only need it for updating the OpenStreetMap data e.g. once a week. If you want to avoid this overhead then ask us as we already GraphHopper files regularly for world wide coverage. Site notes:

  • In Germany there is at least one provider where you get those three servers for under 250€ per months.
  • If you cannot effort 2*64GB servers you could have a look into the memory mapped settings but this is slower – maybe not that slow via SSD, not yet deeply benchmarked.
  • If you don’t need the speed up, e.g. if your routes are rather small or you want a personalizable request then you ‘only’ need 2*12GB of RAM. Or less for the memory mapped case, which could even make it suitable for world wide routing on your 64bit Desktop! (Okay, still you need the geocoding and tiles, but that is for another blog post ;))

World Wide Download

On the preparation server download the OpenStreetMap data for the whole world e.g. from here. Then do

 ln -s planet-latest.pbf planet-car.pbf
 ln -s planet-latest.pbf planet-bike.pbf
 ln -s planet-latest.pbf planet-foot.pbf

Import and Prepare

Still on the preparation server import and prepare the GraphHopper folders for car

 export GH_WEB_OPTS="-Dgraphhopper.osmreader.acceptWay=CAR"
 export JAVA_OPTS="-XX:PermSize=100m -XX:MaxPermSize=100m -Xmx28000m -Xms28000m"
 ./ import planet-car.pbf

Do the same for bike and foot . This process takes 1h for the import and 2 to 5h for the preparation – depending on the vehicle.

3. Move to Leaflet and GraphHopper

Finally your client code needs to move away from Google Maps. Have a look into this description how to handle leaflet in general and into our own code how to handle the routing. Vote +1 for this issue to avoid this work :). Additionally to JavaScript we also provide a pure Java API useful for in-app communication.


Although GraphHopper is not yet feature complete it can already offer a production ready road routing service which is also easy to set up. Furthermore GraphHopper won’t take high administration costs as it is already very robust and used under high load in some companies for several months. Last but not least GraphHopper is easy to customize and can satisfy a wide range of different business needs.

Releasing GraphHopper 0.2 – Further & Faster Road Routing!

Today we’re releasing version 0.2 of our Open Source road routing engine GraphHopper written in 100% Java.


  • All algorithms are faster due to bug fixes and fine tuning
  • A preparation is necessary for our optional speed-up technique called Contraction Hierarchy. This preparation is also faster.


  • We finally fixed GPS-exact routing so you don’t have to workaround a junction-to-junction results

More exciting news will follow …

Have fun and try GraphHopper Maps with world wide coverage for pedestrians, cars and bicycles! You need support? Have a look at our enterprise options!


Free the Java Duke now and use it in Blender!

Duke, the Java mascot is a well known ambassador for Java. It is so important even Oracle still has a prominent site for it. The only problem is that the original source files can only be opened with a commercial application called lightwave3d.

For GraphHopper I took those files and created an OpenStreetMap variant with lightwave3d:


But I wondered why there is no possibility to use the files in Blender. Actually there is a plugin for Blender from Remigiusz to import the DXF files, but at the beginning it did not work for those none-standard files. So I contacted Remigiusz and the story begins. He not only improved his importer to make it working, but he invested hours to make a really nice Blender version for the Java Duke files!

Have a look:


The files are at Github! Thanks a lot again to Remigiusz!

Setup Mapnik From Scratch

THIS document is a work in progress.

There are several options but mainly three web map servers (WMS): Mapnik, GeoServer and MapServer. Simple visualization:

 A) browser/client (leaflet, openlayers)
 B) tile server (mod_tile, tile cache, tile stache, mapproxy, geowebcache)
 C) map web service = WMS (MapServer, GeoServer, Mapnik)
 D) Data storage (PostgreSQL, vector tiles)
 E) OSM data (xml, pbf)


  • for C => Mapnik can use TileMill to style to map
  • leaflet can do tile layers (B) but also WMS (C)
  • Nearly always you need PostgreSQL, but in rare cases you can avoid it via vector tiles.
  • A common approach is to use apache2 with mod_tile. Serving the tiles from disc or creating the image via mapnik through renderd. But also nginx gets more popular. Tiledrawer has an old scripts also with mapnik and nginx.
  • You can also use GeoServer with a cache in front. Often it only serves some feature layers.
  • WFS = web feature service
  • MWS = map web service

Installation of PostgreSQL, Mapnik, mod_tile, renderd


First of all you need the OSM data in a PostgreSQL database via osm2psql import – an easy description is here. For a faster import you can try imposm instead of the more common osm2psql.

Install the Rest

Although nginx would be preferred I did not find a out of the box working solution for it. So you need to use apache2 and mod_tile: a simple installation. Also there is an older article which I did not try. There is also a good presentation with some useful information.

 sudo apt-get install python-software-properties
 sudo add-apt-repository ppa:kakrueger/openstreetmap
 sudo apt-get update
 # now install mod_tile and renderd with the default style
 sudo apt-get install libapache2-mod-tile
 sudo -u postgres osm2pgsql --slim -C 1500 --number-processes 4 /tmp/europe_germany_berlin.pbf
 sudo touch /var/lib/mod_tile/planet-import-complete
 sudo /etc/init.d/renderd restart
 # optionally pre-generate some tiles for faster rendering - see "How do I pre-render tiles ?"
 # difference to and
 go to http://localhost/osm/slippymap.html
# to install mapnik-config do:
 sudo apt-get install libmapnik2-dev

Custom Styles

Here you can find newer style is constructed via CartoCSS
install carto either via just using TileMill or do

sudo apt-get install npm
sudo npm install -g carto

TODO Get mapbox osm-bright working. This new style requires a specific version XY of mapnik which wasn’t found in my ubuntu version!?

edit config name and path in
# backup /etc/mapnik-osm-data/osm.xml before doing:
carto osm-bright/YourProject/project.mml > /etc/mapnik-osm-data/osm.xml
# the osm.xml is used from mod_tile which uses renderd /etc/renderd.conf
# mod_tile config is at: /etc/apache2/sites-available/tileserver_site
# The tiles are here: /var/lib/mod_tile/default/

TODO To update the style you can try

 sudo -u www-data touch /var/lib/mod_tile/planet-import-complete
 # important: do not delete 'default' itself
 sudo rm -R /var/lib/mod_tile/default/
 # how to restart renderd properly?
 sudo service renderd restart



For mapnik installation you’ll also need a web server like nginx or apache2. For nginx you can have a look into the script available here (clone the git repo):

Additionally you’ll need mod_tile and renderd or TileStache if you use nginx. To style the maps you can use TileMill.


Installation is a lot easier compared to Mapnik or MapServer. Only dependency is Java. Just grab the full zip of geo server and copy the war from web cache into webapps, then run ./bin/

If you need mapbox tilemile styles for geoserver have a look into:


Problems with nvidia driver 173 and kernel 3.2.0-52. Two monitors and card Quadro NVS 160M

After the recent kernel upgrade my old nvidia driver failed to load and X loads with a very low resolution and without detecting my second monitor. For my graphic card the nouveau driver is not an option. But I managed to fix the problems via removing current nvidia and nvidia-173. But probably you can just skip those commands and use the jockey-gtk as explained below.

sudo apt-get purge nvidia-current
sudo apt-get remove nvidia-173
sudo apt-get install –reinstall nvidia-173-updates
# now REBOOT!

Now it boots as normal with my second monitor but the nice configuration tool called ‘nvidia-settings’ did not work and says ‘The NVIDIA X driver on is not new enough to support the nvidia-settings Display Configuration page.’

Also my firefox 23 had performance problems for canvas rendering. I solved this via opening “about:config” and set layers.acceleration.force-enabled to true. I found this in the comments of this article.

Update: I was able to fix the all the issues just by switching to ‘(additional updates) (version 319-updates)’ when starting the tool called ‘jockey-gtk’! Afterwards also the tool xfce4-display-settings showed two monitors.

Java on iPhone or iPad

What options do I have to make my Java application working on the iPhone? It should not be necessary to jailbreak the phone. Also UI is not necessary for now although e.g. codenameone seems to support it. My application it not a complicated one, but uses Java 1.5 (generics etc) and e.g. memory mapped files. The good thing would be if the JUnit tests could be transformed too with the tool to check functionality.What I found is

Or somehow use the embedded JVM for ARM directly? Do you have experiences with this or more suggestions?

GraphHopper Maps 0.1 – High Performance and Customizable Routing in Java

Today we’re proud to announce the first stable release of GraphHopper! After over a year of busy development we finally reached version 0.1!

GraphHopper is a fast and Open Source road routing engine written in Java based on OpenStreetMap data. It handles the full planet on a 15GB server but is also scales down and can be embedded into your application! This means you’re able to run Germany-wide queries on Android with only 32MB in a few seconds. You can download the Android offline routing demo or have a look at our web instance which has world wide coverage for car, bike and pedestrian:

GraphHopper Java Routing

The trip to the current state of GraphHopper was rather stony as we had to start from scratch as there is currently no fast Java-based routing engine. What we’ve built is quite interesting as it shows that a Java application can be as fast as Bing or Google Maps (in 2011) and beats YOURS, MapQuest and Cloudmade according to the results outlined in a Blog post from Pascal and with tests against GraphHopper – although OSRM is still ahead. But how can a Java application be so fast? One important side is the used algorithm: Contraction Hierarchies – a ‘simple’ shortcutting technique to speed up especially lengthy queries. But even without this algorithm GraphHopper is fast which is a result of weeks of tuning for less memory consumption (yes, memory has something to do with speed), profiling and tweaking. But not only the routing is fast and memory efficient also the import process. And it should be easy to get started and modify GraphHopper to your needs.

Why would you use GraphHopper?

GraphHopper could be especially useful for more complicated or custom shortest/best path projects. E.g. if you need

  • to embed GraphHopper or only parts of it directly within your Java application, which is easily possible due to the Apache 2 license.
  • offline queries for your Android application
  • highly customized routing (like horse routing – see below) where Google/Bing API calls aren’t sufficient or even possible
  • many to many queries
  • the shortest path tree(s) directly

… you should tell us on the mailing list what you need!


GraphHopper is a young project but it makes great strides and it is already used in GPSies and in more places (cannot disclose all yet).

Last but not least I would like to thank NopMap for his work regarding OSM import and tuning, elevation data and much more! You can try out his horse routing prototype based on GraphHopper at the German (“trail riding map”)!

See the description on how you can contribute.

Have fun!