add testscases for mode changes / additional assertions
This commit is contained in:
parent
7073403f1b
commit
88208bfa5d
@ -484,6 +484,23 @@ Feature: Collapse
|
|||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| a,d | road,road | depart,arrive |
|
| a,d | road,road | depart,arrive |
|
||||||
|
|
||||||
|
Scenario: No Name During Turns - Ferry
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a b
|
||||||
|
c d
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway | name | route |
|
||||||
|
| ab | tertiary | road | |
|
||||||
|
| bc | tertiary | | ferry |
|
||||||
|
| cd | tertiary | road | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns |
|
||||||
|
| a,d | road,,road,road | depart,notification right,notification left,arrive |
|
||||||
|
|
||||||
Scenario: No Name During Turns, Random Oneway
|
Scenario: No Name During Turns, Random Oneway
|
||||||
Given the node map
|
Given the node map
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,7 @@ Feature: Staggered Intersections
|
|||||||
| jcdehi | residential | Cedar Dr |
|
| jcdehi | residential | Cedar Dr |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| waypoints | route | turns |
|
| waypoints | route | turns |
|
||||||
| a,g | Oak St,Oak St | depart,arrive |
|
| a,g | Oak St,Oak St | depart,arrive |
|
||||||
| g,a | Oak St,Oak St | depart,arrive |
|
| g,a | Oak St,Oak St | depart,arrive |
|
||||||
|
|
||||||
|
@ -44,6 +44,27 @@ Feature: Turn Lane Guidance
|
|||||||
| a,c | in,straight,straight | depart,new name straight,arrive | ,straight:true right:false, |
|
| a,c | in,straight,straight | depart,new name straight,arrive | ,straight:true right:false, |
|
||||||
| a,d | in,right,right | depart,turn right,arrive | ,straight:false right:true, |
|
| a,d | in,right,right | depart,turn right,arrive | ,straight:false right:true, |
|
||||||
|
|
||||||
|
# Turn Lane onto a ferry could end up breaking in intersection generation
|
||||||
|
Scenario: Basic Turn Lane 3-way Turn with designated lane
|
||||||
|
Given the node map
|
||||||
|
"""
|
||||||
|
a - b ~ ~ c - e
|
||||||
|
| |
|
||||||
|
d f
|
||||||
|
"""
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | turn:lanes:forward | name | route |
|
||||||
|
| ab | through\|through\|right | ferry-route | |
|
||||||
|
| bc | through\|through\|right | ferry-route | ferry |
|
||||||
|
| ce | | ferry-route | |
|
||||||
|
| bd | | right | |
|
||||||
|
| cf | | right | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns |
|
||||||
|
| a,e | ferry-route,ferry-route,ferry-route,ferry-route | depart,notification straight,notification straight,arrive |
|
||||||
|
|
||||||
@simple
|
@simple
|
||||||
Scenario: Basic Turn Lane 4-Way Turn
|
Scenario: Basic Turn Lane 4-Way Turn
|
||||||
Given the node map
|
Given the node map
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#include "util/group_by.hpp"
|
#include "util/group_by.hpp"
|
||||||
#include "util/guidance/toolkit.hpp"
|
#include "util/guidance/toolkit.hpp"
|
||||||
|
|
||||||
#include "engine/guidance/toolkit.hpp"
|
|
||||||
#include "extractor/guidance/turn_instruction.hpp"
|
#include "extractor/guidance/turn_instruction.hpp"
|
||||||
#include "engine/guidance/post_processing.hpp"
|
#include "engine/guidance/post_processing.hpp"
|
||||||
|
#include "engine/guidance/toolkit.hpp"
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
@ -477,6 +477,8 @@ void collapseUTurn(std::vector<RouteStep> &steps,
|
|||||||
invalidateStep(steps[step_index]);
|
invalidateStep(steps[step_index]);
|
||||||
if (u_turn_with_name_change)
|
if (u_turn_with_name_change)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT_MSG(compatible(steps[one_back_index], steps[next_step_index]),
|
||||||
|
"Compatibility should be transitive");
|
||||||
steps[one_back_index] =
|
steps[one_back_index] =
|
||||||
elongate(std::move(steps[one_back_index]), steps[next_step_index]);
|
elongate(std::move(steps[one_back_index]), steps[next_step_index]);
|
||||||
invalidateStep(steps[next_step_index]); // will be skipped due to the
|
invalidateStep(steps[next_step_index]); // will be skipped due to the
|
||||||
@ -719,7 +721,7 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
|
|||||||
invalidateStep(steps[one_back_index]);
|
invalidateStep(steps[one_back_index]);
|
||||||
}
|
}
|
||||||
// very short segment after turn, turn location remains at one_back_step
|
// very short segment after turn, turn location remains at one_back_step
|
||||||
else if (isDelayedTurn(one_back_step, current_step))
|
else if (isDelayedTurn(one_back_step, current_step)) // checks for compatibility
|
||||||
{
|
{
|
||||||
steps[one_back_index] = elongate(std::move(steps[one_back_index]), steps[step_index]);
|
steps[one_back_index] = elongate(std::move(steps[one_back_index]), steps[step_index]);
|
||||||
// TODO check for lanes (https://github.com/Project-OSRM/osrm-backend/issues/2553)
|
// TODO check for lanes (https://github.com/Project-OSRM/osrm-backend/issues/2553)
|
||||||
@ -1046,6 +1048,9 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
// a series of turns is only possible to collapse if its only name changes and suppressed turns.
|
// a series of turns is only possible to collapse if its only name changes and suppressed turns.
|
||||||
const auto canCollapseAll = [&steps](std::size_t index, const std::size_t end_index) {
|
const auto canCollapseAll = [&steps](std::size_t index, const std::size_t end_index) {
|
||||||
BOOST_ASSERT(end_index <= steps.size());
|
BOOST_ASSERT(end_index <= steps.size());
|
||||||
|
if (!compatible(steps[index], steps[index + 1]))
|
||||||
|
return false;
|
||||||
|
++index;
|
||||||
for (; index < end_index; ++index)
|
for (; index < end_index; ++index)
|
||||||
{
|
{
|
||||||
if (steps[index].maneuver.instruction.type != TurnType::Suppressed &&
|
if (steps[index].maneuver.instruction.type != TurnType::Suppressed &&
|
||||||
@ -1145,7 +1150,7 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
current_step.maneuver.instruction.type != TurnType::Suppressed &&
|
current_step.maneuver.instruction.type != TurnType::Suppressed &&
|
||||||
!isNoticeableNameChange(steps[getPreviousNameIndex(step_index)], current_step) &&
|
!isNoticeableNameChange(steps[getPreviousNameIndex(step_index)], current_step) &&
|
||||||
// canCollapseAll is also checking for compatible(step,step+1) for all indices
|
// canCollapseAll is also checking for compatible(step,step+1) for all indices
|
||||||
canCollapseAll(getPreviousNameIndex(step_index) + 1, next_step_index))
|
canCollapseAll(getPreviousNameIndex(step_index), next_step_index))
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(step_index > 0);
|
BOOST_ASSERT(step_index > 0);
|
||||||
const std::size_t last_available_name_index = getPreviousNameIndex(step_index);
|
const std::size_t last_available_name_index = getPreviousNameIndex(step_index);
|
||||||
@ -1189,7 +1194,8 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps)
|
|||||||
steps[two_back_index] =
|
steps[two_back_index] =
|
||||||
elongate(std::move(steps[two_back_index]), steps[one_back_index]);
|
elongate(std::move(steps[two_back_index]), steps[one_back_index]);
|
||||||
invalidateStep(steps[one_back_index]);
|
invalidateStep(steps[one_back_index]);
|
||||||
if (nameSegmentLength(step_index, steps) < name_segment_cutoff_length)
|
if (nameSegmentLength(step_index, steps) < name_segment_cutoff_length &&
|
||||||
|
compatible(steps[two_back_index], steps[step_index]))
|
||||||
{
|
{
|
||||||
steps[two_back_index] =
|
steps[two_back_index] =
|
||||||
elongate(std::move(steps[two_back_index]), steps[step_index]);
|
elongate(std::move(steps[two_back_index]), steps[step_index]);
|
||||||
@ -1562,6 +1568,7 @@ std::vector<RouteStep> buildIntersections(std::vector<RouteStep> steps)
|
|||||||
const auto instruction = step.maneuver.instruction;
|
const auto instruction = step.maneuver.instruction;
|
||||||
if (instruction.type == TurnType::Suppressed)
|
if (instruction.type == TurnType::Suppressed)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT(compatible(steps[last_valid_instruction], step));
|
||||||
// count intersections. We cannot use exit, since intersections can follow directly
|
// count intersections. We cannot use exit, since intersections can follow directly
|
||||||
// after a roundabout
|
// after a roundabout
|
||||||
steps[last_valid_instruction] =
|
steps[last_valid_instruction] =
|
||||||
@ -1629,8 +1636,11 @@ std::vector<RouteStep> collapseUseLane(std::vector<RouteStep> steps)
|
|||||||
if (step.maneuver.instruction.type == TurnType::UseLane && canCollapseUseLane(step))
|
if (step.maneuver.instruction.type == TurnType::UseLane && canCollapseUseLane(step))
|
||||||
{
|
{
|
||||||
const auto previous = getPreviousIndex(step_index, steps);
|
const auto previous = getPreviousIndex(step_index, steps);
|
||||||
steps[previous] = elongate(std::move(steps[previous]), steps[step_index]);
|
if (compatible(steps[previous], step))
|
||||||
invalidateStep(steps[step_index]);
|
{
|
||||||
|
steps[previous] = elongate(std::move(steps[previous]), steps[step_index]);
|
||||||
|
invalidateStep(steps[step_index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return removeNoTurnInstructions(std::move(steps));
|
return removeNoTurnInstructions(std::move(steps));
|
||||||
|
Loading…
Reference in New Issue
Block a user