Skip to content

Commit

Permalink
restructured to only return valid turns to the outside + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Moritz Kobitzsch committed Mar 18, 2016
1 parent 049f9ba commit 7cce748
Show file tree
Hide file tree
Showing 8 changed files with 1,294 additions and 1,163 deletions.
202 changes: 202 additions & 0 deletions features/guidance/motorway.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
@routing @guidance
Feature: Basic Roundabout

Background:
Given the profile "testbot"
Given a grid size of 10 meters

Scenario: Ramp Exit Right
Given the node map
| a | b | c | d | e |
| | | | f | g |

And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |

Scenario: Ramp Exit Right Curved Right
Given the node map
| a | b | c | | |
| | | f | d | |
| | | | g | e |

And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-right, arrive |

Scenario: Ramp Exit Right Curved Left
Given the node map
| | | | | e |
| | | | d | g |
| a | b | c | f | |


And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, cfg, cfg | depart, ramp-slight-right, arrive |


Scenario: Ramp Exit Left
Given the node map
| | | | f | g |
| a | b | c | d | e |

And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |

Scenario: Ramp Exit Left Curved Left
Given the node map
| | | | g | e |
| | | f | d | |
| a | b | c | | |

And the ways
| nodes | highway |
| abcde | motorway |
| bfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, bfg, bfg | depart, ramp-slight-left, arrive |

Scenario: Ramp Exit Left Curved Right
Given the node map
| a | b | c | f | |
| | | | d | g |
| | | | | e |

And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| a,g | abcde, cfg, cfg | depart, ramp-slight-left, arrive |

Scenario: On Ramp Right
Given the node map
| a | b | c | d | e |
| f | g | | | |

And the ways
| nodes | highway |
| abcde | motorway |
| fgd | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | abcde, fgd, fgd | depart, merge-slight-left, arrive |

Scenario: On Ramp Left
Given the node map
| f | g | | | |
| a | b | c | d | e |

And the ways
| nodes | highway |
| abcde | motorway |
| fgd | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | abcde, fgd, fgd | depart, merge-slight-right, arrive |

Scenario: Highway Fork
Given the node map
| | | | | d | e |
| a | b | c | | | |
| | | | | f | g |

And the ways
| nodes | highway |
| abcde | motorway |
| cfg | motorway |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde, abcde | depart, fork-left, arrive |
| a,g | abcde, cfg, cfg | depart, fork-right, arrive |

Scenario: Fork After Ramp
Given the node map
| | | | | d | e |
| a | b | c | | | |
| | | | | f | g |

And the ways
| nodes | highway |
| abc | motorway_link |
| cde | motorway |
| cfg | motorway |

When I route I should get
| waypoints | route | turns |
| a,e | abc, cde, cde | depart, fork-left, arrive |
| a,g | abc, cfg, cfg | depart, fork-right, arrive |

Scenario: On And Off Ramp Right
Given the node map
| a | b | | c | | d | e |
| f | g | | | | h | i |

And the ways
| nodes | highway |
| abcde | motorway |
| fgc | motorway_link |
| chi | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | fgc, abcde, abcde | depart, merge-slight-left, arrive |
| a,i | abcde, chi, chi | depart, ramp-slight-right, arrive |
| f,i | fgc, chi, chi | depart, turn-slight-right, arrive |

Scenario: On And Off Ramp Left
Given the node map
| f | g | | | | h | i |
| a | b | | c | | d | e |

And the ways
| nodes | highway |
| abcde | motorway |
| fgc | motorway_link |
| chi | motorway_link |

When I route I should get
| waypoints | route | turns |
| a,e | abcde, abcde | depart, arrive |
| f,e | fgc, abcde, abcde | depart, merge-slight-right, arrive |
| a,i | abcde, chi, chi | depart, ramp-slight-left, arrive |
| f,i | fgc, chi, chi | depart, turn-slight-left, arrive |

113 changes: 73 additions & 40 deletions features/guidance/roundabout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ Feature: Basic Roundabout

Scenario: Enter and Exit
Given the node map
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |

And the ways
| nodes | roundabout |
| ab | false |
| cd | false |
| ef | false |
| gh | false |
| bcegb | true |
| ab | no |
| cd | no |
| ef | no |
| gh | no |
| bcegb | yes |

When I route I should get
| waypoints | route | turns |
Expand All @@ -38,19 +38,19 @@ Feature: Basic Roundabout

Scenario: Only Enter
Given the node map
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |

And the ways
| nodes | roundabout |
| ab | false |
| cd | false |
| ef | false |
| gh | false |
| bcegb | true |
| ab | no |
| cd | no |
| ef | no |
| gh | no |
| bcegb | yes |

When I route I should get
| waypoints | route | turns |
Expand All @@ -73,19 +73,19 @@ Feature: Basic Roundabout

Scenario: Only Exit
Given the node map
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |

And the ways
| nodes | roundabout |
| ab | false |
| cd | false |
| ef | false |
| gh | false |
| bcegb | true |
| ab | no |
| cd | no |
| ef | no |
| gh | no |
| bcegb | yes |

When I route I should get
| waypoints | route | turns |
Expand All @@ -108,19 +108,19 @@ Feature: Basic Roundabout

Scenario: Drive Around
Given the node map
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |
| | | a | | |
| | | b | | |
| h | g | | c | d |
| | | e | | |
| | | f | | |

And the ways
| nodes | roundabout |
| ab | false |
| cd | false |
| ef | false |
| gh | false |
| bcegb | true |
| ab | no |
| cd | no |
| ef | no |
| gh | no |
| bcegb | yes |

When I route I should get
| waypoints | route | turns |
Expand All @@ -138,3 +138,36 @@ Feature: Basic Roundabout
| g,e | bcegb,bcegb | depart, arrive |

Scenario: Mixed Entry and Exit
Given the node map
| | a | | c | |
| l | | b | | d |
| | k | | e | |
| j | | h | | f |
| | i | | g | |

And the ways
| nodes | roundabout | oneway |
| abc | no | yes |
| def | no | yes |
| ghi | no | yes |
| jkl | no | yes |
| behkb | yes | yes |

When I route I should get
| waypoints | route | turns |
| a,c | abc,abc,abc | depart, roundabout-exit-1, arrive |
| a,f | abc,def,def | depart, roundabout-exit-2, arrive |
| a,i | abc,ghi,ghi | depart, roundabout-exit-3, arrive |
| a,l | abc,jkl,jkl | depart, roundabout-exit-4, arrive |
| d,f | def,def,def | depart, roundabout-exit-1, arrive |
| d,i | def,ghi,ghi | depart, roundabout-exit-2, arrive |
| d,l | def,jkl,jkl | depart, roundabout-exit-3, arrive |
| d,c | def,abc,abc | depart, roundabout-exit-4, arrive |
| g,i | ghi,ghi,ghi | depart, roundabout-exit-1, arrive |
| g,l | ghi,jkl,jkl | depart, roundabout-exit-2, arrive |
| g,c | ghi,abc,abc | depart, roundabout-exit-3, arrive |
| g,f | ghi,edf,edf | depart, roundabout-exit-4, arrive |
| j,l | jkl,jkl,jkl | depart, roundabout-exit-1, arrive |
| j,c | jkl,abc,abc | depart, roundabout-exit-2, arrive |
| j,f | jkl,def,def | depart, roundabout-exit-3, arrive |
| j,i | jkl,ghi,ghi | depart, roundabout-exit-4, arrive |
7 changes: 6 additions & 1 deletion include/extractor/guidance/toolkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <cmath>
#include <cstdint>
#include <string>
#include <iostream>

namespace osrm
{
Expand Down Expand Up @@ -391,13 +390,19 @@ inline bool requiresNameAnnounced(const std::string &from, const std::string &to

inline int getPriority( const FunctionalRoadClass road_class )
{
//The road priorities indicate which roads can bee seen as more or less equal.
//They are used in Fork-Discovery. Possibly should be moved to profiles post v5?
//A fork can happen between road types that are at most 1 priority apart from each other
const constexpr int road_priority[] = {10, 0, 10, 2, 10, 4, 10, 6, 10, 8, 10, 11, 10, 12, 10, 14};
return road_priority[static_cast<int>(road_class)];
}

inline bool canBeSeenAsFork(const FunctionalRoadClass first, const FunctionalRoadClass second)
{
// forks require similar road categories
// Based on the priorities assigned above, we can set forks only if the road priorities match closely.
// Potentially we could include features like number of lanes here and others?
// Should also be moved to profiles
return std::abs(getPriority(first) - getPriority(second)) <= 1;
}

Expand Down
Loading

0 comments on commit 7cce748

Please sign in to comment.