This commit is contained in:
Siarhei Fedartsou 2024-05-25 16:32:36 +02:00
parent b7a990d0b5
commit 4f46705026
38 changed files with 278 additions and 216 deletions

View File

@ -359,7 +359,7 @@ if(ENABLE_CONAN)
KEEP_RPATHS KEEP_RPATHS
NO_OUTPUT_DIRS NO_OUTPUT_DIRS
OPTIONS boost:filesystem_version=3 # https://stackoverflow.com/questions/73392648/error-with-boost-filesystem-version-in-cmake 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 boost:without_stacktrace=True # Apple Silicon cross-compilation fails without it
BUILD missing BUILD missing
) )

View File

@ -57,7 +57,7 @@ int main(int argc, const char *argv[])
// Execute routing request, this does the heavy lifting // Execute routing request, this does the heavy lifting
const auto status = osrm.Route(params, result); const auto status = osrm.Route(params, result);
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
if (status == Status::Ok) if (status == Status::Ok)
{ {
auto &routes = json_result.values["routes"].get<json::Array>(); auto &routes = json_result.values["routes"].get<json::Array>();
@ -80,7 +80,7 @@ int main(int argc, const char *argv[])
} }
else if (status == Status::Error) else if (status == Status::Error)
{ {
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
const auto message = json_result.values["message"].get<json::String>().value; const auto message = json_result.values["message"].get<json::String>().value;
std::cout << "Code: " << code << "\n"; std::cout << "Code: " << code << "\n";

View File

@ -2,7 +2,7 @@
#define ENGINE_API_BASE_RESULT_HPP #define ENGINE_API_BASE_RESULT_HPP
#include <flatbuffers/flatbuffers.h> #include <flatbuffers/flatbuffers.h>
#include <mapbox/variant.hpp> #include <variant>
#include <string> #include <string>
@ -11,7 +11,7 @@
namespace osrm::engine::api namespace osrm::engine::api
{ {
using ResultT = using ResultT =
mapbox::util::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>; std::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
} // namespace osrm::engine::api } // namespace osrm::engine::api
#endif #endif

View File

@ -30,14 +30,14 @@ class MatchAPI final : public RouteAPI
osrm::engine::api::ResultT &response) const osrm::engine::api::ResultT &response) const
{ {
BOOST_ASSERT(sub_matchings.size() == sub_routes.size()); BOOST_ASSERT(sub_matchings.size() == sub_routes.size());
if (response.is<flatbuffers::FlatBufferBuilder>()) if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
{ {
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
MakeResponse(sub_matchings, sub_routes, fb_result); MakeResponse(sub_matchings, sub_routes, fb_result);
} }
else else
{ {
auto &json_result = response.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(response);
MakeResponse(sub_matchings, sub_routes, json_result); MakeResponse(sub_matchings, sub_routes, json_result);
} }
} }

View File

@ -29,14 +29,14 @@ class NearestAPI final : public BaseAPI
BOOST_ASSERT(phantom_nodes.size() == 1); BOOST_ASSERT(phantom_nodes.size() == 1);
BOOST_ASSERT(parameters.coordinates.size() == 1); BOOST_ASSERT(parameters.coordinates.size() == 1);
if (response.is<flatbuffers::FlatBufferBuilder>()) if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
{ {
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
MakeResponse(phantom_nodes, fb_result); MakeResponse(phantom_nodes, fb_result);
} }
else else
{ {
auto &json_result = response.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(response);
MakeResponse(phantom_nodes, json_result); MakeResponse(phantom_nodes, json_result);
} }
} }

View File

@ -50,14 +50,14 @@ class RouteAPI : public BaseAPI
{ {
BOOST_ASSERT(!raw_routes.routes.empty()); BOOST_ASSERT(!raw_routes.routes.empty());
if (response.is<flatbuffers::FlatBufferBuilder>()) if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
{ {
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
MakeResponse(raw_routes, waypoint_candidates, fb_result); MakeResponse(raw_routes, waypoint_candidates, fb_result);
} }
else else
{ {
auto &json_result = response.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(response);
MakeResponse(raw_routes, waypoint_candidates, json_result); MakeResponse(raw_routes, waypoint_candidates, json_result);
} }
} }
@ -158,7 +158,7 @@ class RouteAPI : public BaseAPI
} }
template <typename ForwardIter> template <typename ForwardIter>
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>, std::variant<flatbuffers::Offset<flatbuffers::String>,
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>> flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const
{ {
@ -408,7 +408,7 @@ class RouteAPI : public BaseAPI
// Fill geometry // Fill geometry
auto overview = MakeOverview(leg_geometries); auto overview = MakeOverview(leg_geometries);
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>, std::variant<flatbuffers::Offset<flatbuffers::String>,
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>> flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
geometry; geometry;
if (overview) if (overview)
@ -426,7 +426,7 @@ class RouteAPI : public BaseAPI
routeObject.add_legs(legs_vector); routeObject.add_legs(legs_vector);
if (overview) if (overview)
{ {
mapbox::util::apply_visitor(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject), std::visit(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject),
geometry); geometry);
} }
@ -645,7 +645,7 @@ class RouteAPI : public BaseAPI
stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string); stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string);
stepBuilder.add_intersections(intersections_vector); stepBuilder.add_intersections(intersections_vector);
stepBuilder.add_maneuver(maneuver_buffer); stepBuilder.add_maneuver(maneuver_buffer);
mapbox::util::apply_visitor(GeometryVisitor<fbresult::StepBuilder>(stepBuilder), geometry); std::visit(GeometryVisitor<fbresult::StepBuilder>(stepBuilder), geometry);
return stepBuilder.Finish(); return stepBuilder.Finish();
}; };

View File

@ -50,14 +50,14 @@ class TableAPI final : public BaseAPI
const std::vector<TableCellRef> &fallback_speed_cells, const std::vector<TableCellRef> &fallback_speed_cells,
osrm::engine::api::ResultT &response) const osrm::engine::api::ResultT &response) const
{ {
if (response.is<flatbuffers::FlatBufferBuilder>()) if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
{ {
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
MakeResponse(tables, candidates, fallback_speed_cells, fb_result); MakeResponse(tables, candidates, fallback_speed_cells, fb_result);
} }
else else
{ {
auto &json_result = response.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(response);
MakeResponse(tables, candidates, fallback_speed_cells, json_result); MakeResponse(tables, candidates, fallback_speed_cells, json_result);
} }
} }

View File

@ -27,14 +27,14 @@ class TripAPI final : public RouteAPI
{ {
BOOST_ASSERT(sub_trips.size() == sub_routes.size()); BOOST_ASSERT(sub_trips.size() == sub_routes.size());
if (response.is<flatbuffers::FlatBufferBuilder>()) if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
{ {
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
MakeResponse(sub_trips, sub_routes, candidates, fb_result); MakeResponse(sub_trips, sub_routes, candidates, fb_result);
} }
else else
{ {
auto &json_result = response.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(response);
MakeResponse(sub_trips, sub_routes, candidates, json_result); MakeResponse(sub_trips, sub_routes, candidates, json_result);
} }
} }

View File

@ -95,7 +95,7 @@ class BasePlugin
const std::string &message, const std::string &message,
osrm::engine::api::ResultT &result) const osrm::engine::api::ResultT &result) const
{ {
mapbox::util::apply_visitor(ErrorRenderer(code, message), result); std::visit(ErrorRenderer(code, message), result);
return Status::Error; return Status::Error;
} }

View File

@ -29,7 +29,7 @@ struct V8Renderer
for (const auto &keyValue : object.values) for (const auto &keyValue : object.values)
{ {
Napi::Value child; Napi::Value child;
mapbox::util::apply_visitor(V8Renderer(env, child), keyValue.second); std::visit(V8Renderer(env, child), keyValue.second);
obj.Set(keyValue.first, child); obj.Set(keyValue.first, child);
} }
out = obj; out = obj;
@ -41,7 +41,7 @@ struct V8Renderer
for (auto i = 0u; i < array.values.size(); ++i) for (auto i = 0u; i < array.values.size(); ++i)
{ {
Napi::Value child; 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); a.Set(i, child);
} }
out = a; out = a;

View File

@ -72,7 +72,7 @@ template <> Napi::Value inline render(const Napi::Env &env, const ObjectOrString
{ {
// Return the string object as a node Buffer // Return the string object as a node Buffer
return Napi::Buffer<char>::Copy( return Napi::Buffer<char>::Copy(
env, result.get<std::string>().data(), result.get<std::string>().size()); env, std::get<std::string>(result).data(), std::get<std::string>(result).size());
} }
} }

View File

@ -51,7 +51,8 @@ class GeojsonLogger
if (!first) if (!first)
ofs << ",\n\t\t"; ofs << ",\n\t\t";
util::json::render(ofs, object.get<util::json::Object>()); (void)object;
// util::json::render(ofs, std::get<util::json::Object>(object));
first = false; first = false;
} }

View File

@ -31,8 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef JSON_CONTAINER_HPP #ifndef JSON_CONTAINER_HPP
#define JSON_CONTAINER_HPP #define JSON_CONTAINER_HPP
#include <mapbox/variant.hpp> #include <variant>
#include <boost/variant/recursive_wrapper.hpp>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
@ -96,10 +96,10 @@ struct Null
* *
* Dispatch on its type by either by using apply_visitor or its get function. * Dispatch on its type by either by using apply_visitor or its get function.
*/ */
using Value = mapbox::util::variant<String, using Value = std::variant<String,
Number, Number,
mapbox::util::recursive_wrapper<Object>, boost::recursive_wrapper<Object>,
mapbox::util::recursive_wrapper<Array>, boost::recursive_wrapper<Array>,
True, True,
False, False,
Null>; Null>;

View File

@ -81,7 +81,7 @@ struct Comparator
const auto &rhs_child = rhs.values.find(key)->second; const auto &rhs_child = rhs.values.find(key)->second;
const auto &lhs_child = lhs.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), Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
lhs_child, lhs_child,
rhs_child); rhs_child);
@ -105,7 +105,7 @@ struct Comparator
for (auto i = 0UL; i < lhs.values.size(); ++i) for (auto i = 0UL; i < lhs.values.size(); ++i)
{ {
auto is_same = auto is_same =
mapbox::util::apply_visitor(Comparator(reason, std::visit(Comparator(reason,
lhs_path + "[" + std::to_string(i) + "]", lhs_path + "[" + std::to_string(i) + "]",
rhs_path + "[" + std::to_string(i) + "]"), rhs_path + "[" + std::to_string(i) + "]"),
lhs.values[i], lhs.values[i],
@ -151,7 +151,7 @@ struct Comparator
inline bool compare(const Value &reference, const Value &result, std::string &reason) 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); Comparator(reason, "reference", "result"), reference, result);
} }
} // namespace osrm::util::json } // namespace osrm::util::json

View File

@ -59,35 +59,35 @@ template <typename Out> struct Renderer
write(buffer.data(), buffer.size()); write(buffer.data(), buffer.size());
} }
void operator()(const Object &object) void operator()(const boost::recursive_wrapper<Object> &)
{ {
write('{'); // write('{');
for (auto it = object.values.begin(), end = object.values.end(); it != end;) // for (auto it = object.values.begin(), end = object.values.end(); it != end;)
{ // {
write('\"'); // write('\"');
write(it->first); // write(it->first);
write<>("\":"); // write<>("\":");
mapbox::util::apply_visitor(Renderer(out), it->second); // std::visit(Renderer(out), it->second);
if (++it != end) // if (++it != end)
{ // {
write(','); // write(',');
} // }
} // }
write('}'); // write('}');
} }
void operator()(const Array &array) void operator()(const boost::recursive_wrapper<Array> &)
{ {
write('['); // write('[');
for (auto it = array.values.cbegin(), end = array.values.cend(); it != end;) // for (auto it = array.values.cbegin(), end = array.values.cend(); it != end;)
{ // {
mapbox::util::apply_visitor(Renderer(out), *it); // std::visit(Renderer(out), *it);
if (++it != end) // if (++it != end)
{ // {
write(','); // write(',');
} // }
} // }
write(']'); // write(']');
} }
void operator()(const True &) { write<>("true"); } void operator()(const True &) { write<>("true"); }

View File

@ -86,7 +86,7 @@ json::Object load(const char *filename)
json::Value result; json::Value result;
convert(document, result); convert(document, result);
return result.get<json::Object>(); return std::get<json::Object>(result);
} }
} // namespace } // namespace

View File

@ -232,7 +232,7 @@ try
{ {
engine::api::ResultT result = json::Object(); engine::api::ResultT result = json::Object();
const auto rc = osrm.Match(params, result); const auto rc = osrm.Match(params, result);
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
if (rc != Status::Ok || if (rc != Status::Ok ||
json_result.values.at("matchings").get<json::Array>().values.size() != 1) json_result.values.at("matchings").get<json::Array>().values.size() != 1)
{ {

View File

@ -76,7 +76,7 @@ try
{ {
engine::api::ResultT result = json::Object(); engine::api::ResultT result = json::Object();
const auto rc = osrm.Route(params, result); const auto rc = osrm.Route(params, result);
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
if (rc != Status::Ok || json_result.values.find("routes") == json_result.values.end()) if (rc != Status::Ok || json_result.values.find("routes") == json_result.values.end())
{ {
throw std::runtime_error{"Couldn't route"}; throw std::runtime_error{"Couldn't route"};

View File

@ -663,7 +663,7 @@ Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
{ {
BOOST_ASSERT(parameters.IsValid()); BOOST_ASSERT(parameters.IsValid());
auto &pbf_buffer = result.get<std::string>(); auto &pbf_buffer = std::get<std::string>(result);
const auto &facade = algorithms.GetFacade(); const auto &facade = algorithms.GetFacade();
auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z); auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z);
auto segregated_nodes = getSegregatedNodes(facade, edges); auto segregated_nodes = getSegregatedNodes(facade, edges);

View File

@ -0,0 +1,60 @@
#include "engine/routing_algorithms/routing_base_mld.hpp"
namespace osrm::engine::routing_algorithms::mld
{
double getNetworkDistance(SearchEngineData<mld::Algorithm> &engine_working_data,
const DataFacade<mld::Algorithm> &facade,
typename SearchEngineData<mld::Algorithm>::QueryHeap &forward_heap,
typename SearchEngineData<mld::Algorithm>::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<double>::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<double>(distance);
}
} // namespace osrm::engine::routing_algorithms::mld

View File

@ -165,7 +165,7 @@ inline void async(const Napi::CallbackInfo &info,
{ {
osrm::engine::api::ResultT r = flatbuffers::FlatBufferBuilder(); osrm::engine::api::ResultT r = flatbuffers::FlatBufferBuilder();
const auto status = ((*osrm).*(service))(*params, r); const auto status = ((*osrm).*(service))(*params, r);
const auto &fbs_result = r.get<flatbuffers::FlatBufferBuilder>(); const auto &fbs_result = std::get<flatbuffers::FlatBufferBuilder>(r);
ParseResult(status, fbs_result); ParseResult(status, fbs_result);
BOOST_ASSERT(pluginParams.renderToBuffer); BOOST_ASSERT(pluginParams.renderToBuffer);
std::string result_str( std::string result_str(
@ -240,7 +240,7 @@ inline void asyncForTiles(const Napi::CallbackInfo &info,
{ {
result = std::string(); result = std::string();
const auto status = ((*osrm).*(service))(*params, result); const auto status = ((*osrm).*(service))(*params, result);
auto str_result = result.get<std::string>(); auto str_result = std::get<std::string>(result);
ParseResult(status, str_result); ParseResult(status, str_result);
} }
catch (const std::exception &e) catch (const std::exception &e)
@ -252,7 +252,7 @@ inline void asyncForTiles(const Napi::CallbackInfo &info,
{ {
Napi::HandleScope scope{Env()}; Napi::HandleScope scope{Env()};
Callback().Call({Env().Null(), render(Env(), result.get<std::string>())}); Callback().Call({Env().Null(), render(Env(), std::get<std::string>(result))});
} }
// Keeps the OSRM object alive even after shutdown until we're done with callback // Keeps the OSRM object alive even after shutdown until we're done with callback

View File

@ -65,7 +65,7 @@ Status OSRM::Route(const engine::api::RouteParameters &params, json::Object &jso
{ {
osrm::engine::api::ResultT result = json::Object(); osrm::engine::api::ResultT result = json::Object();
auto status = engine_->Route(params, result); auto status = engine_->Route(params, result);
json_result = std::move(result.get<json::Object>()); json_result = std::move(std::get<json::Object>(result));
return status; return status;
} }
@ -78,7 +78,7 @@ Status OSRM::Table(const engine::api::TableParameters &params, json::Object &jso
{ {
osrm::engine::api::ResultT result = json::Object(); osrm::engine::api::ResultT result = json::Object();
auto status = engine_->Table(params, result); auto status = engine_->Table(params, result);
json_result = std::move(result.get<json::Object>()); json_result = std::move(std::get<json::Object>(result));
return status; return status;
} }
@ -91,7 +91,7 @@ Status OSRM::Nearest(const engine::api::NearestParameters &params, json::Object
{ {
osrm::engine::api::ResultT result = json::Object(); osrm::engine::api::ResultT result = json::Object();
auto status = engine_->Nearest(params, result); auto status = engine_->Nearest(params, result);
json_result = std::move(result.get<json::Object>()); json_result = std::move(std::get<json::Object>(result));
return status; return status;
} }
@ -104,7 +104,7 @@ Status OSRM::Trip(const engine::api::TripParameters &params, json::Object &json_
{ {
osrm::engine::api::ResultT result = json::Object(); osrm::engine::api::ResultT result = json::Object();
auto status = engine_->Trip(params, result); auto status = engine_->Trip(params, result);
json_result = std::move(result.get<json::Object>()); json_result = std::move(std::get<json::Object>(result));
return status; return status;
} }
@ -118,7 +118,7 @@ Status OSRM::Match(const engine::api::MatchParameters &params, json::Object &jso
{ {
osrm::engine::api::ResultT result = json::Object(); osrm::engine::api::ResultT result = json::Object();
auto status = engine_->Match(params, result); auto status = engine_->Match(params, result);
json_result = std::move(result.get<json::Object>()); json_result = std::move(std::get<json::Object>(result));
return status; return status;
} }
@ -131,7 +131,7 @@ Status OSRM::Tile(const engine::api::TileParameters &params, std::string &str_re
{ {
osrm::engine::api::ResultT result = std::string(); osrm::engine::api::ResultT result = std::string();
auto status = engine_->Tile(params, result); auto status = engine_->Tile(params, result);
str_result = std::move(result.get<std::string>()); str_result = std::move(std::get<std::string>(result));
return status; return status;
} }

View File

@ -21,6 +21,7 @@
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <thread> #include <thread>
#include <variant>
namespace osrm::server namespace osrm::server
{ {
@ -38,17 +39,17 @@ void SendResponse(ServiceHandler::ResultT &result, http::reply &current_reply)
current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET"); current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET");
current_reply.headers.emplace_back("Access-Control-Allow-Headers", current_reply.headers.emplace_back("Access-Control-Allow-Headers",
"X-Requested-With, Content-Type"); "X-Requested-With, Content-Type");
if (result.is<util::json::Object>()) if (std::holds_alternative<util::json::Object>(result))
{ {
current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8"); current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8");
current_reply.headers.emplace_back("Content-Disposition", current_reply.headers.emplace_back("Content-Disposition",
"inline; filename=\"response.json\""); "inline; filename=\"response.json\"");
util::json::render(current_reply.content, result.get<util::json::Object>()); util::json::render(current_reply.content, std::get<util::json::Object>(result));
} }
else if (result.is<flatbuffers::FlatBufferBuilder>()) else if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(result))
{ {
auto &buffer = result.get<flatbuffers::FlatBufferBuilder>(); auto &buffer = std::get<flatbuffers::FlatBufferBuilder>(result);
current_reply.content.resize(buffer.GetSize()); current_reply.content.resize(buffer.GetSize());
std::copy(buffer.GetBufferPointer(), std::copy(buffer.GetBufferPointer(),
buffer.GetBufferPointer() + buffer.GetSize(), buffer.GetBufferPointer() + buffer.GetSize(),
@ -59,10 +60,10 @@ void SendResponse(ServiceHandler::ResultT &result, http::reply &current_reply)
} }
else else
{ {
BOOST_ASSERT(result.is<std::string>()); BOOST_ASSERT(std::holds_alternative<std::string>(result));
current_reply.content.resize(result.get<std::string>().size()); current_reply.content.resize(std::get<std::string>(result).size());
std::copy(result.get<std::string>().cbegin(), std::copy(std::get<std::string>(result).cbegin(),
result.get<std::string>().cend(), std::get<std::string>(result).cend(),
current_reply.content.begin()); current_reply.content.begin());
current_reply.headers.emplace_back("Content-Type", "application/x-protobuf"); current_reply.headers.emplace_back("Content-Type", "application/x-protobuf");
@ -127,7 +128,7 @@ void RequestHandler::HandleRequest(const http::request &current_request, http::r
current_reply.status = http::reply::bad_request; current_reply.status = http::reply::bad_request;
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidUrl"; json_result.values["code"] = "InvalidUrl";
json_result.values["message"] = "URL string malformed close to position " + json_result.values["message"] = "URL string malformed close to position " +
std::to_string(position) + ": \"" + context + "\""; std::to_string(position) + ": \"" + context + "\"";
@ -174,7 +175,7 @@ void RequestHandler::HandleRequest(const http::request &current_request, http::r
current_reply.status = http::reply::bad_request; current_reply.status = http::reply::bad_request;
ServiceHandler::ResultT result = util::json::Object(); ServiceHandler::ResultT result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "DisabledDataset"; json_result.values["code"] = "DisabledDataset";
json_result.values["message"] = e.what(); json_result.values["message"] = e.what();
SendResponse(result, current_reply); SendResponse(result, current_reply);

View File

@ -42,7 +42,7 @@ engine::Status MatchService::RunQuery(std::size_t prefix_length,
osrm::engine::api::ResultT &result) osrm::engine::api::ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -36,7 +36,7 @@ engine::Status NearestService::RunQuery(std::size_t prefix_length,
osrm::engine::api::ResultT &result) osrm::engine::api::ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -40,7 +40,7 @@ engine::Status RouteService::RunQuery(std::size_t prefix_length,
osrm::engine::api::ResultT &result) osrm::engine::api::ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -71,7 +71,7 @@ engine::Status TableService::RunQuery(std::size_t prefix_length,
osrm::engine::api::ResultT &result) osrm::engine::api::ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -22,7 +22,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length,
{ {
const auto position = std::distance(query.begin(), query_iterator); const auto position = std::distance(query.begin(), query_iterator);
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidQuery"; json_result.values["code"] = "InvalidQuery";
json_result.values["message"] = json_result.values["message"] =
"Query string malformed close to position " + std::to_string(prefix_length + position); "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()) if (!parameters->IsValid())
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidOptions"; json_result.values["code"] = "InvalidOptions";
json_result.values["message"] = "Invalid coodinates. Only zoomlevel 12+ is supported"; json_result.values["message"] = "Invalid coodinates. Only zoomlevel 12+ is supported";
return engine::Status::Error; return engine::Status::Error;

View File

@ -42,7 +42,7 @@ engine::Status TripService::RunQuery(std::size_t prefix_length,
osrm::engine::api::ResultT &result) osrm::engine::api::ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =
@ -51,7 +51,7 @@ engine::Status TripService::RunQuery(std::size_t prefix_length,
{ {
const auto position = std::distance(query.begin(), query_iterator); const auto position = std::distance(query.begin(), query_iterator);
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidQuery"; json_result.values["code"] = "InvalidQuery";
json_result.values["message"] = json_result.values["message"] =
"Query string malformed close to position " + std::to_string(prefix_length + position); "Query string malformed close to position " + std::to_string(prefix_length + position);

View File

@ -31,7 +31,7 @@ engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
if (service_iter == service_map.end()) if (service_iter == service_map.end())
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidService"; json_result.values["code"] = "InvalidService";
json_result.values["message"] = "Service " + parsed_url.service + " not found!"; json_result.values["message"] = "Service " + parsed_url.service + " not found!";
return engine::Status::Error; return engine::Status::Error;
@ -41,7 +41,7 @@ engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
if (service->GetVersion() != parsed_url.version) if (service->GetVersion() != parsed_url.version)
{ {
result = util::json::Object(); result = util::json::Object();
auto &json_result = result.get<util::json::Object>(); auto &json_result = std::get<util::json::Object>(result);
json_result.values["code"] = "InvalidVersion"; json_result.values["code"] = "InvalidVersion";
json_result.values["message"] = "Service " + parsed_url.service + " not found!"; json_result.values["message"] = "Service " + parsed_url.service + " not found!";
return engine::Status::Error; return engine::Status::Error;

View File

@ -45,8 +45,8 @@ BOOST_AUTO_TEST_CASE(test_trip_limits)
BOOST_CHECK(rc == Status::Error); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec 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); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec 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); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec 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); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec 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); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec 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); BOOST_CHECK(rc == Status::Error);
// Make sure we're not accidentally hitting a guard code path before // Make sure we're not accidentally hitting a guard code path before
auto &json_result = result.get<json::Object>(); auto &json_result = std::get<json::Object>(result);
const auto code = json_result.values["code"].get<json::String>().value; const auto code = std::get<json::String>(json_result.values["code"]).value;
BOOST_CHECK(code == "TooBig"); // per the New-Server API spec BOOST_CHECK(code == "TooBig"); // per the New-Server API spec
} }

View File

@ -24,7 +24,7 @@ osrm::Status run_match_json(const osrm::OSRM &osrm,
} }
engine::api::ResultT result = json::Object(); engine::api::ResultT result = json::Object();
auto rc = osrm.Match(params, result); auto rc = osrm.Match(params, result);
json_result = result.get<json::Object>(); json_result = std::get<json::Object>(result);
return rc; 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); const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values; const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values;
@ -58,7 +58,7 @@ void test_match(bool use_json_only_api)
if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>()) if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
{ {
BOOST_CHECK(waypoint_check(waypoint)); BOOST_CHECK(waypoint_check(waypoint));
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto matchings_index = const auto matchings_index =
waypoint_object.values.at("matchings_index").get<json::Number>().value; waypoint_object.values.at("matchings_index").get<json::Number>().value;
const auto waypoint_index = 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); const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("tracepoints") == json_result.values.end()); 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); const auto rc = run_match_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values; const auto &tracepoints = json_result.values.at("tracepoints").get<json::Array>().values;
@ -133,7 +133,7 @@ void test_match_split(bool use_json_only_api)
if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>()) if (waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
{ {
BOOST_CHECK(waypoint_check(waypoint)); BOOST_CHECK(waypoint_check(waypoint));
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto matchings_index = const auto matchings_index =
waypoint_object.values.at("matchings_index").get<json::Number>().value; waypoint_object.values.at("matchings_index").get<json::Number>().value;
const auto waypoint_index = const auto waypoint_index =
@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(test_match_fb_serialization)
const auto rc = osrm.Match(params, result); const auto rc = osrm.Match(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); 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); const auto rc = osrm.Match(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());

View File

@ -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); const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
BOOST_REQUIRE(rc == Status::Ok); BOOST_REQUIRE(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate BOOST_CHECK(!waypoints.empty()); // the dataset has at least one nearest coordinate
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto distance = waypoint_object.values.at("distance").get<json::Number>().value; const auto distance = waypoint_object.values.at("distance").get<json::Number>().value;
BOOST_CHECK(distance >= 0); 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); const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
BOOST_REQUIRE(rc == Status::Ok); BOOST_REQUIRE(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); 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); const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
BOOST_REQUIRE(rc == Status::Error); BOOST_REQUIRE(rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "InvalidOptions"); BOOST_CHECK_EQUAL(code, "InvalidOptions");
} }
BOOST_AUTO_TEST_CASE(test_nearest_response_no_coordinates_old_api) 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); const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
BOOST_REQUIRE(rc == Status::Error); BOOST_REQUIRE(rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "InvalidOptions"); BOOST_CHECK_EQUAL(code, "InvalidOptions");
} }
BOOST_AUTO_TEST_CASE(test_nearest_response_multiple_coordinates_old_api) 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); const auto rc = run_nearest_json(osrm, params, json_result, use_json_only_api);
BOOST_REQUIRE(rc == Status::Ok); BOOST_REQUIRE(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK(!waypoints.empty()); BOOST_CHECK(!waypoints.empty());
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
// Everything within ~20m (actually more) is still in small component. // Everything within ~20m (actually more) is still in small component.
// Nearest service should snap to road network without considering components. // 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); const auto rc = osrm.Nearest(params, result);
BOOST_REQUIRE(rc == Status::Ok); BOOST_REQUIRE(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); 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); const auto rc = osrm.Nearest(params, result);
BOOST_REQUIRE(rc == Status::Ok); BOOST_REQUIRE(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());
@ -243,7 +243,7 @@ BOOST_AUTO_TEST_CASE(test_nearest_fb_error)
const auto rc = osrm.Nearest(params, result); const auto rc = osrm.Nearest(params, result);
BOOST_REQUIRE(rc == Status::Error); BOOST_REQUIRE(rc == Status::Error);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(fb->error()); BOOST_CHECK(fb->error());
BOOST_CHECK_EQUAL(fb->code()->code()->str(), "InvalidOptions"); BOOST_CHECK_EQUAL(fb->code()->code()->str(), "InvalidOptions");

View File

@ -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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK(waypoints.size() == params.coordinates.size()); BOOST_CHECK(waypoints.size() == params.coordinates.size());
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
// nothing can be said about name, empty or contains name of the street // nothing can be said about name, empty or contains name of the street
const auto name = waypoint_object.values.at("name").get<json::String>().value; const auto name = std::get<json::String>(waypoint_object.values.at("name")).value;
BOOST_CHECK(((void)name, true)); BOOST_CHECK(((void)name, true));
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); BOOST_CHECK(latitude >= -90. && latitude <= 90.);
const auto hint = waypoint_object.values.at("hint").get<json::String>().value; const auto hint = std::get<json::String>(waypoint_object.values.at("hint")).value;
BOOST_CHECK(!hint.empty()); BOOST_CHECK(!hint.empty());
} }
const auto &routes = json_result.values.at("routes").get<json::Array>().values; const auto &routes = std::get<json::Array>(json_result.values.at("routes")).values;
BOOST_REQUIRE_GT(routes.size(), 0); BOOST_REQUIRE_GT(routes.size(), 0);
for (const auto &route : routes) for (const auto &route : routes)
{ {
const auto &route_object = route.get<json::Object>(); const auto &route_object = route.get<json::Object>();
const auto distance = route_object.values.at("distance").get<json::Number>().value; const auto distance = std::get<json::Number>(route_object.values.at("distance")).value;
BOOST_CHECK_EQUAL(distance, 0); BOOST_CHECK_EQUAL(distance, 0);
const auto duration = route_object.values.at("duration").get<json::Number>().value; const auto duration = std::get<json::Number>(route_object.values.at("duration")).value;
BOOST_CHECK_EQUAL(duration, 0); BOOST_CHECK_EQUAL(duration, 0);
// geometries=polyline by default // geometries=polyline by default
const auto geometry = route_object.values.at("geometry").get<json::String>().value; const auto geometry = std::get<json::String>(route_object.values.at("geometry")).value;
BOOST_CHECK(!geometry.empty()); BOOST_CHECK(!geometry.empty());
const auto &legs = route_object.values.at("legs").get<json::Array>().values; const auto &legs = std::get<json::Array>(route_object.values.at("legs")).values;
BOOST_CHECK(!legs.empty()); BOOST_CHECK(!legs.empty());
for (const auto &leg : legs) 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<json::Object>().values; const auto &intersection_object = intersection.get<json::Object>().values;
const auto location = const auto location =
intersection_object.at("location").get<json::Array>().values; intersection_object.at("location").get<json::Array>().values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end());
const auto &routes = json_result.values.at("routes").get<json::Array>().values; const auto &routes = std::get<json::Array>(json_result.values.at("routes")).values;
BOOST_REQUIRE_GT(routes.size(), 0); BOOST_REQUIRE_GT(routes.size(), 0);
for (const auto &route : routes) for (const auto &route : routes)
{ {
const auto &route_object = route.get<json::Object>(); const auto &route_object = route.get<json::Object>();
const auto distance = route_object.values.at("distance").get<json::Number>().value; const auto distance = std::get<json::Number>(route_object.values.at("distance")).value;
BOOST_CHECK_EQUAL(distance, 0); BOOST_CHECK_EQUAL(distance, 0);
const auto duration = route_object.values.at("duration").get<json::Number>().value; const auto duration = std::get<json::Number>(route_object.values.at("duration")).value;
BOOST_CHECK_EQUAL(duration, 0); BOOST_CHECK_EQUAL(duration, 0);
// geometries=polyline by default // geometries=polyline by default
const auto geometry = route_object.values.at("geometry").get<json::String>().value; const auto geometry = std::get<json::String>(route_object.values.at("geometry")).value;
BOOST_CHECK(!geometry.empty()); BOOST_CHECK(!geometry.empty());
const auto &legs = route_object.values.at("legs").get<json::Array>().values; const auto &legs = std::get<json::Array>(route_object.values.at("legs")).values;
BOOST_CHECK(!legs.empty()); BOOST_CHECK(!legs.empty());
// The rest of legs contents is verified by test_route_same_coordinates // 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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); BOOST_CHECK(rc == Status::Ok);
for (auto waypoint : json_result.values["waypoints"].get<json::Array>().values) for (auto waypoint : json_result.values["waypoints"].get<json::Array>().values)
BOOST_CHECK_EQUAL(waypoint.get<json::Object>().values.count("hint"), 0); BOOST_CHECK_EQUAL(std::get<json::Object>(waypoint).values.count("hint"), 0);
} }
BOOST_AUTO_TEST_CASE(test_route_user_disables_generating_hints_old_api) 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); const auto rc = run_route_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
auto annotations = json_result.values["routes"] 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); const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); 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); const auto rc = osrm.Route(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());

View File

@ -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); const auto rc = run_table_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
// check that returned durations error is expected size and proportions // 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); const auto rc = run_table_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
// check that returned durations error is expected size and proportions // 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); const auto rc = run_table_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
// check that returned durations error is expected size and proportions // 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); const auto rc = run_table_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok || rc == Status::Error); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
// check that returned durations error is expected size and proportions // 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); const auto rc = run_table_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Error); BOOST_CHECK(rc == Status::Error);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "NoSegment"); BOOST_CHECK_EQUAL(code, "NoSegment");
const auto message = json_result.values.at("message").get<json::String>().value; const auto message = json_result.values.at("message").get<json::String>().value;
BOOST_CHECK_EQUAL(message, "Could not find a matching segment for coordinate 0"); 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); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->table() != nullptr); 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); BOOST_CHECK(rc == Status::Ok || rc == Status::Error);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());
BOOST_CHECK(fb->table() != nullptr); BOOST_CHECK(fb->table() != nullptr);

View File

@ -29,7 +29,7 @@ osrm::Status run_tile(const osrm::OSRM &osrm,
} }
osrm::engine::api::ResultT result = std::string(); osrm::engine::api::ResultT result = std::string();
auto rc = osrm.Tile(params, result); auto rc = osrm.Tile(params, result);
string_result = result.get<std::string>(); string_result = std::get<std::string>(result);
return rc; return rc;
} }

View File

@ -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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
const auto &trips = json_result.values.at("trips").get<json::Array>().values; const auto &trips = json_result.values.at("trips").get<json::Array>().values;
@ -55,11 +55,11 @@ void test_roundtrip_response_for_locations_in_small_component(bool use_json_only
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
BOOST_CHECK(json_result.values.find("waypoints") == json_result.values.end()); 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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
const auto &trips = json_result.values.at("trips").get<json::Array>().values; const auto &trips = json_result.values.at("trips").get<json::Array>().values;
@ -138,11 +138,11 @@ void test_roundtrip_response_for_locations_in_big_component(bool use_json_only_a
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
const auto &trips = json_result.values.at("trips").get<json::Array>().values; const auto &trips = json_result.values.at("trips").get<json::Array>().values;
@ -192,11 +192,11 @@ void test_roundtrip_response_for_locations_across_components(bool use_json_only_
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
const auto &trips = json_result.values.at("trips").get<json::Array>().values; const auto &trips = json_result.values.at("trips").get<json::Array>().values;
@ -246,11 +246,11 @@ void test_tfse_1(bool use_json_only_api)
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = run_trip_json(osrm, params, json_result, use_json_only_api);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
const auto code = json_result.values.at("code").get<json::String>().value; const auto code = std::get<json::String>(json_result.values.at("code")).value;
BOOST_CHECK_EQUAL(code, "Ok"); BOOST_CHECK_EQUAL(code, "Ok");
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values; const auto &waypoints = std::get<json::Array>(json_result.values.at("waypoints")).values;
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size()); BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
const auto &trips = json_result.values.at("trips").get<json::Array>().values; const auto &trips = json_result.values.at("trips").get<json::Array>().values;
@ -294,11 +294,11 @@ void test_tfse_2(bool use_json_only_api)
for (const auto &waypoint : waypoints) for (const auto &waypoint : waypoints)
{ {
const auto &waypoint_object = waypoint.get<json::Object>(); const auto &waypoint_object = std::get<json::Object>(waypoint);
const auto location = waypoint_object.values.at("location").get<json::Array>().values; const auto location = std::get<json::Array>(waypoint_object.values.at("location")).values;
const auto longitude = location[0].get<json::Number>().value; const auto longitude = std::get<json::Number>(location[0]).value;
const auto latitude = location[1].get<json::Number>().value; const auto latitude = std::get<json::Number>(location[1]).value;
BOOST_CHECK(longitude >= -180. && longitude <= 180.); BOOST_CHECK(longitude >= -180. && longitude <= 180.);
BOOST_CHECK(latitude >= -90. && latitude <= 90.); 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); const auto rc = osrm.Trip(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); 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); const auto rc = osrm.Trip(params, result);
BOOST_CHECK(rc == Status::Ok); BOOST_CHECK(rc == Status::Ok);
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>(); auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(result);
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer()); auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
BOOST_CHECK(!fb->error()); BOOST_CHECK(!fb->error());

View File

@ -14,10 +14,10 @@ inline bool waypoint_check(osrm::json::Value waypoint)
{ {
throw util::exception("Must pass in a waypoint object"); throw util::exception("Must pass in a waypoint object");
} }
const auto waypoint_object = waypoint.get<json::Object>(); const auto waypoint_object = std::get<json::Object>(waypoint);
const auto waypoint_location = waypoint_object.values.at("location").get<json::Array>().values; const auto waypoint_location = std::get<json::Array>(waypoint_object.values.at("location")).values;
util::FloatLongitude lon{waypoint_location[0].get<json::Number>().value}; util::FloatLongitude lon{waypoint_std::get<json::Number>(location[0]).value};
util::FloatLatitude lat{waypoint_location[1].get<json::Number>().value}; util::FloatLatitude lat{waypoint_std::get<json::Number>(location[1]).value};
util::Coordinate location_coordinate(lon, lat); util::Coordinate location_coordinate(lon, lat);
return location_coordinate.IsValid(); return location_coordinate.IsValid();
} }