Fix summary generation when empty strings are present.

Also corrects step ordering when steps have equal durations.
This commit is contained in:
Daniel Patterson
2016-04-28 16:48:44 -07:00
committed by Patrick Niklaus
parent aab1aad8f4
commit f251f93a11
5 changed files with 88 additions and 4 deletions
+6
View File
@@ -127,6 +127,12 @@ module.exports = function () {
}
};
this.summary = (instructions) => {
if (instructions) {
return instructions.legs.map(l => l.summary).join(',');
}
}
this.wayList = (instructions) => {
return this.extractInstructionList(instructions, s => s.name);
};
+6 -1
View File
@@ -31,7 +31,7 @@ module.exports = function () {
var afterRequest = (err, res, body) => {
if (err) return cb(err);
if (body && body.length) {
var instructions, bearings, turns, modes, times, distances;
var instructions, bearings, turns, modes, times, distances, summary;
var json = JSON.parse(body);
@@ -44,6 +44,7 @@ module.exports = function () {
modes = this.modeList(json.routes[0]);
times = this.timeList(json.routes[0]);
distances = this.distanceList(json.routes[0]);
summary = this.summary(json.routes[0]);
}
if (headers.has('status')) {
@@ -66,6 +67,10 @@ module.exports = function () {
if (headers.has('route')) {
got.route = (instructions || '').trim();
if (headers.has('summary')) {
got.summary = (summary || '').trim();
}
if (headers.has('alternative')) {
// TODO examine more than first alternative?
got.alternative ='';