[GraphHopper] GH 0.1 -> 0.1.1 code update
Ondřej Hubáček
ondrej.hubacek at gmail.com
Sat Oct 5 08:42:10 UTC 2013
Hello!
I would like to use GH for measuring distance in my offline desktop app.
Long time ago I used some 0.1 snaphot and wrote this little piece of code:
double fromLat = 50.216493, fromLon = 15.814353, toLat =
50.105043, toLon = 14.389708;
GraphHopperAPI gh = new GraphHopper().setInMemory(true, true);
gh.load("C:\\OSM\\streets.osm");
GHRequest request = new GHRequest(fromLat,fromLon,toLat,toLon);
request.algorithm("astar");
GHResponse response = gh.route(request);
System.out.println("Distance: " + response.distance());
And it worked! But now i would like to use snaphot 0.1.1
(https://oss.sonatype.org/content/groups/public/com/graphhopper/graphhopper-parent/).
I reworked the code like this:
double fromLat = 50.216493, fromLon = 15.814353, toLat =
50.105043, toLon = 14.389708;
GraphHopper gh = new
GraphHopper().forDesktop().setInMemory(true, true);
gh.setOSMFile("C:\\OSM\\streets.osm");
gh.load("C:\\OSM\\");
EncodingManager ecn = new EncodingManager("CAR");
gh.setEncodingManager(ecn);
GHRequest request = new GHRequest(fromLat,fromLon,toLat,toLon);
GHResponse response = gh.route(request);
System.out.println("Distance: " + response.getDistance());
I guess it´s awfully wrong, because it´s not working (I am getting null
pointer ex in gh.route()). Can you help me fix this please?
Andy
More information about the GraphHopper
mailing list