From 4f467050267ed012f761160bb27a6186cedb0339 Mon Sep 17 00:00:00 2001 From: Siarhei Fedartsou Date: Sat, 25 May 2024 16:32:36 +0200 Subject: [PATCH] wip --- CMakeLists.txt | 2 +- example/example.cpp | 4 +- include/engine/api/base_result.hpp | 4 +- include/engine/api/match_api.hpp | 6 +- include/engine/api/nearest_api.hpp | 6 +- include/engine/api/route_api.hpp | 14 +-- include/engine/api/table_api.hpp | 6 +- include/engine/api/trip_api.hpp | 6 +- include/engine/plugins/plugin_base.hpp | 2 +- include/nodejs/json_v8_renderer.hpp | 4 +- include/nodejs/node_osrm_support.hpp | 2 +- include/util/geojson_debug_logger.hpp | 3 +- include/util/json_container.hpp | 12 +-- include/util/json_deep_compare.hpp | 6 +- include/util/json_renderer.hpp | 50 +++++------ src/benchmarks/json_render.cpp | 2 +- src/benchmarks/match.cpp | 2 +- src/benchmarks/route.cpp | 2 +- src/engine/plugins/tile.cpp | 2 +- .../routing_algorithms/routing_base_mld.cpp | 60 +++++++++++++ src/nodejs/node_osrm.cpp | 6 +- src/osrm/osrm.cpp | 12 +-- src/server/request_handler.cpp | 21 ++--- src/server/service/match_service.cpp | 2 +- src/server/service/nearest_service.cpp | 2 +- src/server/service/route_service.cpp | 2 +- src/server/service/table_service.cpp | 2 +- src/server/service/tile_service.cpp | 4 +- src/server/service/trip_service.cpp | 4 +- src/server/service_handler.cpp | 4 +- unit_tests/library/limits.cpp | 24 +++--- unit_tests/library/match.cpp | 16 ++-- unit_tests/library/nearest.cpp | 24 +++--- unit_tests/library/route.cpp | 86 +++++++++---------- unit_tests/library/table.cpp | 14 +-- unit_tests/library/tile.cpp | 2 +- unit_tests/library/trip.cpp | 66 +++++++------- unit_tests/library/waypoint_check.hpp | 8 +- 38 files changed, 278 insertions(+), 216 deletions(-) create mode 100644 src/engine/routing_algorithms/routing_base_mld.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fb135888bd0..b57f0f20ae9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -359,7 +359,7 @@ if(ENABLE_CONAN) KEEP_RPATHS NO_OUTPUT_DIRS OPTIONS boost:filesystem_version=3 # https://stackoverflow.com/questions/73392648/error-with-boost-filesystem-version-in-cmake - onetbb:shared=${TBB_SHARED} + # onetbb:shared=${TBB_SHARED} boost:without_stacktrace=True # Apple Silicon cross-compilation fails without it BUILD missing ) diff --git a/example/example.cpp b/example/example.cpp index 108fc622e18..7a43deeccf9 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -57,7 +57,7 @@ int main(int argc, const char *argv[]) // Execute routing request, this does the heavy lifting const auto status = osrm.Route(params, result); - auto &json_result = result.get(); + auto &json_result = std::get(result); if (status == Status::Ok) { auto &routes = json_result.values["routes"].get(); @@ -80,7 +80,7 @@ int main(int argc, const char *argv[]) } else if (status == Status::Error) { - const auto code = json_result.values["code"].get().value; + const auto code = std::get(json_result.values["code"]).value; const auto message = json_result.values["message"].get().value; std::cout << "Code: " << code << "\n"; diff --git a/include/engine/api/base_result.hpp b/include/engine/api/base_result.hpp index 32887159588..801066a9dc0 100644 --- a/include/engine/api/base_result.hpp +++ b/include/engine/api/base_result.hpp @@ -2,7 +2,7 @@ #define ENGINE_API_BASE_RESULT_HPP #include -#include +#include #include @@ -11,7 +11,7 @@ namespace osrm::engine::api { using ResultT = - mapbox::util::variant; + std::variant; } // namespace osrm::engine::api #endif diff --git a/include/engine/api/match_api.hpp b/include/engine/api/match_api.hpp index 1a6172abf8e..012c011763e 100644 --- a/include/engine/api/match_api.hpp +++ b/include/engine/api/match_api.hpp @@ -30,14 +30,14 @@ class MatchAPI final : public RouteAPI osrm::engine::api::ResultT &response) const { BOOST_ASSERT(sub_matchings.size() == sub_routes.size()); - if (response.is()) + if (std::holds_alternative(response)) { - auto &fb_result = response.get(); + auto &fb_result = std::get(response); MakeResponse(sub_matchings, sub_routes, fb_result); } else { - auto &json_result = response.get(); + auto &json_result = std::get(response); MakeResponse(sub_matchings, sub_routes, json_result); } } diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index 53ea1fd4360..32a5898d3db 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -29,14 +29,14 @@ class NearestAPI final : public BaseAPI BOOST_ASSERT(phantom_nodes.size() == 1); BOOST_ASSERT(parameters.coordinates.size() == 1); - if (response.is()) + if (std::holds_alternative(response)) { - auto &fb_result = response.get(); + auto &fb_result = std::get(response); MakeResponse(phantom_nodes, fb_result); } else { - auto &json_result = response.get(); + auto &json_result = std::get(response); MakeResponse(phantom_nodes, json_result); } } diff --git a/include/engine/api/route_api.hpp b/include/engine/api/route_api.hpp index cbff9ce3b54..7f5c74da278 100644 --- a/include/engine/api/route_api.hpp +++ b/include/engine/api/route_api.hpp @@ -50,14 +50,14 @@ class RouteAPI : public BaseAPI { BOOST_ASSERT(!raw_routes.routes.empty()); - if (response.is()) + if (std::holds_alternative(response)) { - auto &fb_result = response.get(); + auto &fb_result = std::get(response); MakeResponse(raw_routes, waypoint_candidates, fb_result); } else { - auto &json_result = response.get(); + auto &json_result = std::get(response); MakeResponse(raw_routes, waypoint_candidates, json_result); } } @@ -158,7 +158,7 @@ class RouteAPI : public BaseAPI } template - mapbox::util::variant, + std::variant, flatbuffers::Offset>> MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const { @@ -408,7 +408,7 @@ class RouteAPI : public BaseAPI // Fill geometry auto overview = MakeOverview(leg_geometries); - mapbox::util::variant, + std::variant, flatbuffers::Offset>> geometry; if (overview) @@ -426,7 +426,7 @@ class RouteAPI : public BaseAPI routeObject.add_legs(legs_vector); if (overview) { - mapbox::util::apply_visitor(GeometryVisitor(routeObject), + std::visit(GeometryVisitor(routeObject), geometry); } @@ -645,7 +645,7 @@ class RouteAPI : public BaseAPI stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string); stepBuilder.add_intersections(intersections_vector); stepBuilder.add_maneuver(maneuver_buffer); - mapbox::util::apply_visitor(GeometryVisitor(stepBuilder), geometry); + std::visit(GeometryVisitor(stepBuilder), geometry); return stepBuilder.Finish(); }; diff --git a/include/engine/api/table_api.hpp b/include/engine/api/table_api.hpp index 20d6a4a23f4..484583ba837 100644 --- a/include/engine/api/table_api.hpp +++ b/include/engine/api/table_api.hpp @@ -50,14 +50,14 @@ class TableAPI final : public BaseAPI const std::vector &fallback_speed_cells, osrm::engine::api::ResultT &response) const { - if (response.is()) + if (std::holds_alternative(response)) { - auto &fb_result = response.get(); + auto &fb_result = std::get(response); MakeResponse(tables, candidates, fallback_speed_cells, fb_result); } else { - auto &json_result = response.get(); + auto &json_result = std::get(response); MakeResponse(tables, candidates, fallback_speed_cells, json_result); } } diff --git a/include/engine/api/trip_api.hpp b/include/engine/api/trip_api.hpp index d7a4ab69c06..2f821cc1bc5 100644 --- a/include/engine/api/trip_api.hpp +++ b/include/engine/api/trip_api.hpp @@ -27,14 +27,14 @@ class TripAPI final : public RouteAPI { BOOST_ASSERT(sub_trips.size() == sub_routes.size()); - if (response.is()) + if (std::holds_alternative(response)) { - auto &fb_result = response.get(); + auto &fb_result = std::get(response); MakeResponse(sub_trips, sub_routes, candidates, fb_result); } else { - auto &json_result = response.get(); + auto &json_result = std::get(response); MakeResponse(sub_trips, sub_routes, candidates, json_result); } } diff --git a/include/engine/plugins/plugin_base.hpp b/include/engine/plugins/plugin_base.hpp index 5fb0ffc58b8..3a98022e98f 100644 --- a/include/engine/plugins/plugin_base.hpp +++ b/include/engine/plugins/plugin_base.hpp @@ -95,7 +95,7 @@ class BasePlugin const std::string &message, osrm::engine::api::ResultT &result) const { - mapbox::util::apply_visitor(ErrorRenderer(code, message), result); + std::visit(ErrorRenderer(code, message), result); return Status::Error; } diff --git a/include/nodejs/json_v8_renderer.hpp b/include/nodejs/json_v8_renderer.hpp index 4b8bbd193d8..9572744c2a0 100644 --- a/include/nodejs/json_v8_renderer.hpp +++ b/include/nodejs/json_v8_renderer.hpp @@ -29,7 +29,7 @@ struct V8Renderer for (const auto &keyValue : object.values) { Napi::Value child; - mapbox::util::apply_visitor(V8Renderer(env, child), keyValue.second); + std::visit(V8Renderer(env, child), keyValue.second); obj.Set(keyValue.first, child); } out = obj; @@ -41,7 +41,7 @@ struct V8Renderer for (auto i = 0u; i < array.values.size(); ++i) { Napi::Value child; - mapbox::util::apply_visitor(V8Renderer(env, child), array.values[i]); + std::visit(V8Renderer(env, child), array.values[i]); a.Set(i, child); } out = a; diff --git a/include/nodejs/node_osrm_support.hpp b/include/nodejs/node_osrm_support.hpp index f69d8e81303..e4f9f8c97c8 100644 --- a/include/nodejs/node_osrm_support.hpp +++ b/include/nodejs/node_osrm_support.hpp @@ -72,7 +72,7 @@ template <> Napi::Value inline render(const Napi::Env &env, const ObjectOrString { // Return the string object as a node Buffer return Napi::Buffer::Copy( - env, result.get().data(), result.get().size()); + env, std::get(result).data(), std::get(result).size()); } } diff --git a/include/util/geojson_debug_logger.hpp b/include/util/geojson_debug_logger.hpp index ea86535d5db..cf96083f5ef 100644 --- a/include/util/geojson_debug_logger.hpp +++ b/include/util/geojson_debug_logger.hpp @@ -51,7 +51,8 @@ class GeojsonLogger if (!first) ofs << ",\n\t\t"; - util::json::render(ofs, object.get()); + (void)object; + // util::json::render(ofs, std::get(object)); first = false; } diff --git a/include/util/json_container.hpp b/include/util/json_container.hpp index 27436b7f874..7243a690490 100644 --- a/include/util/json_container.hpp +++ b/include/util/json_container.hpp @@ -31,8 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef JSON_CONTAINER_HPP #define JSON_CONTAINER_HPP -#include - +#include +#include #include #include #include @@ -96,10 +96,10 @@ struct Null * * Dispatch on its type by either by using apply_visitor or its get function. */ -using Value = mapbox::util::variant, - mapbox::util::recursive_wrapper, +using Value = std::variant, + boost::recursive_wrapper, True, False, Null>; diff --git a/include/util/json_deep_compare.hpp b/include/util/json_deep_compare.hpp index 810dcdfad84..f82336ab356 100644 --- a/include/util/json_deep_compare.hpp +++ b/include/util/json_deep_compare.hpp @@ -81,7 +81,7 @@ struct Comparator const auto &rhs_child = rhs.values.find(key)->second; const auto &lhs_child = lhs.values.find(key)->second; - auto is_same = mapbox::util::apply_visitor( + auto is_same = std::visit( Comparator(reason, lhs_path + "." + key, rhs_path + "." + key), lhs_child, rhs_child); @@ -105,7 +105,7 @@ struct Comparator for (auto i = 0UL; i < lhs.values.size(); ++i) { auto is_same = - mapbox::util::apply_visitor(Comparator(reason, + std::visit(Comparator(reason, lhs_path + "[" + std::to_string(i) + "]", rhs_path + "[" + std::to_string(i) + "]"), lhs.values[i], @@ -151,7 +151,7 @@ struct Comparator inline bool compare(const Value &reference, const Value &result, std::string &reason) { - return mapbox::util::apply_visitor( + return std::visit( Comparator(reason, "reference", "result"), reference, result); } } // namespace osrm::util::json diff --git a/include/util/json_renderer.hpp b/include/util/json_renderer.hpp index aba5c2e4e02..cbe42c81b56 100644 --- a/include/util/json_renderer.hpp +++ b/include/util/json_renderer.hpp @@ -59,35 +59,35 @@ template struct Renderer write(buffer.data(), buffer.size()); } - void operator()(const Object &object) + void operator()(const boost::recursive_wrapper &) { - write('{'); - for (auto it = object.values.begin(), end = object.values.end(); it != end;) - { - write('\"'); - write(it->first); - write<>("\":"); - mapbox::util::apply_visitor(Renderer(out), it->second); - if (++it != end) - { - write(','); - } - } - write('}'); + // write('{'); + // for (auto it = object.values.begin(), end = object.values.end(); it != end;) + // { + // write('\"'); + // write(it->first); + // write<>("\":"); + // std::visit(Renderer(out), it->second); + // if (++it != end) + // { + // write(','); + // } + // } + // write('}'); } - void operator()(const Array &array) + void operator()(const boost::recursive_wrapper &) { - write('['); - for (auto it = array.values.cbegin(), end = array.values.cend(); it != end;) - { - mapbox::util::apply_visitor(Renderer(out), *it); - if (++it != end) - { - write(','); - } - } - write(']'); + // write('['); + // for (auto it = array.values.cbegin(), end = array.values.cend(); it != end;) + // { + // std::visit(Renderer(out), *it); + // if (++it != end) + // { + // write(','); + // } + // } + // write(']'); } void operator()(const True &) { write<>("true"); } diff --git a/src/benchmarks/json_render.cpp b/src/benchmarks/json_render.cpp index d9d3c3cacac..d2c00b51f07 100644 --- a/src/benchmarks/json_render.cpp +++ b/src/benchmarks/json_render.cpp @@ -86,7 +86,7 @@ json::Object load(const char *filename) json::Value result; convert(document, result); - return result.get(); + return std::get(result); } } // namespace diff --git a/src/benchmarks/match.cpp b/src/benchmarks/match.cpp index cece7960b10..5292f1691c4 100644 --- a/src/benchmarks/match.cpp +++ b/src/benchmarks/match.cpp @@ -232,7 +232,7 @@ try { engine::api::ResultT result = json::Object(); const auto rc = osrm.Match(params, result); - auto &json_result = result.get(); + auto &json_result = std::get(result); if (rc != Status::Ok || json_result.values.at("matchings").get().values.size() != 1) { diff --git a/src/benchmarks/route.cpp b/src/benchmarks/route.cpp index ea95d06fbff..def90c17524 100644 --- a/src/benchmarks/route.cpp +++ b/src/benchmarks/route.cpp @@ -76,7 +76,7 @@ try { engine::api::ResultT result = json::Object(); const auto rc = osrm.Route(params, result); - auto &json_result = result.get(); + auto &json_result = std::get(result); if (rc != Status::Ok || json_result.values.find("routes") == json_result.values.end()) { throw std::runtime_error{"Couldn't route"}; diff --git a/src/engine/plugins/tile.cpp b/src/engine/plugins/tile.cpp index 17f896b6d9e..c4d32facbcf 100644 --- a/src/engine/plugins/tile.cpp +++ b/src/engine/plugins/tile.cpp @@ -663,7 +663,7 @@ Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms, { BOOST_ASSERT(parameters.IsValid()); - auto &pbf_buffer = result.get(); + auto &pbf_buffer = std::get(result); const auto &facade = algorithms.GetFacade(); auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z); auto segregated_nodes = getSegregatedNodes(facade, edges); diff --git a/src/engine/routing_algorithms/routing_base_mld.cpp b/src/engine/routing_algorithms/routing_base_mld.cpp new file mode 100644 index 00000000000..f5babeb844b --- /dev/null +++ b/src/engine/routing_algorithms/routing_base_mld.cpp @@ -0,0 +1,60 @@ +#include "engine/routing_algorithms/routing_base_mld.hpp" + +namespace osrm::engine::routing_algorithms::mld +{ +double getNetworkDistance(SearchEngineData &engine_working_data, + const DataFacade &facade, + typename SearchEngineData::QueryHeap &forward_heap, + typename SearchEngineData::QueryHeap &reverse_heap, + const PhantomNode &source_phantom, + const PhantomNode &target_phantom, + EdgeWeight weight_upper_bound) +{ + forward_heap.Clear(); + reverse_heap.Clear(); + + const PhantomEndpoints endpoints{source_phantom, target_phantom}; + insertNodesInHeaps(forward_heap, reverse_heap, endpoints); + + auto [weight, unpacked_nodes, unpacked_edges] = search( + engine_working_data, facade, forward_heap, reverse_heap, {}, weight_upper_bound, endpoints); + + if (weight == INVALID_EDGE_WEIGHT) + { + return std::numeric_limits::max(); + } + + BOOST_ASSERT(unpacked_nodes.size() >= 1); + + EdgeDistance distance = {0.0}; + + if (source_phantom.forward_segment_id.id == unpacked_nodes.front()) + { + BOOST_ASSERT(source_phantom.forward_segment_id.enabled); + distance = EdgeDistance{0} - source_phantom.GetForwardDistance(); + } + else if (source_phantom.reverse_segment_id.id == unpacked_nodes.front()) + { + BOOST_ASSERT(source_phantom.reverse_segment_id.enabled); + distance = EdgeDistance{0} - source_phantom.GetReverseDistance(); + } + + for (size_t index = 0; index < unpacked_nodes.size() - 1; ++index) + { + distance += facade.GetNodeDistance(unpacked_nodes[index]); + } + + if (target_phantom.forward_segment_id.id == unpacked_nodes.back()) + { + BOOST_ASSERT(target_phantom.forward_segment_id.enabled); + distance += target_phantom.GetForwardDistance(); + } + else if (target_phantom.reverse_segment_id.id == unpacked_nodes.back()) + { + BOOST_ASSERT(target_phantom.reverse_segment_id.enabled); + distance += target_phantom.GetReverseDistance(); + } + + return from_alias(distance); +} +} // namespace osrm::engine::routing_algorithms::mld diff --git a/src/nodejs/node_osrm.cpp b/src/nodejs/node_osrm.cpp index 320aaa84941..80aa06e89fa 100644 --- a/src/nodejs/node_osrm.cpp +++ b/src/nodejs/node_osrm.cpp @@ -165,7 +165,7 @@ inline void async(const Napi::CallbackInfo &info, { osrm::engine::api::ResultT r = flatbuffers::FlatBufferBuilder(); const auto status = ((*osrm).*(service))(*params, r); - const auto &fbs_result = r.get(); + const auto &fbs_result = std::get(r); ParseResult(status, fbs_result); BOOST_ASSERT(pluginParams.renderToBuffer); std::string result_str( @@ -240,7 +240,7 @@ inline void asyncForTiles(const Napi::CallbackInfo &info, { result = std::string(); const auto status = ((*osrm).*(service))(*params, result); - auto str_result = result.get(); + auto str_result = std::get(result); ParseResult(status, str_result); } catch (const std::exception &e) @@ -252,7 +252,7 @@ inline void asyncForTiles(const Napi::CallbackInfo &info, { Napi::HandleScope scope{Env()}; - Callback().Call({Env().Null(), render(Env(), result.get())}); + Callback().Call({Env().Null(), render(Env(), std::get(result))}); } // Keeps the OSRM object alive even after shutdown until we're done with callback diff --git a/src/osrm/osrm.cpp b/src/osrm/osrm.cpp index 83e1076f7e7..cf961d5fbc4 100644 --- a/src/osrm/osrm.cpp +++ b/src/osrm/osrm.cpp @@ -65,7 +65,7 @@ Status OSRM::Route(const engine::api::RouteParameters ¶ms, json::Object &jso { osrm::engine::api::ResultT result = json::Object(); auto status = engine_->Route(params, result); - json_result = std::move(result.get()); + json_result = std::move(std::get(result)); return status; } @@ -78,7 +78,7 @@ Status OSRM::Table(const engine::api::TableParameters ¶ms, json::Object &jso { osrm::engine::api::ResultT result = json::Object(); auto status = engine_->Table(params, result); - json_result = std::move(result.get()); + json_result = std::move(std::get(result)); return status; } @@ -91,7 +91,7 @@ Status OSRM::Nearest(const engine::api::NearestParameters ¶ms, json::Object { osrm::engine::api::ResultT result = json::Object(); auto status = engine_->Nearest(params, result); - json_result = std::move(result.get()); + json_result = std::move(std::get(result)); return status; } @@ -104,7 +104,7 @@ Status OSRM::Trip(const engine::api::TripParameters ¶ms, json::Object &json_ { osrm::engine::api::ResultT result = json::Object(); auto status = engine_->Trip(params, result); - json_result = std::move(result.get()); + json_result = std::move(std::get(result)); return status; } @@ -118,7 +118,7 @@ Status OSRM::Match(const engine::api::MatchParameters ¶ms, json::Object &jso { osrm::engine::api::ResultT result = json::Object(); auto status = engine_->Match(params, result); - json_result = std::move(result.get()); + json_result = std::move(std::get(result)); return status; } @@ -131,7 +131,7 @@ Status OSRM::Tile(const engine::api::TileParameters ¶ms, std::string &str_re { osrm::engine::api::ResultT result = std::string(); auto status = engine_->Tile(params, result); - str_result = std::move(result.get()); + str_result = std::move(std::get(result)); return status; } diff --git a/src/server/request_handler.cpp b/src/server/request_handler.cpp index 78408865d5b..284df6fd2b8 100644 --- a/src/server/request_handler.cpp +++ b/src/server/request_handler.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace osrm::server { @@ -38,17 +39,17 @@ void SendResponse(ServiceHandler::ResultT &result, http::reply ¤t_reply) current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET"); current_reply.headers.emplace_back("Access-Control-Allow-Headers", "X-Requested-With, Content-Type"); - if (result.is()) + if (std::holds_alternative(result)) { current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8"); current_reply.headers.emplace_back("Content-Disposition", "inline; filename=\"response.json\""); - util::json::render(current_reply.content, result.get()); + util::json::render(current_reply.content, std::get(result)); } - else if (result.is()) + else if (std::holds_alternative(result)) { - auto &buffer = result.get(); + auto &buffer = std::get(result); current_reply.content.resize(buffer.GetSize()); std::copy(buffer.GetBufferPointer(), buffer.GetBufferPointer() + buffer.GetSize(), @@ -59,10 +60,10 @@ void SendResponse(ServiceHandler::ResultT &result, http::reply ¤t_reply) } else { - BOOST_ASSERT(result.is()); - current_reply.content.resize(result.get().size()); - std::copy(result.get().cbegin(), - result.get().cend(), + BOOST_ASSERT(std::holds_alternative(result)); + current_reply.content.resize(std::get(result).size()); + std::copy(std::get(result).cbegin(), + std::get(result).cend(), current_reply.content.begin()); current_reply.headers.emplace_back("Content-Type", "application/x-protobuf"); @@ -127,7 +128,7 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r current_reply.status = http::reply::bad_request; result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidUrl"; json_result.values["message"] = "URL string malformed close to position " + std::to_string(position) + ": \"" + context + "\""; @@ -174,7 +175,7 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r current_reply.status = http::reply::bad_request; ServiceHandler::ResultT result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "DisabledDataset"; json_result.values["message"] = e.what(); SendResponse(result, current_reply); diff --git a/src/server/service/match_service.cpp b/src/server/service/match_service.cpp index 3a74ec90bb8..22b48245462 100644 --- a/src/server/service/match_service.cpp +++ b/src/server/service/match_service.cpp @@ -42,7 +42,7 @@ engine::Status MatchService::RunQuery(std::size_t prefix_length, osrm::engine::api::ResultT &result) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); auto query_iterator = query.begin(); auto parameters = diff --git a/src/server/service/nearest_service.cpp b/src/server/service/nearest_service.cpp index 28aa75d69da..8eb0d1ea037 100644 --- a/src/server/service/nearest_service.cpp +++ b/src/server/service/nearest_service.cpp @@ -36,7 +36,7 @@ engine::Status NearestService::RunQuery(std::size_t prefix_length, osrm::engine::api::ResultT &result) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); auto query_iterator = query.begin(); auto parameters = diff --git a/src/server/service/route_service.cpp b/src/server/service/route_service.cpp index f5b61e82ae8..a651ab9f763 100644 --- a/src/server/service/route_service.cpp +++ b/src/server/service/route_service.cpp @@ -40,7 +40,7 @@ engine::Status RouteService::RunQuery(std::size_t prefix_length, osrm::engine::api::ResultT &result) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); auto query_iterator = query.begin(); auto parameters = diff --git a/src/server/service/table_service.cpp b/src/server/service/table_service.cpp index 27341f6aa97..719218bd055 100644 --- a/src/server/service/table_service.cpp +++ b/src/server/service/table_service.cpp @@ -71,7 +71,7 @@ engine::Status TableService::RunQuery(std::size_t prefix_length, osrm::engine::api::ResultT &result) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); auto query_iterator = query.begin(); auto parameters = diff --git a/src/server/service/tile_service.cpp b/src/server/service/tile_service.cpp index d90a0861d4e..ba256cdc668 100644 --- a/src/server/service/tile_service.cpp +++ b/src/server/service/tile_service.cpp @@ -22,7 +22,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length, { const auto position = std::distance(query.begin(), query_iterator); result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidQuery"; json_result.values["message"] = "Query string malformed close to position " + std::to_string(prefix_length + position); @@ -33,7 +33,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length, if (!parameters->IsValid()) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidOptions"; json_result.values["message"] = "Invalid coodinates. Only zoomlevel 12+ is supported"; return engine::Status::Error; diff --git a/src/server/service/trip_service.cpp b/src/server/service/trip_service.cpp index a9e44b89687..633a8b606f3 100644 --- a/src/server/service/trip_service.cpp +++ b/src/server/service/trip_service.cpp @@ -42,7 +42,7 @@ engine::Status TripService::RunQuery(std::size_t prefix_length, osrm::engine::api::ResultT &result) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); auto query_iterator = query.begin(); auto parameters = @@ -51,7 +51,7 @@ engine::Status TripService::RunQuery(std::size_t prefix_length, { const auto position = std::distance(query.begin(), query_iterator); result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidQuery"; json_result.values["message"] = "Query string malformed close to position " + std::to_string(prefix_length + position); diff --git a/src/server/service_handler.cpp b/src/server/service_handler.cpp index 675c3be099c..d7ee9112692 100644 --- a/src/server/service_handler.cpp +++ b/src/server/service_handler.cpp @@ -31,7 +31,7 @@ engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, if (service_iter == service_map.end()) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidService"; json_result.values["message"] = "Service " + parsed_url.service + " not found!"; return engine::Status::Error; @@ -41,7 +41,7 @@ engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, if (service->GetVersion() != parsed_url.version) { result = util::json::Object(); - auto &json_result = result.get(); + auto &json_result = std::get(result); json_result.values["code"] = "InvalidVersion"; json_result.values["message"] = "Service " + parsed_url.service + " not found!"; return engine::Status::Error; diff --git a/unit_tests/library/limits.cpp b/unit_tests/library/limits.cpp index 8db7ff24b3f..cedbef4cb09 100644 --- a/unit_tests/library/limits.cpp +++ b/unit_tests/library/limits.cpp @@ -45,8 +45,8 @@ BOOST_AUTO_TEST_CASE(test_trip_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } @@ -73,8 +73,8 @@ BOOST_AUTO_TEST_CASE(test_route_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } @@ -101,8 +101,8 @@ BOOST_AUTO_TEST_CASE(test_table_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } @@ -129,8 +129,8 @@ BOOST_AUTO_TEST_CASE(test_match_coordinate_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } @@ -162,8 +162,8 @@ BOOST_AUTO_TEST_CASE(test_match_radiuses_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } @@ -189,8 +189,8 @@ BOOST_AUTO_TEST_CASE(test_nearest_limits) BOOST_CHECK(rc == Status::Error); // Make sure we're not accidentally hitting a guard code path before - auto &json_result = result.get(); - const auto code = json_result.values["code"].get().value; + auto &json_result = std::get(result); + const auto code = std::get(json_result.values["code"]).value; BOOST_CHECK(code == "TooBig"); // per the New-Server API spec } diff --git a/unit_tests/library/match.cpp b/unit_tests/library/match.cpp index 741e8e4fd4b..98f4c75c87d 100644 --- a/unit_tests/library/match.cpp +++ b/unit_tests/library/match.cpp @@ -24,7 +24,7 @@ osrm::Status run_match_json(const osrm::OSRM &osrm, } engine::api::ResultT result = json::Object(); auto rc = osrm.Match(params, result); - json_result = result.get(); + json_result = std::get(result); return rc; } @@ -45,7 +45,7 @@ void test_match(bool use_json_only_api) const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); const auto &tracepoints = json_result.values.at("tracepoints").get().values; @@ -58,7 +58,7 @@ void test_match(bool use_json_only_api) if (waypoint.is>()) { BOOST_CHECK(waypoint_check(waypoint)); - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); const auto matchings_index = waypoint_object.values.at("matchings_index").get().value; const auto waypoint_index = @@ -96,7 +96,7 @@ void test_match_skip_waypoints(bool use_json_only_api) const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end()); @@ -118,7 +118,7 @@ void test_match_split(bool use_json_only_api) const auto rc = run_match_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); const auto &tracepoints = json_result.values.at("tracepoints").get().values; @@ -133,7 +133,7 @@ void test_match_split(bool use_json_only_api) if (waypoint.is>()) { BOOST_CHECK(waypoint_check(waypoint)); - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); const auto matchings_index = waypoint_object.values.at("matchings_index").get().value; const auto waypoint_index = @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(test_match_fb_serialization) const auto rc = osrm.Match(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); @@ -215,7 +215,7 @@ BOOST_AUTO_TEST_CASE(test_match_fb_serialization_skip_waypoints) const auto rc = osrm.Match(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); diff --git a/unit_tests/library/nearest.cpp b/unit_tests/library/nearest.cpp index 249e19387f5..8e061300f72 100644 --- a/unit_tests/library/nearest.cpp +++ b/unit_tests/library/nearest.cpp @@ -41,15 +41,15 @@ void test_nearest_response(bool use_json_only_api) const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); BOOST_REQUIRE(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); const auto distance = waypoint_object.values.at("distance").get().value; BOOST_CHECK(distance >= 0); } @@ -71,7 +71,7 @@ void test_nearest_response_skip_waypoints(bool use_json_only_api) const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); BOOST_REQUIRE(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); @@ -97,7 +97,7 @@ void test_nearest_response_no_coordinates(bool use_json_only_api) const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); BOOST_REQUIRE(rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "InvalidOptions"); } BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates_old_api) @@ -123,7 +123,7 @@ void test_nearest_response_multiple_coordinates(bool use_json_only_api) const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); BOOST_REQUIRE(rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "InvalidOptions"); } BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates_old_api) @@ -151,15 +151,15 @@ void test_nearest_response_for_location_in_small_component(bool use_json_only_ap const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api); BOOST_REQUIRE(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK(!waypoints.empty()); for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); // Everything within ~20m (actually more) is still in small component. // Nearest service should snap to road network without considering components. @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_serialization) const auto rc = osrm.Nearest(params, result); BOOST_REQUIRE(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); @@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_serialization_skip_waypoints) const auto rc = osrm.Nearest(params, result); BOOST_REQUIRE(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); @@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_error) const auto rc = osrm.Nearest(params, result); BOOST_REQUIRE(rc == Status::Error); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(fb->error()); BOOST_CHECK_EQUAL(fb->code()->code()->str(), "InvalidOptions"); diff --git a/unit_tests/library/route.cpp b/unit_tests/library/route.cpp index cc823816d32..575a4f866af 100644 --- a/unit_tests/library/route.cpp +++ b/unit_tests/library/route.cpp @@ -154,48 +154,48 @@ void test_route_same_coordinates(bool use_json_only_api) const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK(waypoints.size() == params.coordinates.size()); for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); // nothing can be said about name, empty or contains name of the street - const auto name = waypoint_object.values.at("name").get().value; + const auto name = std::get(waypoint_object.values.at("name")).value; BOOST_CHECK(((void)name, true)); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); - const auto hint = waypoint_object.values.at("hint").get().value; + const auto hint = std::get(waypoint_object.values.at("hint")).value; BOOST_CHECK(!hint.empty()); } - const auto &routes = json_result.values.at("routes").get().values; + const auto &routes = std::get(json_result.values.at("routes")).values; BOOST_REQUIRE_GT(routes.size(), 0); for (const auto &route : routes) { const auto &route_object = route.get(); - const auto distance = route_object.values.at("distance").get().value; + const auto distance = std::get(route_object.values.at("distance")).value; BOOST_CHECK_EQUAL(distance, 0); - const auto duration = route_object.values.at("duration").get().value; + const auto duration = std::get(route_object.values.at("duration")).value; BOOST_CHECK_EQUAL(duration, 0); // geometries=polyline by default - const auto geometry = route_object.values.at("geometry").get().value; + const auto geometry = std::get(route_object.values.at("geometry")).value; BOOST_CHECK(!geometry.empty()); - const auto &legs = route_object.values.at("legs").get().values; + const auto &legs = std::get(route_object.values.at("legs")).values; BOOST_CHECK(!legs.empty()); for (const auto &leg : legs) @@ -252,8 +252,8 @@ void test_route_same_coordinates(bool use_json_only_api) const auto &intersection_object = intersection.get().values; const auto location = intersection_object.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -309,29 +309,29 @@ void test_route_same_coordinates_no_waypoints(bool use_json_only_api) const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); - const auto &routes = json_result.values.at("routes").get().values; + const auto &routes = std::get(json_result.values.at("routes")).values; BOOST_REQUIRE_GT(routes.size(), 0); for (const auto &route : routes) { const auto &route_object = route.get(); - const auto distance = route_object.values.at("distance").get().value; + const auto distance = std::get(route_object.values.at("distance")).value; BOOST_CHECK_EQUAL(distance, 0); - const auto duration = route_object.values.at("duration").get().value; + const auto duration = std::get(route_object.values.at("duration")).value; BOOST_CHECK_EQUAL(duration, 0); // geometries=polyline by default - const auto geometry = route_object.values.at("geometry").get().value; + const auto geometry = std::get(route_object.values.at("geometry")).value; BOOST_CHECK(!geometry.empty()); - const auto &legs = route_object.values.at("legs").get().values; + const auto &legs = std::get(route_object.values.at("legs")).values; BOOST_CHECK(!legs.empty()); // The rest of legs contents is verified by test_route_same_coordinates @@ -363,19 +363,19 @@ void test_route_response_for_locations_in_small_component(bool use_json_only_api const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); } @@ -406,19 +406,19 @@ void test_route_response_for_locations_in_big_component(bool use_json_only_api) const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); } @@ -451,19 +451,19 @@ void test_route_response_for_locations_across_components(bool use_json_only_api) const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); } @@ -494,7 +494,7 @@ void test_route_user_disables_generating_hints(bool use_json_only_api) BOOST_CHECK(rc == Status::Ok); for (auto waypoint : json_result.values["waypoints"].get().values) - BOOST_CHECK_EQUAL(waypoint.get().values.count("hint"), 0); + BOOST_CHECK_EQUAL(std::get(waypoint).values.count("hint"), 0); } BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints_old_api) { @@ -570,7 +570,7 @@ void test_manual_setting_of_annotations_property(bool use_json_only_api) const auto rc = run_route_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); auto annotations = json_result.values["routes"] @@ -611,7 +611,7 @@ BOOST_AUTO_TEST_CASE(test_route_serialize_fb) const auto rc = osrm.Route(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); @@ -710,7 +710,7 @@ BOOST_AUTO_TEST_CASE(test_route_serialize_fb_skip_waypoints) const auto rc = osrm.Route(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); diff --git a/unit_tests/library/table.cpp b/unit_tests/library/table.cpp index 0fa27d9a1cf..582e08b6ef5 100644 --- a/unit_tests/library/table.cpp +++ b/unit_tests/library/table.cpp @@ -46,7 +46,7 @@ void test_table_three_coords_one_source_one_dest_matrix(bool use_json_only_api) const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); // check that returned durations error is expected size and proportions @@ -115,7 +115,7 @@ void test_table_three_coords_one_source_one_dest_matrix_no_waypoints(bool use_js const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); // check that returned durations error is expected size and proportions @@ -170,7 +170,7 @@ void test_table_three_coords_one_source_matrix(bool use_json_only_api) const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); // check that returned durations error is expected size and proportions @@ -225,7 +225,7 @@ void test_table_three_coordinates_matrix(bool use_json_only_api) const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); // check that returned durations error is expected size and proportions @@ -278,7 +278,7 @@ void test_table_no_segment_for_some_coordinates(bool use_json_only_api) const auto rc = run_table_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Error); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "NoSegment"); const auto message = json_result.values.at("message").get().value; BOOST_CHECK_EQUAL(message, "Could not find a matching segment for coordinate 0"); @@ -312,7 +312,7 @@ BOOST_AUTO_TEST_CASE(test_table_serialiaze_fb) BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); BOOST_CHECK(fb->table() != nullptr); @@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(test_table_serialiaze_fb_no_waypoints) BOOST_CHECK(rc == Status::Ok || rc == Status::Error); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); BOOST_CHECK(fb->table() != nullptr); diff --git a/unit_tests/library/tile.cpp b/unit_tests/library/tile.cpp index 43b74bada2d..703e7755bd1 100644 --- a/unit_tests/library/tile.cpp +++ b/unit_tests/library/tile.cpp @@ -29,7 +29,7 @@ osrm::Status run_tile(const osrm::OSRM &osrm, } osrm::engine::api::ResultT result = std::string(); auto rc = osrm.Tile(params, result); - string_result = result.get(); + string_result = std::get(result); return rc; } diff --git a/unit_tests/library/trip.cpp b/unit_tests/library/trip.cpp index 52308f2e0f0..cb18571ce35 100644 --- a/unit_tests/library/trip.cpp +++ b/unit_tests/library/trip.cpp @@ -44,10 +44,10 @@ void test_roundtrip_response_for_locations_in_small_component(bool use_json_only const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); const auto &trips = json_result.values.at("trips").get().values; @@ -55,11 +55,11 @@ void test_roundtrip_response_for_locations_in_small_component(bool use_json_only for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -95,7 +95,7 @@ void test_roundtrip_response_for_locations_in_small_component_skip_waypoints(boo const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); @@ -127,10 +127,10 @@ void test_roundtrip_response_for_locations_in_big_component(bool use_json_only_a const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); const auto &trips = json_result.values.at("trips").get().values; @@ -138,11 +138,11 @@ void test_roundtrip_response_for_locations_in_big_component(bool use_json_only_a for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -179,10 +179,10 @@ void test_roundtrip_response_for_locations_across_components(bool use_json_only_ const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); const auto &trips = json_result.values.at("trips").get().values; @@ -192,11 +192,11 @@ void test_roundtrip_response_for_locations_across_components(bool use_json_only_ for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -235,10 +235,10 @@ void test_tfse_1(bool use_json_only_api) const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); const auto &trips = json_result.values.at("trips").get().values; @@ -246,11 +246,11 @@ void test_tfse_1(bool use_json_only_api) for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -283,10 +283,10 @@ void test_tfse_2(bool use_json_only_api) const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api); BOOST_CHECK(rc == Status::Ok); - const auto code = json_result.values.at("code").get().value; + const auto code = std::get(json_result.values.at("code")).value; BOOST_CHECK_EQUAL(code, "Ok"); - const auto &waypoints = json_result.values.at("waypoints").get().values; + const auto &waypoints = std::get(json_result.values.at("waypoints")).values; BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); const auto &trips = json_result.values.at("trips").get().values; @@ -294,11 +294,11 @@ void test_tfse_2(bool use_json_only_api) for (const auto &waypoint : waypoints) { - const auto &waypoint_object = waypoint.get(); + const auto &waypoint_object = std::get(waypoint); - const auto location = waypoint_object.values.at("location").get().values; - const auto longitude = location[0].get().value; - const auto latitude = location[1].get().value; + const auto location = std::get(waypoint_object.values.at("location")).values; + const auto longitude = std::get(location[0]).value; + const auto latitude = std::get(location[1]).value; BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(latitude >= -90. && latitude <= 90.); @@ -512,7 +512,7 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_fb_serialization) const auto rc = osrm.Trip(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); @@ -556,7 +556,7 @@ BOOST_AUTO_TEST_CASE(test_roundtrip_response_fb_serialization_skip_waypoints) const auto rc = osrm.Trip(params, result); BOOST_CHECK(rc == Status::Ok); - auto &fb_result = result.get(); + auto &fb_result = std::get(result); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); BOOST_CHECK(!fb->error()); diff --git a/unit_tests/library/waypoint_check.hpp b/unit_tests/library/waypoint_check.hpp index 76e4524f39b..9a84eb16bc8 100644 --- a/unit_tests/library/waypoint_check.hpp +++ b/unit_tests/library/waypoint_check.hpp @@ -14,10 +14,10 @@ inline bool waypoint_check(osrm::json::Value waypoint) { throw util::exception("Must pass in a waypoint object"); } - const auto waypoint_object = waypoint.get(); - const auto waypoint_location = waypoint_object.values.at("location").get().values; - util::FloatLongitude lon{waypoint_location[0].get().value}; - util::FloatLatitude lat{waypoint_location[1].get().value}; + const auto waypoint_object = std::get(waypoint); + const auto waypoint_location = std::get(waypoint_object.values.at("location")).values; + util::FloatLongitude lon{waypoint_std::get(location[0]).value}; + util::FloatLatitude lat{waypoint_std::get(location[1]).value}; util::Coordinate location_coordinate(lon, lat); return location_coordinate.IsValid(); }