GraphHopper: a fast and flexible open source trip planner

No readers like this yet.
Several houses

Opensource.com

Route planning is an essential part of the connected and mobile world. Many people use commercial solutions on a daily basis to avoid traffic jams when heading home or when they plan their next business or outdoor trip. It is also a crucial part in many business areas like for garbage collection, pizza delivery, or ride sharing where speed is important to calculate thousands or even millions of high quality routes within a short time.

The team behind GraphHopper is building a fast and open source alternative to existing solutions. It is licensed under the permissive Apache License 2.0 and available on GitHub. We provide a world-wide instance for car routing, biking, and walking called GraphHopper Maps. With it, you can see the routing engine GraphHopper in action, combined with map tiles served from Mapnik and the address search coming from Photon. It's all open source and has high privacy standards due to using own servers.

GraphHopper supports two different modes: the flexibility mode and the speed-up mode. With the flexibility mode, you have full control to customize a route search for every user to its personal preferences. With the speed-up mode, you can pre-create route profiles for a car and provide extraordinary speed, e.g. from Los Angeles to New York City in under 50 milliseconds.

If you host GraphHopper on your own servers, you can avoid the network latency compared to external services, making GraphHopper faster than any commercial routing engine even on commodity hardware and for routes of continental length. GraphHopper works on all major platforms such as Linux, Windows, Mac, Raspberry Pi, Android, and iOS. It can even work offline in the browser with the help of TeaVM, a Java virtual machine for the browser. This will make hybrid routing solutions possible, being created from the identical source code basis.

The setup of the routing server is simple, fast, and only requires Java. The HTTP API can then be consumed easily from any programming language, where we provide implementations for Java and JavaScript. You can also integrate GraphHopper directly into your Java projects or customize it to your needs like using your own data for traffic jams or speed limits. GraphHopper is tuned towards low memory usage but still the Java API is easy to use. For example, the following Java snippet will import OpenStreetMap data for Berlin and fire up a first route query there:

public static void main( String[] args ) {
 GraphHopper hopper = new GraphHopper().init(CmdArgs.read(args));
 hopper.setOSMFile("berlin.pbf");
 hopper.setGraphHopperLocation("berlin-gh");
 hopper.importOrLoad();
 hopper.route(new GHRequest(
     52.524786, 13.401604,
     52.503266, 13.358688));
 hopper.close();
}

This is a demonstration of a typical point-to-point routing, other uses are:

  • traffic simulation
  • indoor routing
  • multimodal routing
  • urban planning
  • calculating distance matrices for the logistic sector
  • and many more!

Despite the fact that it is still a young project, 0.3 was released in May 2014 and there are already users like Gnome Maps, GPSies.com, Rome2rio.com, and Komoot.de. GraphHopper can especially shine due to the rich and open data from OpenStreetMap and NASA for elevation data.

An active community is available via our mailing list—please ask your questions and join the discussion! We are also on Twitter.

User profile image.
Peter Karich is the creator of the fast and open source route planner GraphHopper. He worked at various companies involving complex algorithms and tool chains. For example he improved speech assistants and enterprise search via e.g. ElasticSearch. From time to time he writes about GraphHopper and Java at his blog called karussell. Follow him on Twitter @timetabling

Comments are closed.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.