From 4b6a85aae04abc3dc241a7b7b50dc2abc1a7d012 Mon Sep 17 00:00:00 2001 From: Lauren Budorick Date: Tue, 29 Mar 2016 18:18:09 -0700 Subject: [PATCH] Distance matrix fixes --- features/step_definitions/distance_matrix.js | 2 +- features/support/exception_classes.js | 12 ++++++------ features/support/route.js | 6 ++++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/features/step_definitions/distance_matrix.js b/features/step_definitions/distance_matrix.js index 93189eeb2..735847d56 100644 --- a/features/step_definitions/distance_matrix.js +++ b/features/step_definitions/distance_matrix.js @@ -47,7 +47,7 @@ module.exports = function () { var result = json['durations'].map(row => { var hashes = {}; - row.forEach((v, i) => hashes[tableRows[0][i+1]] = v); + row.forEach((v, i) => { hashes[tableRows[0][i+1]] = isNaN(parseInt(v)) ? '' : v; }); return hashes; }); diff --git a/features/support/exception_classes.js b/features/support/exception_classes.js index bb5e62dbc..9740be580 100644 --- a/features/support/exception_classes.js +++ b/features/support/exception_classes.js @@ -18,18 +18,18 @@ var OSRMError = class extends Error { this.logTail(this.log, this.lines, callback); } - toString (callback) { - this.extract((tail) => { - callback(util.format('*** %s\nLast %s from %s:\n%s\n', this.msg, this.lines, this.log, tail)); - }); - } + // toString (callback) { + // this.extract((tail) => { + // callback(util.format('*** %s\nLast %s from %s:\n%s\n', this.msg, this.lines, this.log, tail)); + // }); + // } logTail (logPath, n, callback) { var expanded = path.resolve(this.TEST_FOLDER, logPath); fs.exists(expanded, (exists) => { if (exists) { fs.readFile(expanded, (err, data) => { - var lines = data.trim().split('\n'); + var lines = data.toString().trim().split('\n'); callback(lines .slice(lines.length - n) .map(line => util.format(' %s', line)) diff --git a/features/support/route.js b/features/support/route.js index 1bfe22d91..5168e619d 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -82,8 +82,10 @@ module.exports = function () { params = this.overwriteParams(defaults, userParams); params.coordinates = waypoints.map(w => [w.coord.lon, w.coord.lat].join(',')); - // TODO what was 'type' here? - // params = params.concat(waypoints.map(w => [w.type, [w.coord.lat, w.coord.lon].join(',')])); + var srcs = waypoints.map((w, i) => [w.type, i]).filter(w => w[0] === 'src').map(w => w[1]), + dsts = waypoints.map((w, i) => [w.type, i]).filter(w => w[0] === 'dst').map(w => w[1]); + if (srcs.length) params.sources = srcs.join(';'); + if (dsts.length) params.destinations = dsts.join(';'); return this.requestPath('table', params, callback); };