Skip to content

Instantly share code, notes, and snippets.

@quintona
Last active December 16, 2015 05:39
Show Gist options
  • Save quintona/5385839 to your computer and use it in GitHub Desktop.
Save quintona/5385839 to your computer and use it in GitHub Desktop.
Issue getting started with graphhopper
@Test
public void test() {
Date start = new Date();
//GraphHopper gh = new GraphHopper().forServer(); //<- this works, line below doesn't
GraphHopper gh = new GraphHopper().forServer().contractionHierarchies(true);
gh.load("./london.osm");
Date end = new Date();
System.out.println("Load Time: " + (end.getTime() - start.getTime()));
GHRequest request = new GHRequest(51.430896,0.115356,
51.564266,-0.219727);
//request.algorithm("dijkstraNative");
start = new Date();
GHResponse response = gh.route(request);
end = new Date();
System.out.println("Route Time: " + (end.getTime() - start.getTime()));
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