Hello,
I’m using GraphHopper in my project to generate routes, approximate mileage and trip durations. While the mileage calculations seem accurate, the trip durations are consistently too short, which is a problem for my use case.
I’ve compared the results to the GraphHopper online web app, and the durations there are much more realistic. The web app doesn’t use traffic data (which isn’t supported in my country), so I suspect the issue lies within my custom model or configuration.
Here’s my profile:
private Profile getCarProfile() {
final var profile = new Profile(CAR_PROFILE);
final var customModel = new CustomModel();
customModel.setDistanceInfluence(10.0);
customModel.addToPriority(Statement.If("!car_access", Statement.Op.MULTIPLY, "0"));
customModel.addToSpeed(Statement.If("true", Statement.Op.LIMIT, "car_average_speed"));
profile.setTurnCostsConfig(TurnCostsConfig.car());
profile.setCustomModel(customModel);
return profile;
}
And the route function:
GHResponse getResponse(List<MapCoordinatesDto> waypoints) {
final var points = waypoints.stream()
.map((i) -> new GHPoint(i.latitude(), i.longitude()))
.toList();
final var request = new GHRequest(points);
request.setProfile(CAR_PROFILE);
request.putHint("instructions", false);
request.putHint("calcPoints", false);
return graphHopper.route(request);
}
Question:
- Is there a configuration issue in my custom model that could lead to shorter trip durations?
- How can I adjust the model or profile to ensure realistic duration calculations?
Any insights or suggestions would be greatly appreciated!