diff --git a/features/testbot/distance_matrix.feature b/features/testbot/distance_matrix.feature index f48db123d..399698ad6 100644 --- a/features/testbot/distance_matrix.feature +++ b/features/testbot/distance_matrix.feature @@ -596,7 +596,6 @@ Feature: Basic Distance Matrix | e | 198.8 | 298.9 | 499 | 710.3 | 0 | 1592.8 | | f | 596.4 | 696.5 | 896.6 | 1107.9 | 397.6 | 0 | - Scenario: Testbot - Filling in noroutes with estimates (defaults to input coordinate location) Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" @@ -620,7 +619,18 @@ Feature: Basic Distance Matrix | f | 900.7 | 600.5 | 0 | 302.2 | | 1 | 1501.1 | 1200.9 | 300.2 | 0 | - Scenario: Testbot - Filling in noroutes with estimates - use input coordinate + When I request a travel distance matrix I should get + | | a | b | f | 1 | + | a | 0 | 300.2 | 900.7 | 1501.1 | + + When I request a travel distance matrix I should get + | | a | + | a | 0 | + | b | 300.2 | + | f | 900.7 | + | 1 | 1501.1 | + + Scenario: Testbot - Fise input coordinate Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" Given the query options @@ -644,6 +654,18 @@ Feature: Basic Distance Matrix | f | 900.7 | 600.5 | 0 | 302.2 | | 1 | 1501.1 | 1200.9 | 300.2 | 0 | + When I request a travel distance matrix I should get + | | a | b | f | 1 | + | a | 0 | 300.2 | 900.7 | 1501.1 | + + When I request a travel distance matrix I should get + | | a | + | a | 0 | + | b | 300.2 | + | f | 900.7 | + | 1 | 1501.1 | + + Scenario: Testbot - Filling in noroutes with estimates - use snapped coordinate Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" @@ -668,22 +690,9 @@ Feature: Basic Distance Matrix | f | 900.7 | 600.5 | 0 | 302.2 | | 1 | 1200.9 | 900.7 | 300.2 | 0 | - Scenario: Testbot - Asymetric fallback_speed - more sources than destinations - Given a grid size of 300 meters - Given the extract extra arguments "--small-component-size 4" - Given the query options - | fallback_speed | 5 | - | fallback_coordinate | snapped | - Given the node map - """ - a b f h 1 - d e g i - """ - - And the ways - | nodes | - | abeda | - | fhigf | + When I request a travel distance matrix I should get + | | a | b | f | 1 | + | a | 0 | 300.2 | 900.7 | 1200.9 | When I request a travel distance matrix I should get | | a | @@ -692,23 +701,3 @@ Feature: Basic Distance Matrix | f | 900.7 | | 1 | 1200.9 | - Scenario: Testbot - Asymetric fallback_speed - more destinations than sources - Given a grid size of 300 meters - Given the extract extra arguments "--small-component-size 4" - Given the query options - | fallback_speed | 5 | - | fallback_coordinate | snapped | - Given the node map - """ - a b f h 1 - d e g i - """ - - And the ways - | nodes | - | abeda | - | fhigf | - - When I request a travel distance matrix I should get - | | a | b | f | 1 | - | a | 0 | 300.2 | 900.7 | 1200.9 | diff --git a/features/testbot/duration_matrix.feature b/features/testbot/duration_matrix.feature index 9e2b3f05b..998f85101 100644 --- a/features/testbot/duration_matrix.feature +++ b/features/testbot/duration_matrix.feature @@ -534,6 +534,17 @@ Feature: Basic Duration Matrix | f | 18 | 12 | 0 | 30 | | 1 | 30 | 24 | 30 | 0 | + When I request a travel time matrix I should get + | | a | b | f | 1 | + | a | 0 | 30 | 18 | 30 | + + When I request a travel time matrix I should get + | | a | + | a | 0 | + | b | 30 | + | f | 18 | + | 1 | 30 | + Scenario: Testbot - Filling in noroutes with estimates - use input coordinate Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" @@ -558,6 +569,17 @@ Feature: Basic Duration Matrix | f | 18 | 12 | 0 | 30 | | 1 | 30 | 24 | 30 | 0 | + When I request a travel time matrix I should get + | | a | b | f | 1 | + | a | 0 | 30 | 18 | 30 | + + When I request a travel time matrix I should get + | | a | + | a | 0 | + | b | 30 | + | f | 18 | + | 1 | 30 | + Scenario: Testbot - Filling in noroutes with estimates - use snapped coordinate Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" @@ -582,25 +604,33 @@ Feature: Basic Duration Matrix | f | 18 | 12 | 0 | 30 | | 1 | 24 | 18 | 30 | 0 | + When I request a travel time matrix I should get + | | a | b | f | 1 | + | a | 0 | 30 | 18 | 24 | + + When I request a travel time matrix I should get + | | a + | a | 0 + | b | 30 + | f | 18 + | 1 | 24 + + Scenario: Testbot - Travel time matrix of minimal network with scale factor Given the query options | scale_factor | 2 | - - Given the node map + Given the node map """ a b """ - - And the ways + And the ways | nodes | | ab | - - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | b | | a | 0 | 20 | | b | 20 | 0 | - - Scenario: Testbot - Test fallback speeds and scale factor + Scenario: Testbot - Test fallback speeds and scale factor Given a grid size of 300 meters Given the extract extra arguments "--small-component-size 4" Given the query options @@ -608,68 +638,67 @@ Feature: Basic Duration Matrix | fallback_speed | 5 | | fallback_coordinate | snapped | - Given the node map + Given the node map """ a b f h 1 d e g i """ - And the ways + And the ways | nodes | | abeda | | fhigf | - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | b | f | 1 | | a | 0 | 60 | 36 | 48 | | b | 60 | 0 | 24 | 36 | | f | 36 | 24 | 0 | 60 | | 1 | 48 | 36 | 60 | 0 | - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | b | f | 1 | | a | 0 | 60 | 36 | 48 | - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | | a | 0 | | b | 60 | | f | 36 | | 1 | 48 | - - Scenario: Testbot - Travel time matrix of minimal network with overflow scale factor + Scenario: Testbot - Travel time matrix of minimal network with overflow scale factor Given the query options | scale_factor | 2147483647 | - Given the node map + Given the node map """ a b """ - And the ways + And the ways | nodes | | ab | - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | b | | a | 0 | 214748364.6 | | b | 214748364.6 | 0 | - Scenario: Testbot - Travel time matrix of minimal network with fraction scale factor + Scenario: Testbot - Travel time matrix of minimal network with fraction scale factor Given the query options | scale_factor | 0.5 | - Given the node map + Given the node map """ a b """ - And the ways + And the ways | nodes | | ab | - When I request a travel time matrix I should get + When I request a travel time matrix I should get | | a | b | | a | 0 | 5 | | b | 5 | 0 | diff --git a/test/nodejs/table.js b/test/nodejs/table.js index c42680329..a6b0884aa 100644 --- a/test/nodejs/table.js +++ b/test/nodejs/table.js @@ -276,12 +276,9 @@ tables.forEach(function(annotation) { options.fallback_speed = 10; options.fallback_coordinate = 'bla'; - assert.throws(()=>osrm.table(options, (err, res) => {}), /fallback_coordinate' param must be one of \[input, snapped\]/, "should throw on invalid fallback_coordinate"); - options.fallback_coordinate = 10; - assert.throws(()=>osrm.table(options, (err, res) => {}), /fallback_coordinate must be a string: \[input, snapped\]/, "should throw on invalid fallback_coordinate"); }); diff --git a/unit_tests/server/parameters_parser.cpp b/unit_tests/server/parameters_parser.cpp index 02702563d..f4aad86b0 100644 --- a/unit_tests/server/parameters_parser.cpp +++ b/unit_tests/server/parameters_parser.cpp @@ -91,6 +91,7 @@ BOOST_AUTO_TEST_CASE(invalid_table_urls) 49UL); BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?fallback_coordinate=asdf"), 28UL); + BOOST_CHECK_EQUAL(testInvalidOptions("1,2;3,4?fallback_coordinate=10"), 28UL); BOOST_CHECK_EQUAL( testInvalidOptions("1,2;3,4?annotations=durations&scale_factor=-1"), 28UL); BOOST_CHECK_EQUAL( @@ -580,31 +581,43 @@ BOOST_AUTO_TEST_CASE(valid_table_urls) CHECK_EQUAL_RANGE(reference_7.sources, result_7->sources); CHECK_EQUAL_RANGE(reference_7.destinations, result_7->destinations); -<<<<<<< HEAD - auto result_8 = parseParameters("1,2;3,4?sources=all&destinations=all&" - "annotations=duration&fallback_speed=1&" - "fallback_coordinate=snapped&scale_factor=2"); -======= TableParameters reference_8{}; reference_8.coordinates = coords_1; auto result_8 = parseParameters("1,2;3,4?annotations=distance&fallback_speed=2.5"); ->>>>>>> fix formatting BOOST_CHECK(result_8); - CHECK_EQUAL_RANGE(reference_1.sources, result_3->sources); - CHECK_EQUAL_RANGE(reference_1.destinations, result_3->destinations); - CHECK_EQUAL_RANGE(reference_1.bearings, result_3->bearings); - CHECK_EQUAL_RANGE(reference_1.radiuses, result_3->radiuses); - CHECK_EQUAL_RANGE(reference_1.approaches, result_3->approaches); - CHECK_EQUAL_RANGE(reference_1.coordinates, result_3->coordinates); + BOOST_CHECK_EQUAL(result_8->annotations & TableParameters::AnnotationsType::Distance, true); + CHECK_EQUAL_RANGE(reference_8.sources, result_8->sources); + CHECK_EQUAL_RANGE(reference_8.destinations, result_8->destinations); TableParameters reference_9{}; reference_9.coordinates = coords_1; - auto result_9 = parseParameters("1,2;3,4?annotations=distance&fallback_speed=2.5"); + auto result_9 = parseParameters( + "1,2;3,4?annotations=distance&fallback_speed=2.5&fallback_coordinate=input"); BOOST_CHECK(result_9); BOOST_CHECK_EQUAL(result_9->annotations & TableParameters::AnnotationsType::Distance, true); CHECK_EQUAL_RANGE(reference_9.sources, result_9->sources); CHECK_EQUAL_RANGE(reference_9.destinations, result_9->destinations); + + TableParameters reference_10{}; + reference_10.coordinates = coords_1; + auto result_10 = parseParameters( + "1,2;3,4?annotations=distance&fallback_speed=20&fallback_coordinate=snapped"); + BOOST_CHECK(result_10); + BOOST_CHECK_EQUAL(result_10->annotations & TableParameters::AnnotationsType::Distance, true); + CHECK_EQUAL_RANGE(reference_10.sources, result_10->sources); + CHECK_EQUAL_RANGE(reference_10.destinations, result_10->destinations); + + auto result_11 = parseParameters("1,2;3,4?sources=all&destinations=all&" + "annotations=duration&fallback_speed=1&" + "fallback_coordinate=snapped&scale_factor=2"); + BOOST_CHECK(result_11); + CHECK_EQUAL_RANGE(reference_1.sources, result_11->sources); + CHECK_EQUAL_RANGE(reference_1.destinations, result_11->destinations); + CHECK_EQUAL_RANGE(reference_1.bearings, result_11->bearings); + CHECK_EQUAL_RANGE(reference_1.radiuses, result_11->radiuses); + CHECK_EQUAL_RANGE(reference_1.approaches, result_11->approaches); + CHECK_EQUAL_RANGE(reference_1.coordinates, result_11->coordinates); } BOOST_AUTO_TEST_CASE(valid_match_urls)