Add test case for bearing_after values when collapsing two left turns into a u-turn.

This commit is contained in:
Daniel Patterson 2017-09-21 12:43:58 -07:00
parent fa1a4e8bf6
commit ade58bece7
No known key found for this signature in database
GPG Key ID: 19C12BE1725A028B
3 changed files with 37 additions and 1 deletions

View File

@ -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 |

View File

@ -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 => {

View File

@ -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])) {