From ade58bece7030f7145ba1b195f6a137f235c4e3a Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Thu, 21 Sep 2017 12:43:58 -0700 Subject: [PATCH] Add test case for bearing_after values when collapsing two left turns into a u-turn. --- features/guidance/collapse.feature | 19 +++++++++++++++++++ features/support/route.js | 12 ++++++++++++ features/support/shared_steps.js | 7 ++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/features/guidance/collapse.feature b/features/guidance/collapse.feature index ab58c72bc..aec4f113c 100644 --- a/features/guidance/collapse.feature +++ b/features/guidance/collapse.feature @@ -1074,3 +1074,22 @@ Feature: Collapse When I route I should get | waypoints | bearings | route | turns | locations | | 1,2 | 90 270 | ab,bd,bd,ab,ab | depart,turn left,continue uturn,turn right,arrive | _,b,d,b,_ | + + + Scenario: Correct bearings after collapsing u-turns + Given the node map + """ + a--------------------b--------------c + | + d--------------------e--------------f + """ + + And the ways + | nodes | highway | name | oneway | + | cba | secondary | Main St | yes | + | def | secondary | Main St | yes | + | eb | secondary | Main St | | + + When I route I should get + | waypoints | bearing_before | bearing_after | turns | + | c,f | 0,268,90 | 270,90,0 | depart,continue uturn,arrive | diff --git a/features/support/route.js b/features/support/route.js index ce86772b5..df50ca2a6 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -250,6 +250,18 @@ module.exports = function () { .join(','); }; + this.step_bearing_befores = (instructions) => { + return instructions.legs.reduce((allsteps,leg) => allsteps.concat(leg.steps), []) + .map(step => step.maneuver.bearing_before) + .join(','); + }; + + this.step_bearing_afters = (instructions) => { + return instructions.legs.reduce((allsteps,leg) => allsteps.concat(leg.steps), []) + .map(step => step.maneuver.bearing_after) + .join(','); + }; + this.intersectionList = (instructions) => { return instructions.legs.reduce((m, v) => m.concat(v.steps), []) .map( v => { diff --git a/features/support/shared_steps.js b/features/support/shared_steps.js index 46e26c75f..06abd7740 100644 --- a/features/support/shared_steps.js +++ b/features/support/shared_steps.js @@ -35,7 +35,8 @@ module.exports = function () { if (err) return cb(err); if (body && body.length) { let destinations, exits, pronunciations, instructions, refs, bearings, turns, modes, times, classes, - distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches; + distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches, + bearing_befores, bearing_afters; let json = JSON.parse(body); @@ -63,6 +64,8 @@ module.exports = function () { weight_name = this.weightName(json.routes[0]); weights = this.weightList(json.routes[0]); approaches = this.approachList(json.routes[0]); + bearing_befores = this.step_bearing_befores(json.routes[0]); + bearing_afters = this.step_bearing_afters(json.routes[0]); } if (headers.has('status')) { @@ -185,6 +188,8 @@ module.exports = function () { putValue('weights', weights); putValue('weight', weight); putValue('approach', approaches); + putValue('bearing_before', bearing_befores); + putValue('bearing_after', bearing_afters); for (var key in row) { if (this.FuzzyMatch.match(got[key], row[key])) {