Optimize routing question

Hi, everybody!

I want to use graphhopper in my project. I really like the project, thank you for developing it.

I want to run my own graphhopper server and use it via c# client (https://github.com/graphhopper/directions-api-clients), I am developing in c # and unfortunately i can’t develop in java.

I have very big accumulated gps data of movements of our trucks, I want to use it to build optimal routes.
We build many routes to different regions of our country and cover long distances.
Experienced drivers know which roads are better to drive, and which roads to bypass. We accumulate gps movements of experienced drivers. But there are many inexperienced logisticians and drivers who do not know about the best routes. We want them to be able to build an optimal route taking into account the experience of the trodden roads.

Basically, we have a problem with bypass roads where a truck drives from city A to B and on the way passes through different cities. The routers often builds a route through the city because it is so closer the distance. But in fact it is easier to drive through the bypass roads without going into the city, it will be better that way.

The big truck profile does not solve the problem, because not all roads on the map are marked as highways and not all highways are comfortable to travel.
The peculiarity of our Russian roads is such that even if the road is marked as a highway on the map, it can be bad for driving, and experienced drivers know which roads are in good condition and which are not, which roads are wide and comfortable.

Based on the accumulated gps coordinates of the optimal roads, we want to patch the osm map file, so that later when building routes, the router can take into account these optimal roads. So that when building routes, preference is given to those roads that we have already trodden earlier.

Could you tell me is it possible to implement this with graphhopper ?

Also, we want to take into account toll and free roads, is this possible?

I will be glad to receive any of your tips.

Yes this is certainly possible. If you add OSM tags to all the roads you want to consider ‘optimal’ (in your patched OSM file, not on osm.org of course) you can then create an EncodedValue that stores whether or not a given road is optimal or not. For example take a look at one of the TagParser implementations like OSMSurfaceParser to see how this is done. A quick workaround to do a proof of concept could also be simply adding another value optimal to one of the existing ones, e.g. surface=optimal. Finally you can use this EncodedValue in CustomWeighting to adjust the priority or speed for this road such that it will be preferred by the routing engine, take a look at the profiles.md documentation to learn about custom weighting.

1 Like

Thank you very much for the hint, I am very glad that this can implement using profiles (without inheriting code)!

Also note that the custom weighting language is being reworked currently to become more powerful. This will be part of the 3.0 release (and you can test it in current master already, but this is still subject to potential change).

great! more good news :rocket:

I want to generate client for c# using https://editor.swagger.io/?url=https://docs.graphhopper.com/openapi.json
Where can I get (or generate) openapi.json for master branch?

can anyone come in handy, use openapi.yaml: https://editor.swagger.io/?url=https://raw.githubusercontent.com/graphhopper/directions-api-doc/master/spec/openapi.yaml

Yes, this is the correct openapi spec and repository.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.