Good Day everyone,
I wished to know what are the steps to integrate traffic data from external sources in Graphhopper 3.0. I had tried to replicate the steps given in GitHub - karussell/graphhopper-traffic-data-integration: [not maintained] Traffic data integration example for GraphHopper in my application but even though the edges are showing changed value of speed, the route is not changing based on the new edge weights. Here’s what my code looks like:
My config.properties file:
graph.flag_encoders=car
graph.dataaccess=RAM_STORE
profiles_ch=no
My graphhopper initialization code:
GraphHopperConfig args=new GraphHopperConfig();
gh=new GraphHopper();
Properties prop=new Properties();
FileInputStream ip;
try {
ip = new FileInputStream(“config.properties”);
prop.load(ip);
args.putObject(“datareader.file”,MAP_URL);
args.putObject(“profiles_ch”,prop.getProperty(“profiles_ch”));
List profiles = new ArrayList<>();
profiles.add(new Profile(“car”).setVehicle(“car”).setWeighting(“fastest”));
args.setProfiles(profiles);
args.putObject(“graph.flag_encoders”,prop.getProperty(“graph.flag_encoders”));
args.putObject(“graph.dataaccess”, prop.getProperty(“graph.dataaccess”));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
gh.init(args).setOSMFile(MAP_URL).setGraphHopperLocation(“graphLocation”);
gh.clean();
gh.importOrLoad();
And my routing code:
GHRequest request=new GHRequest(p.getStartlat(),p.getStartlon(),p.getEndlat(),p.getEndlon()).setProfile(“car”);
try
{
GHResponse fullRes = gh.route(request);
if (fullRes.hasErrors())
throw new RuntimeException(fullRes.getErrors().toString());
ResponsePath res = fullRes.getBest();
PointList pl = res.getPoints();
System.out.println(pl);
return pl;
}
finally
{
readLock.unlock();
}
Here’s where I had changed the speed value based on traffic and the console output shows it has been changed:
However, the routing is not happening based on these new edge weights. It is remaining the same, no matter what edge speed value I change to. Am i missing something? How can we integrate traffic in Graphhopper 3.0?
Thanks and regards.