GraphHopper.com | Forum | GitHub | Maps | Blog

Custom Weighting - Flat Fees/Vignettes


#1

Hi there,

Just wondering if GH can support the concept of vignettes/flat fees when the vehicle crosses a particular border, most likely a country border. A quick forum search did not help…

Does anyone have any idea as to how it can be implemented by creating a custom Weighting class?

Any help is appreciated! :slight_smile:

Vignette

Swiss and Austrian motorways don’t have tolls but these are just two of the countries that require motorists to purchase a vignette, a pre-paid sticker that you affix to your car windscreen. The vignette acts as proof that you have paid the toll-road fee. ©

Cheers,
Craig


#2

It should be relative simple to tell GH to completely avoid these toll areas or to do toll cost calculation on the client side (using path details).

You would mark those border edges to e.g. vignette=true and then also set all edges inside the country to vignette=true using e.g. the BFS algorithm. To determine the edges on the border you could use the same approach we use here.

The problem would be to find the route with the smallest toll costs ie. minimizing for toll costs. The problem is that these toll costs are stateful: once you paid you can enter without paying more. Let’s say you travel with a car from Germany to Italy and you allow tolls but want to reduce them then we must add the toll costs at the first border edge only and ignore additional costs within Switzerland. I think for this approach you would have to handle toll costs like currently only weight is handled and store it per node in the ShortestPathTree (for public transit routing we already store more in the SPT like time, transfers,…). Only with this approach Dijkstra would automatically determine the best path using a custom Weighting.


#3

Peter,

Thank you for the reply!

Firstly, I assume you are implying STP = SPTEntry.java

Could you point to the right direction if I were to check how the below is done code wise? Is it just a bunch of new fields in the same class?
for public transit routing we already store more in the SPT like time, transfers,…

Am I right in saying that the new toll cost will need to be introduced so that newWeight would depend upon the toll cost as well as entryCurrent.weight + entryOther.weight?

protected void updateBestPath(EdgeIteratorState edgeState, SPTEntry entryCurrent, int traversalId)

// update μ
double newWeight = entryCurrent.weight + entryOther.weight;

Ta


#4

Sorry, SPT means shortest path tree and yes, you would store this new information per node, so SPTEntry is the correct place.

Could you point to the right direction if I were to check how the below is done code wise? Is it just a bunch of new fields in the same class?

Have not done it before so I don’t know how much work it is. You could create an issue to make this easier and possible via a config change or something.


#5

Thank you.

Will have a look into it.