Add data_version field to responses of all plugins. (#5387)

This commit is contained in:
Lev Dragunov
2022-08-22 22:07:32 +03:00
committed by GitHub
parent 972a848094
commit 928867c520
14 changed files with 183 additions and 17 deletions
+52
View File
@@ -59,6 +59,31 @@ Feature: Locating Nearest node on a Way - pick closest way
| 3 | u |
| 4 | w |
Scenario: Nearest - inside a oneway triangle
Given the node map
"""
c
y z
0 1
2 3 4
a x u w b
"""
And the ways
| nodes | oneway |
| ab | yes |
| bc | yes |
| ca | yes |
When I request nearest I should get
| in | out |
| 0 | y |
| 1 | z |
| 2 | x |
| 3 | u |
| 4 | w |
Scenario: Nearest - High lat/lon
Given the node locations
| node | lat | lon |
@@ -78,3 +103,30 @@ Feature: Locating Nearest node on a Way - pick closest way
| x | a |
| y | b |
| z | c |
Scenario: Nearest - data version
Given the node map
"""
c
y z
0 1
2 3 4
a x u w b
"""
And the ways
| nodes |
| ab |
| bc |
| ca |
And the extract extra arguments "--data_version cucumber_data_version"
When I request nearest I should get
| in | out | data_version |
| 0 | y | cucumber_data_version |
| 1 | z | cucumber_data_version |
| 2 | x | cucumber_data_version |
| 3 | u | cucumber_data_version |
| 4 | w | cucumber_data_version |
+4
View File
@@ -117,6 +117,10 @@ module.exports = function () {
got.duration = duration.toString();
}
if (headers.has('data_version')) {
got.data_version = json.data_version || '';
}
// if header matches 'a:*', parse out the values for *
// and return in that header
headers.forEach((k) => {
+6
View File
@@ -8,6 +8,7 @@ module.exports = function () {
this.reprocessAndLoadData((e) => {
if (e) return callback(e);
var testRow = (row, ri, cb) => {
var inNode = this.findNodeByName(row.in);
if (!inNode) throw new Error(util.format('*** unknown in-node "%s"', row.in));
@@ -17,6 +18,7 @@ module.exports = function () {
this.requestNearest(inNode, this.queryParams, (err, response) => {
if (err) return cb(err);
var coord;
var headers = new Set(table.raw()[0]);
if (response.statusCode === 200 && response.body.length) {
var json = JSON.parse(response.body);
@@ -25,6 +27,10 @@ module.exports = function () {
var got = { in: row.in, out: row.out };
if (headers.has('data_version')) {
got.data_version = json.data_version || '';
}
Object.keys(row).forEach((key) => {
if (key === 'out') {
if (this.FuzzyMatch.matchLocation(coord, outNode)) {
+4
View File
@@ -43,6 +43,10 @@ module.exports = function () {
got.message = json.message;
}
if (headers.has('data_version')) {
got.data_version = json.data_version || '';
}
if (headers.has('geometry')) {
if (this.queryParams['geometries'] === 'polyline') {
got.geometry = polyline.decode(json.trips[0].geometry).toString();
+2 -1
View File
@@ -726,4 +726,5 @@ Feature: Basic Distance Matrix
| | 1 | 2 | 3 |
| 1 | 0 | 1000.1 | 1400.1 |
| 2 | 1000.1 | 0 | 400 |
| 3 | 1400.1 | 400 | 0 |
| 3 | 1400.1 | 400 | 0 |
+23 -3
View File
@@ -21,8 +21,27 @@ Feature: Basic Map Matching
| abcd | no |
When I match I should get
| trace | timestamps | matchings |
| ab1d | 0 1 2 3 | ad |
| trace | timestamps | matchings | data_version |
| ab1d | 0 1 2 3 | ad | |
Scenario: Data_version test on matching
Given a grid size of 100 meters
Given the node map
"""
a b c d
1
"""
And the extract extra arguments "--data_version cucumber_data_version"
And the ways
| nodes | oneway |
| abcd | no |
When I match I should get
| trace | timestamps | matchings | data_version |
| ab1d | 0 1 2 3 | ad | cucumber_data_version |
Scenario: Testbot - Map matching with trace splitting
Given the node map
@@ -792,4 +811,5 @@ Feature: Basic Map Matching
When I match I should get
| trace | geometry | a:distance | a:duration | a:weight | duration |
| 2345 | 1.00018,1,1.000314,1 | 14.914666 | 1.4 | 1.4 | 1.4 |
| 4321 | 1.00027,1,1.000135,1 | 15.02597 | 1.5 | 1.5 | 1.5 |
| 4321 | 1.00027,1,1.000135,1 | 15.02597 | 1.5 | 1.5 | 1.5 |
+26 -6
View File
@@ -47,11 +47,31 @@ Feature: Snap start/end point to the nearest way
| adb |
When I route I should get
| from | to | route |
| 1 | b | adb,adb |
| 2 | b | adb,adb |
| 6 | b | aub,aub |
| 7 | b | aub,aub |
| from | to | route | data_version |
| 1 | b | adb,adb | |
| 2 | b | adb,adb | |
| 6 | b | aub,aub | |
| 7 | b | aub,aub | |
Scenario: Data_version check on nearest
Given the node map
"""
4 5 6 7
3 a u
2
1 d b
"""
And the extract extra arguments "--data_version cucumber_data_version"
And the ways
| nodes |
| aub |
| adb |
When I route I should get
| from | to | route | data_version |
| 1 | b | adb,adb | cucumber_data_version |
Scenario: Snap to edge right under start/end point
Given the node map
@@ -182,4 +202,4 @@ Feature: Snap start/end point to the nearest way
| x | m | xe,xe |
| x | n | xf,xf |
| x | o | xg,xg |
| x | p | xh,xh |
| x | p | xh,xh |
+43 -5
View File
@@ -5,6 +5,24 @@ Feature: Basic trip planning
Given the profile "testbot"
Given a grid size of 10 meters
Scenario: Testbot - Trip: Invalid options (like was in test suite for a long time)
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 | code |
| a | | InvalidOptions |
Scenario: Testbot - Trip: Roundtrip between same waypoint
Given the node map
"""
@@ -20,8 +38,28 @@ Feature: Basic trip planning
| da |
When I plan a trip I should get
| waypoints | trips |
| a,a | aa |
| waypoints | trips | code |
| a,a | aa | Ok |
Scenario: Testbot - Trip: data version check
Given the node map
"""
a b
c d
"""
And the ways
| nodes |
| ab |
| bc |
| cb |
| da |
And the extract extra arguments "--data_version cucumber_data_version"
When I plan a trip I should get
| waypoints | trips | data_version | code |
| a,a | aa | cucumber_data_version | Ok |
Scenario: Testbot - Trip: Roundtrip with waypoints (less than 10)
Given the node map
@@ -38,9 +76,9 @@ Feature: Basic trip planning
| da |
When I plan a trip I should get
| waypoints | trips | durations |
| a,b,c,d | abcda | 7.6 |
| d,b,c,a | dbcad | 7.6 |
| waypoints | trips | durations | code |
| a,b,c,d | abcda | 7.6 | Ok |
| d,b,c,a | dbcad | 7.6 | Ok |
Scenario: Testbot - Trip: Roundtrip waypoints (more than 10)
Given the node map