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
+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;