Hi @all,
i want to weight an OSM way with a custom weighting factor. For example:
- ‘highway:trunk’ --> good (factor 1)
- ‘highway:residential’ --> bad (factor 5)
In other words: I prefer a routing over trunks.
How can i do that with graphhopper?
Where can i inject my code (CustomWeighting) or extend which classes? Can i, and how, encode this by a flag of an edge?
I use both modes: CH and none CH.
My first draft was to save for each edge a custom factor and apply this factor in my weighting-class:
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
double weight = original.calcWeight(edgeState, reverse, prevOrNextEdgeId);
int factor = osmDataProvider.getOSMWayFactor(edgeState.getEdge());
return weight * factor;
}
However, it’s not a good practice to map an ID to a factor. In addition: There are incoming edge IDs which are unknown by my osm-data-provider. (The osm-data-provider saves in a preprocessing step for each edge ID a factor.)
Is there a better way to achieve a custom edge weighting depended by some OSM-tags?
Does graphhopper supports this weighting mechanism for “highway” out of the box?
Best regards,
Olli.