Using custom weighting in GraphHopper 3.0

Hi all,
I have some doubts regarding using custom weighting in graphhopper.
What I wish is to add a new weighting class that uses traffic(following
Integerating Traffic data in Graphhopper 3.0) and air pollution data (added as new encoded value of edge) of the edges to compute optimal route. However I am finding it difficult to understand how to integrate custom weighting with profiles.

I tried extending GraphHopper and overriding the createweighting method as is mentioned in graphhopper/weighting.md at master · graphhopper/graphhopper · GitHub
but that is raising the error that final methods cannot be overriden.

The graphhopper 3.0 version has final methods of createweighting, so how to go about assigning custom weighting to profiles?
-Thank you

I think the docs are out of date there (I’ll submit a PR with some changes).

You need to override GraphHopper.createWeightingFactory(). Then you’ll need to implement WeightingFactory, and inside that class you’ll get to implement createWeighting().

1 Like

Thank you! It worked :smiley:

Powered by Discourse