Skip to content

Commit

Permalink
ignore invalid only_* restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Sep 1, 2016
1 parent 8b144f2 commit 6fac14d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Reduced semantic of merge to refer only to merges from a lane onto a motorway-like road
- Bugfixes
- Fixed an issue that would result in segfaults for viaroutes with an invalid intermediate segment when u-turns were allowed at the via-location
- Invalid only_* restrictions could result in loss of connectivity. As a fallback, we assume all turns allowed when the restriction is not valid

# 5.3.0
Changes from 5.3.0-rc.3
Expand Down
24 changes: 20 additions & 4 deletions features/car/restrictions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,27 @@ Feature: Car - Turn restrictions
| type | way:from | way:to | node:via | restriction |
| restriction | sj | wj | j | only_left_turn |

Scenario: Car - Only right turn, invalid
Given the node map
| | n | | |
| w | j | e | r |
| | s | | |

And the ways
| nodes | oneway |
| sj | yes |
| nj | -1 |
| wj | -1 |
| ej | -1 |
| re | -1 |

And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | sj | er | j | only_right_on |

When I route I should get
| from | to | route |
| s | w | sj,wj,wj |
| s | n | |
| s | e | |
| from | to | route |
| s | r | sj,ej,re,re |

@only_turning
Scenario: Car - Only right turn
Expand Down
17 changes: 15 additions & 2 deletions src/extractor/guidance/intersection_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,21 @@ Intersection IntersectionGenerator::GetConnectedRoads(const NodeID from_node,
{
Intersection intersection;
const NodeID turn_node = node_based_graph.GetTarget(via_eid);
const NodeID only_restriction_to_node =
restriction_map.CheckForEmanatingIsOnlyTurn(from_node, turn_node);
const NodeID only_restriction_to_node = [&]() {
// If only restrictions refer to invalid ways somewhere far away, we rather ignore the
// restriction than to not route over the intersection at all.
const auto only_restriction_to_node =
restriction_map.CheckForEmanatingIsOnlyTurn(from_node, turn_node);
if (only_restriction_to_node != SPECIAL_NODEID)
{
// check if we can find an edge in the edge-rage
for (const auto onto_edge : node_based_graph.GetAdjacentEdgeRange(turn_node))
if (only_restriction_to_node == node_based_graph.GetTarget(onto_edge))
return only_restriction_to_node;
}
// Ignore broken only restrictions.
return SPECIAL_NODEID;
}();
const bool is_barrier_node = barrier_nodes.find(turn_node) != barrier_nodes.end();

bool has_uturn_edge = false;
Expand Down
8 changes: 3 additions & 5 deletions src/extractor/restriction_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ bool RestrictionMap::CheckIfTurnIsRestricted(const NodeID node_u,
{
return true;
}
if (node_w != restriction_target.target_node && // target not found
restriction_target.is_only) // and is an only restriction
{
return true;
}
// We could be tempted to check for `only` restrictions here as well. However, that check is
// actually perfomed in intersection generation where we can also verify if the only
// restriction is valid at all.
}
return false;
}
Expand Down

0 comments on commit 6fac14d

Please sign in to comment.