Adding "sides" params for the sides option tests into java script
Signed-off-by: FILLAU Jean-Maxime <jean-maxime.fillau@mapotempo.com>
This commit is contained in:
parent
8e70c87e64
commit
8a54e6a0ec
@ -121,7 +121,7 @@ module.exports = function () {
|
|||||||
|
|
||||||
r.which = dir;
|
r.which = dir;
|
||||||
|
|
||||||
this.requestRoute((dir === 'forw' ? [a, b] : [b, a]), [], this.queryParams, (err, res, body) => {
|
this.requestRoute((dir === 'forw' ? [a, b] : [b, a]), [], [], this.queryParams, (err, res, body) => {
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
|
|
||||||
r.query = this.query;
|
r.query = this.query;
|
||||||
|
@ -46,8 +46,9 @@ module.exports = function () {
|
|||||||
return waypoints.map(w => [w.lon, w.lat].map(ensureDecimal).join(','));
|
return waypoints.map(w => [w.lon, w.lat].map(ensureDecimal).join(','));
|
||||||
};
|
};
|
||||||
|
|
||||||
this.requestRoute = (waypoints, bearings, userParams, callback) => {
|
this.requestRoute = (waypoints, bearings, sides, userParams, callback) => {
|
||||||
if (bearings.length && bearings.length !== waypoints.length) throw new Error('*** number of bearings does not equal the number of waypoints');
|
if (bearings.length && bearings.length !== waypoints.length) throw new Error('*** number of bearings does not equal the number of waypoints');
|
||||||
|
if (sides.length && sides.length !== waypoints.length) throw new Error('*** number of sides does not equal the number of waypoints');
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
output: 'json',
|
output: 'json',
|
||||||
@ -67,6 +68,9 @@ module.exports = function () {
|
|||||||
}).join(';');
|
}).join(';');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sides.length) {
|
||||||
|
params.sides = sides.join(';');
|
||||||
|
}
|
||||||
return this.requestPath('route', params, callback);
|
return this.requestPath('route', params, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,6 +167,10 @@ module.exports = function () {
|
|||||||
('out' in s.intersections[0] ? s.intersections[0].bearings[s.intersections[0].out] : 0));
|
('out' in s.intersections[0] ? s.intersections[0].bearings[s.intersections[0].out] : 0));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.sideList = (instructions) => {
|
||||||
|
return this.extractInstructionList(instructions, s => s.sides || '');
|
||||||
|
};
|
||||||
|
|
||||||
this.annotationList = (instructions) => {
|
this.annotationList = (instructions) => {
|
||||||
if (!('annotation' in instructions.legs[0]))
|
if (!('annotation' in instructions.legs[0]))
|
||||||
return '';
|
return '';
|
||||||
|
@ -35,7 +35,7 @@ module.exports = function () {
|
|||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (body && body.length) {
|
if (body && body.length) {
|
||||||
let destinations, pronunciations, instructions, refs, bearings, turns, modes, times,
|
let destinations, pronunciations, instructions, refs, bearings, turns, modes, times,
|
||||||
distances, summary, intersections, lanes, locations, annotation, weight_name, weights;
|
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, sides;
|
||||||
|
|
||||||
let json = JSON.parse(body);
|
let json = JSON.parse(body);
|
||||||
|
|
||||||
@ -60,6 +60,7 @@ module.exports = function () {
|
|||||||
annotation = this.annotationList(json.routes[0]);
|
annotation = this.annotationList(json.routes[0]);
|
||||||
weight_name = this.weightName(json.routes[0]);
|
weight_name = this.weightName(json.routes[0]);
|
||||||
weights = this.weightList(json.routes[0]);
|
weights = this.weightList(json.routes[0]);
|
||||||
|
sides = this.sideList(json.routes[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers.has('status')) {
|
if (headers.has('status')) {
|
||||||
@ -146,7 +147,10 @@ module.exports = function () {
|
|||||||
if (headers.has('locations')){
|
if (headers.has('locations')){
|
||||||
got.locations = (locations || '').trim();
|
got.locations = (locations || '').trim();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if (headers.has('sides')){
|
||||||
|
got.sides = (sides || '').trim();
|
||||||
|
}*/
|
||||||
// if header matches 'a:*', parse out the values for *
|
// if header matches 'a:*', parse out the values for *
|
||||||
// and return in that header
|
// and return in that header
|
||||||
headers.forEach((k) => {
|
headers.forEach((k) => {
|
||||||
@ -176,6 +180,7 @@ module.exports = function () {
|
|||||||
putValue('weight_name', weight_name);
|
putValue('weight_name', weight_name);
|
||||||
putValue('weights', weights);
|
putValue('weights', weights);
|
||||||
putValue('weight', weight);
|
putValue('weight', weight);
|
||||||
|
putValue('side', sides);
|
||||||
|
|
||||||
for (var key in row) {
|
for (var key in row) {
|
||||||
if (this.FuzzyMatch.match(got[key], row[key])) {
|
if (this.FuzzyMatch.match(got[key], row[key])) {
|
||||||
@ -210,13 +215,19 @@ module.exports = function () {
|
|||||||
|
|
||||||
var params = this.overwriteParams(defaultParams, userParams),
|
var params = this.overwriteParams(defaultParams, userParams),
|
||||||
waypoints = [],
|
waypoints = [],
|
||||||
bearings = [];
|
bearings = [],
|
||||||
|
sides = [];
|
||||||
|
|
||||||
if (row.bearings) {
|
if (row.bearings) {
|
||||||
got.bearings = row.bearings;
|
got.bearings = row.bearings;
|
||||||
bearings = row.bearings.split(' ').filter(b => !!b);
|
bearings = row.bearings.split(' ').filter(b => !!b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (row.sides) {
|
||||||
|
got.sides = row.sides;
|
||||||
|
sides = row.sides.split(' ').filter(b => !!b);
|
||||||
|
}
|
||||||
|
|
||||||
if (row.from && row.to) {
|
if (row.from && row.to) {
|
||||||
var fromNode = this.findNodeByName(row.from);
|
var fromNode = this.findNodeByName(row.from);
|
||||||
if (!fromNode) return cb(new Error(util.format('*** unknown from-node "%s"', row.from)));
|
if (!fromNode) return cb(new Error(util.format('*** unknown from-node "%s"', row.from)));
|
||||||
@ -228,7 +239,7 @@ module.exports = function () {
|
|||||||
|
|
||||||
got.from = row.from;
|
got.from = row.from;
|
||||||
got.to = row.to;
|
got.to = row.to;
|
||||||
this.requestRoute(waypoints, bearings, params, afterRequest);
|
this.requestRoute(waypoints, bearings, sides, params, afterRequest);
|
||||||
} else if (row.waypoints) {
|
} else if (row.waypoints) {
|
||||||
row.waypoints.split(',').forEach((n) => {
|
row.waypoints.split(',').forEach((n) => {
|
||||||
var node = this.findNodeByName(n.trim());
|
var node = this.findNodeByName(n.trim());
|
||||||
@ -236,7 +247,7 @@ module.exports = function () {
|
|||||||
waypoints.push(node);
|
waypoints.push(node);
|
||||||
});
|
});
|
||||||
got.waypoints = row.waypoints;
|
got.waypoints = row.waypoints;
|
||||||
this.requestRoute(waypoints, bearings, params, afterRequest);
|
this.requestRoute(waypoints, bearings, sides, params, afterRequest);
|
||||||
} else {
|
} else {
|
||||||
return cb(new Error('*** no waypoints'));
|
return cb(new Error('*** no waypoints'));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user