Skip to content

Instantly share code, notes, and snippets.

@quintona
Created April 15, 2013 06:14
Show Gist options
  • Save quintona/e5208c7b68aced6f19e6 to your computer and use it in GitHub Desktop.
Save quintona/e5208c7b68aced6f19e6 to your computer and use it in GitHub Desktop.
Updated Gist after I got the contraction hierarchies working
public class TestGH {
@Test
public void test() {
GraphHopper gh = new GraphHopper().forServer().contractionHierarchies(true);
gh.load("./london.osm");
GHRequest request = new GHRequest(51.559997,-0.226593,
51.448016,0.063171);
request.algorithm("dijkstrabi");
StopWatch sw = new StopWatch().start();
GHResponse response = gh.route(request);
System.out.println("Route Time: " + sw.stop().getSeconds());
System.out.println(response.distance() + " " + response.time());
PointList points = response.points();
for (int i = 0; i < points.size(); i++) {
System.out.println(points.latitude(i) + " : " + points.longitude(i));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment