GraphHopper.com | Forum | GitHub | Maps | Blog

Inconsistency Problem while Calling the Same Route Request from GH Web and Java


#1

I have implemented a new flagEncoder for ski lift.
When I use call a route request from the web, I get the correct response as I expect. But when I call a route request from java code, I am not getting the correct output, even it has the same parameters which I pass from the web.

Here are the details:

Getting route from web:

http://localhost:8990/route?point=45.110589%2C5.877138&point=45.113951%2C5.886859&locale=en-US&vehicle=ski_lift&weighting=fastest&points_encoded=false

Output:

> {"hints":{"visited_nodes.average":"4.0","visited_nodes.sum":"4"},"paths":[{"instructions":[{"distance":849.508,"sign":0,"interval":[0,1],"text":"Continue onto TSD de la Bérangère","time":203881,"street_name":"TSD de la Bérangère"},{"distance":0.0,"sign":4,"interval":[1,1],"text":"Arrive at destination","time":0,"street_name":""}],"descend":0.0,"ascend":0.0,"distance":849.508,"bbox":[5.877149,45.110573,5.886864,45.113944],"weight":203.881983,"points_encoded":false,"points":{"coordinates":[[5.877149,45.110573],[5.886864,45.113944]],"type":"LineString"},"transfers":0,"legs":[],"details":{},"time":203881,"snapped_waypoints":{"coordinates":[[5.877149,45.110573],[5.886864,45.113944]],"type":"LineString"}}],"info":{"took":3,"copyrights":["GraphHopper","OpenStreetMap contributors"]}}

But when I call from java:

GraphHopper hopper = new GraphHopperOSM().forServer();

hopper.setDataReaderFile(osmFilePath);
hopper.setGraphHopperLocation(graphFolderPath);
hopper.setEncodingManager(new EncodingManager(“ski_lift”));
hopper.importOrLoad();

GHRequest req = new GHRequest(45.110589, 5.877138, 45.113951, 5.886859).
setWeighting(“fastest”).
setVehicle(“ski_lift”).
setLocale(Locale.US);

GHResponse rsp = hopper.route(req);

I get the following response:

path = (PathWrapper) nodes:1; (45.120123478474994,5.8915987065046735), [(4,0.0,0)]
pointList = (45.120123478474994,5.8915987065046735)
distance = 0.0
timeInMs = 0

I don’t know why is this weird behaviour from Java call.
Am I doing anything wrong or missing anything? To me, both calls look exactly the same.

Best Regards,
Yasir