| Forum | GitHub | Maps | Blog

Custom weighting


I am interested in using graphhopper to generate driving directions between locations. I would like to influence the way in which graphhopper determines the best route by using custom variables, for example I may want to calculate the safest route (as opposed to the fastest or shortest).

Is the best way to achieve this by creating my own custom Weighting class? Looking at the method signature of the calcWeight method it’s not clear to me how the arguments to that methods would help me. For example, lets say I want a calcWeight method to lookup a “safety rating” for that road/edge, it’s not clear to me how I can identify the road from those arguments.

It also not clear to me what the role of the “encoder” is and what information is stored in and can be retrieved from a graph.

Any help would be much appreciated.