Expose pronunciation in RouteStep

Uses name:pronunciation by default for cars.
This commit is contained in:
Patrick Niklaus
2016-05-26 03:35:38 +02:00
parent 9cdc9008aa
commit 0a53775fb3
17 changed files with 76 additions and 9 deletions
+17
View File
@@ -18,6 +18,23 @@ Feature: Car - Street names in instructions
| from | to | route |
| a | c | My Way,Your Way (A1),Your Way (A1) |
Scenario: Car - A named street with pronunciation
Given the node map
| a | b | d |
| | 1 | |
| | c | |
And the ways
| nodes | name |name:pronunciation | ref |
| ab | My Way | | |
| bd | My Way | meyeway | A1 |
| cd | Your Way | yourewaye | |
When I route I should get
| from | to | route | pronunciations |
| a | d | My Way,My Way (A1) | ,meyeway |
| 1 | c | Your Way,Your Way | yourewaye,yourewaye |
@todo
Scenario: Car - Use way type to describe unnamed ways
Given the node map
+4
View File
@@ -139,6 +139,10 @@ module.exports = function () {
return this.extractInstructionList(instructions, s => s.name);
};
this.pronunciationList = (instructions) => {
return this.extractInstructionList(instructions, s => s.pronunciation || '');
};
this.bearingList = (instructions) => {
return this.extractInstructionList(instructions, s => s.maneuver.bearing_before + '->' + s.maneuver.bearing_after);
};
+7 -3
View File
@@ -1,3 +1,5 @@
'use strict';
var util = require('util');
var assert = require('assert');
@@ -31,14 +33,15 @@ module.exports = function () {
var afterRequest = (err, res, body) => {
if (err) return cb(err);
if (body && body.length) {
var instructions, bearings, turns, modes, times, distances, summary, intersections;
let pronunciations, instructions, bearings, turns, modes, times, distances, summary, intersections;
var json = JSON.parse(body);
let json = JSON.parse(body);
var hasRoute = json.code === 'Ok';
let hasRoute = json.code === 'Ok';
if (hasRoute) {
instructions = this.wayList(json.routes[0]);
pronunciations = this.pronunciationList(json.routes[0]);
bearings = this.bearingList(json.routes[0]);
turns = this.turnList(json.routes[0]);
intersections = this.intersectionList(json.routes[0]);
@@ -122,6 +125,7 @@ module.exports = function () {
putValue('modes', modes);
putValue('times', times);
putValue('distances', distances);
putValue('pronunciations', pronunciations);
}
var ok = true;