Hi everyone.
In my case, I have a route from [21.003024,105.799557] to [21.002787,105.80142].
Why my route is like that althought have 2 restriction ?
How to fix it ?
Hi everyone.
In my case, I have a route from [21.003024,105.799557] to [21.002787,105.80142].
Why my route is like that althought have 2 restriction ?
How to fix it ?
This is strange indeed. I’ll look into this.
I try to log and found : when call api /route,
calcTurnWeight: inEdge=5491163, viaNode=3191890, outEdge=5491165
But when import, restriction set in RestrictionSetter inEdge=5738550,viaNode=3191890, outEdge=5491165
I’m not sure, but I think get via edge is wrong**
int viaEdge = GHUtility.getEdgeFromEdgeKey(viaEdgeKey);
**.
I changed to
int inEdge = restriction.getEdgeKeys().get(restriction.getEdgeKeys().size() - 2);
EdgeIteratorState temp = baseGraph.getEdgeIteratorStateForKey(inEdge);
int viaEdge = temp.getEdge();
And it’s work.
@easbar Please, Confirm if my solutions is true . Thanks
No, you simply changed restriction.getActualEdgeKeys()
to restriction.getEdgeKeys()
, but here we need to consider artificial edges that are needed to implement via-edge restrictions.
I think there is a data error here: This no_left_turn relation is probably meant to deny the left turn from Nguyen Tuan Road onto Le Van Luong Road. But as it stands it has the following members:
which means that it is forbidden to continue from C to D if coming from A-B. But this means it is still legal to turn from B onto C (even when coming from A-B). So the first left turn is not forbidden (even though it probably was meant to be). The route then does another left turn (because going A-B-C-D is actually forbidden). It then does two more left turns and finally goes straight to D, which is also allowed because the C-D turn is only forbidden when coming from A-B directly. Your problem might already be fixed if the via-way restriction was turned into a simple via-node restriction (if appropriate at this junction).
But what really does look like an error in GraphHopper to me is that the second (fourth) left turn violates this (and this) no-u-turn relation. I created this issue for this.