Hook up small component locations for Nearest response test
This commit is contained in:
		
							parent
							
								
									1c41a6b1e8
								
							
						
					
					
						commit
						3e1b7ad6d5
					
				| @ -20,8 +20,7 @@ inline Location get_dummy_location() | |||||||
| 
 | 
 | ||||||
| inline Locations get_locations_in_small_component() | inline Locations get_locations_in_small_component() | ||||||
| { | { | ||||||
|     return {{Longitude{7.437246}, Latitude{43.747225}}, |     return {{Longitude{7.438023}, Latitude{43.746465}}, | ||||||
|             {Longitude{7.438023}, Latitude{43.746465}}, |  | ||||||
|             {Longitude{7.439263}, Latitude{43.746543}}, |             {Longitude{7.439263}, Latitude{43.746543}}, | ||||||
|             {Longitude{7.438190}, Latitude{43.747560}}}; |             {Longitude{7.438190}, Latitude{43.747560}}}; | ||||||
| } | } | ||||||
|  | |||||||
| @ -79,4 +79,38 @@ BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates) | |||||||
|     BOOST_CHECK_EQUAL(code, "InvalidOptions"); |     BOOST_CHECK_EQUAL(code, "InvalidOptions"); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | BOOST_AUTO_TEST_CASE(test_nearest_response_for_location_in_small_component) | ||||||
|  | { | ||||||
|  |     const auto args = get_args(); | ||||||
|  |     auto osrm = get_osrm(args.at(0)); | ||||||
|  | 
 | ||||||
|  |     using namespace osrm; | ||||||
|  | 
 | ||||||
|  |     const auto locations = get_locations_in_small_component(); | ||||||
|  | 
 | ||||||
|  |     NearestParameters params; | ||||||
|  |     params.coordinates.push_back(locations.at(0)); | ||||||
|  |     params.number_of_results = 3; | ||||||
|  | 
 | ||||||
|  |     json::Object result; | ||||||
|  |     const auto rc = osrm.Nearest(params, result); | ||||||
|  |     BOOST_REQUIRE(rc == Status::Ok); | ||||||
|  | 
 | ||||||
|  |     const auto code = result.values.at("code").get<json::String>().value; | ||||||
|  |     BOOST_CHECK_EQUAL(code, "ok"); | ||||||
|  | 
 | ||||||
|  |     const auto &waypoints = result.values.at("waypoints").get<json::Array>().values; | ||||||
|  |     BOOST_CHECK(!waypoints.empty()); | ||||||
|  | 
 | ||||||
|  |     for (const auto &waypoint : waypoints) | ||||||
|  |     { | ||||||
|  |         const auto &waypoint_object = waypoint.get<json::Object>(); | ||||||
|  | 
 | ||||||
|  |         // Everything within ~20m (actually more) is still in small component.
 | ||||||
|  |         // Nearest service should snap to road network without considering components.
 | ||||||
|  |         const auto distance = waypoint_object.values.at("distance").get<json::Number>().value; | ||||||
|  |         BOOST_CHECK_LT(distance, 20); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user