Rename side API

Side -> Approach
 - DEFAULT -> CURB
 - BOTH -> UNRESTRICTED
 - remove OPPOSITE param

Signed-off-by: FILLAU Jean-Maxime <jean-maxime.fillau@mapotempo.com>
This commit is contained in:
FILLAU Jean-Maxime
2017-05-22 16:07:12 +02:00
committed by Patrick Niklaus
parent f782dfbfd9
commit f65299d665
16 changed files with 272 additions and 330 deletions
+6 -6
View File
@@ -46,9 +46,9 @@ module.exports = function () {
return waypoints.map(w => [w.lon, w.lat].map(ensureDecimal).join(','));
};
this.requestRoute = (waypoints, bearings, sides, userParams, callback) => {
this.requestRoute = (waypoints, bearings, approaches, userParams, callback) => {
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');
if (approaches.length && approaches.length !== waypoints.length) throw new Error('*** number of approaches does not equal the number of waypoints');
var defaults = {
output: 'json',
@@ -68,8 +68,8 @@ module.exports = function () {
}).join(';');
}
if (sides.length) {
params.sides = sides.join(';');
if (approaches.length) {
params.approaches = approaches.join(';');
}
return this.requestPath('route', params, callback);
};
@@ -167,8 +167,8 @@ module.exports = function () {
('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.approachList = (instructions) => {
return this.extractInstructionList(instructions, s => s.approaches || '');
};
this.annotationList = (instructions) => {
+11 -11
View File
@@ -35,7 +35,7 @@ module.exports = function () {
if (err) return cb(err);
if (body && body.length) {
let destinations, pronunciations, instructions, refs, bearings, turns, modes, times,
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, sides;
distances, summary, intersections, lanes, locations, annotation, weight_name, weights, approaches;
let json = JSON.parse(body);
@@ -60,7 +60,7 @@ module.exports = function () {
annotation = this.annotationList(json.routes[0]);
weight_name = this.weightName(json.routes[0]);
weights = this.weightList(json.routes[0]);
sides = this.sideList(json.routes[0]);
approaches = this.approachList(json.routes[0]);
}
if (headers.has('status')) {
@@ -148,8 +148,8 @@ module.exports = function () {
got.locations = (locations || '').trim();
}
/*
if (headers.has('sides')){
got.sides = (sides || '').trim();
if (headers.has('approaches')){
got.approaches = (approaches || '').trim();
}*/
// if header matches 'a:*', parse out the values for *
// and return in that header
@@ -180,7 +180,7 @@ module.exports = function () {
putValue('weight_name', weight_name);
putValue('weights', weights);
putValue('weight', weight);
putValue('side', sides);
putValue('approach', approaches);
for (var key in row) {
if (this.FuzzyMatch.match(got[key], row[key])) {
@@ -216,16 +216,16 @@ module.exports = function () {
var params = this.overwriteParams(defaultParams, userParams),
waypoints = [],
bearings = [],
sides = [];
approaches = [];
if (row.bearings) {
got.bearings = row.bearings;
bearings = row.bearings.split(' ').filter(b => !!b);
}
if (row.sides) {
got.sides = row.sides;
sides = row.sides.split(' ').filter(b => !!b);
if (row.approaches) {
got.approaches = row.approaches;
approaches = row.approaches.split(' ').filter(b => !!b);
}
if (row.from && row.to) {
@@ -239,7 +239,7 @@ module.exports = function () {
got.from = row.from;
got.to = row.to;
this.requestRoute(waypoints, bearings, sides, params, afterRequest);
this.requestRoute(waypoints, bearings, approaches, params, afterRequest);
} else if (row.waypoints) {
row.waypoints.split(',').forEach((n) => {
var node = this.findNodeByName(n.trim());
@@ -247,7 +247,7 @@ module.exports = function () {
waypoints.push(node);
});
got.waypoints = row.waypoints;
this.requestRoute(waypoints, bearings, sides, params, afterRequest);
this.requestRoute(waypoints, bearings, approaches, params, afterRequest);
} else {
return cb(new Error('*** no waypoints'));
}
+192
View File
@@ -0,0 +1,192 @@
@routing @approach_param @testbot
Feature: Approach parameter
Background:
Given the profile "car"
And a grid size of 10 meters
Scenario: Testbot - Start End same approach, option unrestricted for Start and End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted unrestricted | ab,bc |
Scenario: Testbot - Start End same approach, option unrestricted for Start and curb for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | ab,bc,bc |
Scenario: Testbot - Start End opposite approach, option unrestricted for Start and End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted unrestricted | ab,bc |
Scenario: Testbot - Start End opposite approach, option unrestricted for Start and curb for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | ab,bc |
###############
# Oneway Test #
###############
Scenario: Testbot - Test on oneway segment, Start End same approach, option unrestricted for Start and End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted unrestricted | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End same approach, option unrestricted for Start and curb for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End opposite approach, option unrestricted for Start and End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted unrestricted | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End opposite approach, option unrestricted for Start and curb for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | ab,bc |
##############
# UTurn Test #
##############
Scenario: Testbot - UTurn test, router can't found a route because uturn unauthorized on the segment selected
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | bc | bc | c | no_u_turn |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | |
Scenario: Testbot - UTurn test, router can found a route because he can use the roundabout
Given the node map
"""
h
s e / \
a------b------c g
\ /
f
"""
And the ways
| nodes | junction |
| ab | |
| bc | |
| cfghc | roundabout |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | bc | bc | c | no_u_turn |
When I route I should get
| from | to | approaches | route |
| s | e | unrestricted curb | ab,bc,bc |
-245
View File
@@ -1,245 +0,0 @@
@routing @side_param @testbot
Feature: Side parameter
Background:
Given the profile "car"
And a grid size of 10 meters
Scenario: Testbot - Start End same side, option both for Start and End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b b | ab,bc |
Scenario: Testbot - Start End same side, option both for Start and Default for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b d | ab,bc,bc |
Scenario: Testbot - Start End same side, option both for Start and Opposite for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b o | ab,bc |
Scenario: Testbot - Start End opposite side, option both for Start and End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b b | ab,bc |
Scenario: Testbot - Start End opposite side, option both for Start and Default for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b d | ab,bc |
Scenario: Testbot - Start End opposite side, option both for Start and Opposite for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes |
| ab |
| bc |
When I route I should get
| from | to | sides | route |
| s | e | b o | ab,bc,bc |
###############
# Oneway Test #
###############
Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and End,
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b b | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and Default for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b d | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End same side, option both for Start and Opposite for End
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b o | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and End,
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b b | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and Default for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b d | ab,bc |
Scenario: Testbot - Test on oneway segment, Start End opposite side, option both for Start and Opposite for End
Given the node map
"""
s
a------b------c
e
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
When I route I should get
| from | to | sides | route |
| s | e | b o | ab,bc |
Scenario: Testbot - UTurn test, router can't found a route because uturn unauthorized on the segment selected
Given the node map
"""
s e
a------b------c
"""
And the ways
| nodes |
| ab |
| bc |
And the relations
| type | way:from | way:to | node:via | restriction |
| restriction | bc | bc | c | no_u_turn |
When I route I should get
| from | to | sides | route |
| s | e | b d | |