I have, for example, three edges in my dummy graph:
A to B (both directions)
B to C (only forward)
C to D (only backward).
Now i want to change the direction of some edges dynamically, e.g. force edge (B to C) to navigate backward and prohibit forward navigation.
How can i do this? Where should i extend graphhopper to accomplish this task?
I have implemented a custom weighting class, but currently i cannot determine the direction how my edge is traversed.
In calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId):
If (B to C) is traversed from B to C i want return a bad weight.
If (B to C) is traversed from C to B i want return a good weight.
Any ideas?
(I do not want to recalculate the routing cache and i use CH and No-CH).
Sorry, this is incorrect it should be better like:
edgeExplorer = graph.createEdgeExplorer(edgeFilter);
edgeIterator = edgeExplorer.setBaseNode(node);
while(edgeIterator.next()) {
// now the edgeIterator has a certain 'state', i.e use as EdgeIteratorState
edgeIterator.getXY
// to put an edgeIteratorState into a list for later usage you need to 'remember' the current state and detach it from the iterator via:
edgeIteratorState = edgeIterator.detach(false);
list.add(edgeIteratorState);
// detach is usually a rather costly operation and should be done only if necessary
}