Distance matrix fixes
This commit is contained in:
		
							parent
							
								
									e9369293dc
								
							
						
					
					
						commit
						d4e2b5a3b8
					
				@ -47,7 +47,7 @@ module.exports = function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                var result = json['durations'].map(row => {
 | 
					                var result = json['durations'].map(row => {
 | 
				
			||||||
                    var hashes = {};
 | 
					                    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;
 | 
					                    return hashes;
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -18,18 +18,18 @@ var OSRMError = class extends Error {
 | 
				
			|||||||
        this.logTail(this.log, this.lines, callback);
 | 
					        this.logTail(this.log, this.lines, callback);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    toString (callback) {
 | 
					    // toString (callback) {
 | 
				
			||||||
        this.extract((tail) => {
 | 
					    //     this.extract((tail) => {
 | 
				
			||||||
            callback(util.format('*** %s\nLast %s from %s:\n%s\n', this.msg, this.lines, this.log, tail));
 | 
					    //         callback(util.format('*** %s\nLast %s from %s:\n%s\n', this.msg, this.lines, this.log, tail));
 | 
				
			||||||
        });
 | 
					    //     });
 | 
				
			||||||
    }
 | 
					    // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    logTail (logPath, n, callback) {
 | 
					    logTail (logPath, n, callback) {
 | 
				
			||||||
        var expanded = path.resolve(this.TEST_FOLDER, logPath);
 | 
					        var expanded = path.resolve(this.TEST_FOLDER, logPath);
 | 
				
			||||||
        fs.exists(expanded, (exists) => {
 | 
					        fs.exists(expanded, (exists) => {
 | 
				
			||||||
            if (exists) {
 | 
					            if (exists) {
 | 
				
			||||||
                fs.readFile(expanded, (err, data) => {
 | 
					                fs.readFile(expanded, (err, data) => {
 | 
				
			||||||
                    var lines = data.trim().split('\n');
 | 
					                    var lines = data.toString().trim().split('\n');
 | 
				
			||||||
                    callback(lines
 | 
					                    callback(lines
 | 
				
			||||||
                        .slice(lines.length - n)
 | 
					                        .slice(lines.length - n)
 | 
				
			||||||
                        .map(line => util.format('    %s', line))
 | 
					                        .map(line => util.format('    %s', line))
 | 
				
			||||||
 | 
				
			|||||||
@ -82,8 +82,10 @@ module.exports = function () {
 | 
				
			|||||||
            params = this.overwriteParams(defaults, userParams);
 | 
					            params = this.overwriteParams(defaults, userParams);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        params.coordinates = waypoints.map(w => [w.coord.lon, w.coord.lat].join(','));
 | 
					        params.coordinates = waypoints.map(w => [w.coord.lon, w.coord.lat].join(','));
 | 
				
			||||||
        // TODO what was 'type' here?
 | 
					        var srcs = waypoints.map((w, i) => [w.type, i]).filter(w => w[0] === 'src').map(w => w[1]),
 | 
				
			||||||
        // params = params.concat(waypoints.map(w => [w.type, [w.coord.lat, w.coord.lon].join(',')]));
 | 
					            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);
 | 
					        return this.requestPath('table', params, callback);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user