Trip with Fixed Start and End points (TFSE) (#3408)
* fixed start and end trip feature to trip service
This commit is contained in:
@@ -24,7 +24,6 @@ module.exports = function () {
|
||||
} else if (row[k]) {
|
||||
params[match[1]] = [row[k]];
|
||||
}
|
||||
|
||||
got[k] = row[k];
|
||||
}
|
||||
}
|
||||
@@ -35,11 +34,11 @@ module.exports = function () {
|
||||
}
|
||||
|
||||
if (headers.has('status')) {
|
||||
got.status = json.status.toString();
|
||||
got.status = json.code;
|
||||
}
|
||||
|
||||
if (headers.has('message')) {
|
||||
got.message = json.status_message;
|
||||
got.message = json.message;
|
||||
}
|
||||
|
||||
if (headers.has('geometry')) {
|
||||
@@ -59,6 +58,7 @@ module.exports = function () {
|
||||
|
||||
var subTrips;
|
||||
var trip_durations;
|
||||
var trip_distance;
|
||||
if (res.statusCode === 200) {
|
||||
if (headers.has('trips')) {
|
||||
subTrips = json.trips.filter(t => !!t).map(t => t.legs).map(tl => Array.prototype.concat.apply([], tl.map((sl, i) => {
|
||||
@@ -74,13 +74,19 @@ module.exports = function () {
|
||||
})));
|
||||
trip_durations = all_durations.map( a => a.reduce(add, 0));
|
||||
}
|
||||
if(headers.has('distance')) {
|
||||
var all_distance = json.trips.filter(t => !!t).map(t => t.legs).map(tl => Array.prototype.concat.apply([], tl.map(sl => {
|
||||
return sl.distance;
|
||||
})));
|
||||
trip_distance = all_distance.map( a => a.reduce(add, 0));
|
||||
}
|
||||
}
|
||||
|
||||
var ok = true,
|
||||
encodedResult = '',
|
||||
extendedTarget = '';
|
||||
|
||||
row.trips.split(',').forEach((sub, si) => {
|
||||
if (json.trips) row.trips.split(',').forEach((sub, si) => {
|
||||
if (si >= subTrips.length) {
|
||||
ok = false;
|
||||
} else {
|
||||
@@ -105,10 +111,10 @@ module.exports = function () {
|
||||
got.via_points = row.via_points;
|
||||
} else {
|
||||
got.trips = encodedResult;
|
||||
got.trips = extendedTarget;
|
||||
}
|
||||
|
||||
got.durations = trip_durations;
|
||||
got.distance = trip_distance;
|
||||
|
||||
for (var key in row) {
|
||||
if (this.FuzzyMatch.match(got[key], row[key])) {
|
||||
@@ -144,6 +150,19 @@ module.exports = function () {
|
||||
waypoints.push(node);
|
||||
});
|
||||
got = { waypoints: row.waypoints };
|
||||
|
||||
if (row.source) {
|
||||
params.source = got.source = row.source;
|
||||
}
|
||||
|
||||
if (row.destination) {
|
||||
params.destination = got.destination = row.destination;
|
||||
}
|
||||
|
||||
if (row.hasOwnProperty('roundtrip')) { //roundtrip is a boolean so row.roundtrip alone doesn't work as a check here
|
||||
params.roundtrip = got.roundtrip = row.roundtrip;
|
||||
}
|
||||
|
||||
this.requestTrip(waypoints, params, afterRequest);
|
||||
} else {
|
||||
throw new Error('*** no waypoints');
|
||||
|
||||
+200
-17
@@ -5,7 +5,25 @@ Feature: Basic trip planning
|
||||
Given the profile "testbot"
|
||||
Given a grid size of 10 meters
|
||||
|
||||
Scenario: Testbot - Trip planning with less than 10 nodes
|
||||
Scenario: Testbot - Trip: Roundtrip with one waypoint
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
c d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| cb |
|
||||
| da |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| a | aa |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip with waypoints (less than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
@@ -24,7 +42,7 @@ Feature: Basic trip planning
|
||||
| a,b,c,d | abcda | 7.6 |
|
||||
| d,b,c,a | dbcad | 7.6 |
|
||||
|
||||
Scenario: Testbot - Trip planning with more than 10 nodes
|
||||
Scenario: Testbot - Trip: Roundtrip waypoints (more than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
@@ -37,7 +55,6 @@ Feature: Basic trip planning
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| cb |
|
||||
| de |
|
||||
| ef |
|
||||
| fg |
|
||||
@@ -48,12 +65,85 @@ Feature: Basic trip planning
|
||||
| kl |
|
||||
| la |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l | alkjihgfedcba |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip FS waypoints (more than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
l e
|
||||
k f
|
||||
j i h g
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| de |
|
||||
| ef |
|
||||
| fg |
|
||||
| gh |
|
||||
| hi |
|
||||
| ij |
|
||||
| jk |
|
||||
| kl |
|
||||
| la |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | source | trips |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l | first | alkjihgfedcba |
|
||||
|
||||
Scenario: Testbot - Trip: Roundtrip FE waypoints (more than 10)
|
||||
Given the query options
|
||||
| source | last |
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
l e
|
||||
k f
|
||||
j i h g
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| de |
|
||||
| ef |
|
||||
| fg |
|
||||
| gh |
|
||||
| hi |
|
||||
| ij |
|
||||
| jk |
|
||||
| kl |
|
||||
| la |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l | cbalkjihgfedc |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l | lkjihgfedcbal |
|
||||
|
||||
Scenario: Testbot - Trip planning with multiple scc
|
||||
Scenario: Testbot - Trip: Unroutable roundtrip with waypoints (less than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
|
||||
d c
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| dc |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | status | message |
|
||||
| a,b,c,d | NoTrips | No trip visiting all destinations possible. |
|
||||
|
||||
|
||||
Scenario: Testbot - Trip: Unroutable roundtrip with waypoints (more than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b c d
|
||||
@@ -62,7 +152,7 @@ Feature: Basic trip planning
|
||||
j i h g
|
||||
|
||||
q m n
|
||||
p o
|
||||
p o
|
||||
"""
|
||||
|
||||
And the ways
|
||||
@@ -85,13 +175,106 @@ Feature: Basic trip planning
|
||||
| pq |
|
||||
| qm |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | status | message |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p | NoTrips | No trip visiting all destinations possible. |
|
||||
|
||||
# Test TFSE
|
||||
Scenario: Testbot - Trip: TFSE with errors
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
|
||||
d c
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| dc |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | source | destination | roundtrip | status | message |
|
||||
| a,b,c,d | first | last | false | NoTrips | No trip visiting all destinations possible. |
|
||||
|
||||
Scenario: Testbot - Trip: FSE with waypoints (less than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
|
||||
c
|
||||
e d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| ac |
|
||||
| ad |
|
||||
| ae |
|
||||
| bc |
|
||||
| bd |
|
||||
| be |
|
||||
| cd |
|
||||
| ce |
|
||||
| de |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p | defghijklabcd,mnopm |
|
||||
| waypoints | source | destination |roundtrip | trips | durations | distance |
|
||||
| a,b,d,e,c | first | last | false | abedc | 8.200000000000001 | 81.6 |
|
||||
|
||||
# Test single node in each component #1850
|
||||
Scenario: Testbot - Trip planning with less than 10 nodes
|
||||
|
||||
Scenario: Testbot - Trip: FSE with waypoints (more than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b c d e f g h i j k
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| bc |
|
||||
| cd |
|
||||
| de |
|
||||
| ef |
|
||||
| fg |
|
||||
| gh |
|
||||
| hi |
|
||||
| ij |
|
||||
| jk |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | source | destination | roundtrip | trips | durations | distance |
|
||||
| a,b,c,d,e,h,i,j,k,g,f | first | last | false | abcdeghijkf | 15 | 149.8 |
|
||||
|
||||
Scenario: Testbot - Trip: FSE roundtrip with waypoints (less than 10)
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
|
||||
c
|
||||
e d
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
| ac |
|
||||
| ad |
|
||||
| ae |
|
||||
| bc |
|
||||
| bd |
|
||||
| be |
|
||||
| cd |
|
||||
| ce |
|
||||
| de |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | source | destination | roundtrip | trips |
|
||||
| a,b,d,e,c | first | last | true | abedca |
|
||||
|
||||
|
||||
Scenario: Testbot - Trip: midway points in isoldated roads should return no trips
|
||||
Given the node map
|
||||
"""
|
||||
a 1 b
|
||||
@@ -105,10 +288,10 @@ Feature: Basic trip planning
|
||||
| cd |
|
||||
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips |
|
||||
| 1,2 | |
|
||||
| waypoints | status | message |
|
||||
| 1,2 | NoTrips | No trip visiting all destinations possible. |
|
||||
|
||||
Scenario: Testbot - Repeated Coordinate
|
||||
Scenario: Testbot - Trip: Repeated Coordinate
|
||||
Given the node map
|
||||
"""
|
||||
a b
|
||||
@@ -123,7 +306,7 @@ Feature: Basic trip planning
|
||||
| a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a | |
|
||||
|
||||
|
||||
Scenario: Testbot - Trip with geometry details of geojson
|
||||
Scenario: Testbot - Trip: geometry details of geojson
|
||||
Given the query options
|
||||
| geometries | geojson |
|
||||
|
||||
@@ -145,7 +328,7 @@ Feature: Basic trip planning
|
||||
| a,b,c,d | abcda | 7.6 | 1,1,1.00009,1,1,0.99991,1.00009,1,1,1,1.00009,0.99991,1,1 |
|
||||
| d,b,c,a | dbcad | 7.6 | 1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009,1,1,1,1.00009,0.99991 |
|
||||
|
||||
Scenario: Testbot - Trip with geometry details of polyline
|
||||
Scenario: Testbot - Trip: geometry details of polyline
|
||||
Given the query options
|
||||
| geometries | polyline |
|
||||
|
||||
@@ -167,7 +350,7 @@ Feature: Basic trip planning
|
||||
| a,b,c,d | abcda | 7.6 | 1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009,1,1 |
|
||||
| d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 |
|
||||
|
||||
Scenario: Testbot - Trip with geometry details of polyline6
|
||||
Scenario: Testbot - Trip: geometry details of polyline6
|
||||
Given the query options
|
||||
| geometries | polyline6 |
|
||||
|
||||
@@ -187,4 +370,4 @@ Feature: Basic trip planning
|
||||
When I plan a trip I should get
|
||||
| waypoints | trips | durations | geometry |
|
||||
| a,b,c,d | abcda | 7.6 | 1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009,1,1 |
|
||||
| d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 |
|
||||
| d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 |
|
||||
Reference in New Issue
Block a user