| 209 | BOOST_AUTO_TEST_CASE(test_tile_mld_new_api) { test_tile_mld(false); } |
| 210 | |
| 211 | void test_tile_turns(const osrm::OSRM &osrm, bool use_string_only_api) |
| 212 | { |
| 213 | using namespace osrm; |
| 214 | |
| 215 | // Small tile where we can test all the values |
| 216 | TileParameters params{272953, 191177, 19}; |
| 217 | |
| 218 | std::string str_result; |
| 219 | const auto rc = run_tile(osrm, params, str_result, use_string_only_api); |
| 220 | BOOST_CHECK(rc == Status::Ok); |
| 221 | |
| 222 | BOOST_CHECK_GT(str_result.size(), 128); |
| 223 | |
| 224 | vtzero::vector_tile tile{str_result}; |
| 225 | |
| 226 | tile.next_layer(); |
| 227 | auto layer = tile.next_layer(); |
| 228 | BOOST_CHECK_EQUAL(to_string(layer.name()), "turns"); |
| 229 | |
| 230 | std::vector<float> actual_time_turn_penalties; |
| 231 | std::vector<float> actual_weight_turn_penalties; |
| 232 | std::vector<std::string> actual_turn_types; |
| 233 | std::vector<std::string> actual_turn_modifiers; |
| 234 | std::vector<std::int64_t> actual_turn_angles; |
| 235 | std::vector<std::int64_t> actual_turn_bearings; |
| 236 | |
| 237 | while (auto feature = layer.next_feature()) |
| 238 | { |
| 239 | auto props = vtzero::create_properties_map<std::map<std::string, variant_type>>(feature); |
| 240 | |
| 241 | BOOST_CHECK(std::holds_alternative<float>(props["cost"])); |
| 242 | actual_time_turn_penalties.push_back(std::get<float>(props["cost"])); |
| 243 | BOOST_CHECK(std::holds_alternative<float>(props["weight"])); |
| 244 | actual_weight_turn_penalties.push_back(std::get<float>(props["weight"])); |
| 245 | BOOST_CHECK(std::holds_alternative<std::int64_t>(props["turn_angle"])); |
| 246 | actual_turn_angles.push_back(std::get<std::int64_t>(props["turn_angle"])); |
| 247 | BOOST_CHECK(std::holds_alternative<std::int64_t>(props["bearing_in"])); |
| 248 | actual_turn_bearings.push_back(std::get<std::int64_t>(props["bearing_in"])); |
| 249 | BOOST_CHECK(std::holds_alternative<std::string>(props["type"])); |
| 250 | actual_turn_types.push_back(std::get<std::string>(props["type"])); |
| 251 | BOOST_CHECK(std::holds_alternative<std::string>(props["modifier"])); |
| 252 | actual_turn_modifiers.push_back(std::get<std::string>(props["modifier"])); |
| 253 | } |
| 254 | |
| 255 | // Verify that we got the expected turn penalties |
| 256 | std::sort(actual_time_turn_penalties.begin(), actual_time_turn_penalties.end()); |
| 257 | const std::vector<float> expected_time_turn_penalties = { |
| 258 | 0, 0, 0, 0, 0, 0, .1f, .1f, .3f, .4f, 1.2f, 1.9f, 5.3f, 5.5f, 5.8f, 7.1f, 7.2f, 7.2f}; |
| 259 | CHECK_EQUAL_RANGE(actual_time_turn_penalties, expected_time_turn_penalties); |
| 260 | |
| 261 | // Verify that we got the expected turn penalties |
| 262 | std::sort(actual_weight_turn_penalties.begin(), actual_weight_turn_penalties.end()); |
| 263 | const std::vector<float> expected_weight_turn_penalties = { |
| 264 | 0, 0, 0, 0, 0, 0, .1f, .1f, .3f, .4f, 1.2f, 1.9f, 5.3f, 5.5f, 5.8f, 7.1f, 7.2f, 7.2f}; |
| 265 | CHECK_EQUAL_RANGE(actual_weight_turn_penalties, expected_weight_turn_penalties); |
| 266 | |
| 267 | // Verify that we got the expected turn types |
| 268 | std::sort(actual_turn_types.begin(), actual_turn_types.end()); |