Distance matrix fixes

This commit is contained in:
Lauren Budorick 2016-03-29 18:18:09 -07:00 committed by Patrick Niklaus
parent c8a8859d2f
commit 4b6a85aae0
3 changed files with 11 additions and 9 deletions

View File

@ -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;
});

View File

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

View File

@ -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);
};