Merge pull request #5513 from akashihi/flatbuffers

Flatbuffers support added
This commit is contained in:
Lev Dragunov
2019-08-29 13:11:24 +03:00
committed by GitHub
676 changed files with 135336 additions and 489 deletions
+4 -2
View File
@@ -214,9 +214,11 @@ int main(int argc, const char *argv[]) try
auto NUM = 100;
for (int i = 0; i < NUM; ++i)
{
json::Object result;
engine::api::ResultT result = json::Object();
const auto rc = osrm.Match(params, result);
if (rc != Status::Ok || result.values.at("matchings").get<json::Array>().values.size() != 1)
auto &json_result = result.get<json::Object>();
if (rc != Status::Ok ||
json_result.values.at("matchings").get<json::Array>().values.size() != 1)
{
return EXIT_FAILURE;
}
-13
View File
@@ -20,7 +20,6 @@
#include <vector>
namespace TurnType = osrm::guidance::TurnType;
namespace DirectionModifier = osrm::guidance::DirectionModifier;
using TurnInstruction = osrm::guidance::TurnInstruction;
namespace osrm
@@ -34,18 +33,6 @@ namespace json
namespace detail
{
// Check whether to include a modifier in the result of the API
inline bool isValidModifier(const guidance::StepManeuver maneuver)
{
return (maneuver.waypoint_type == guidance::WaypointType::None ||
maneuver.instruction.direction_modifier != DirectionModifier::UTurn);
}
inline bool hasValidLanes(const guidance::IntermediateIntersection &intersection)
{
return intersection.lanes.lanes_in_turn > 0;
}
inline util::json::Array toJSON(const extractor::TurnLaneType::Mask lane_type)
{
util::json::Array result;
+14 -17
View File
@@ -112,16 +112,16 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::MatchParameters &parameters,
util::json::Object &json_result) const
osrm::engine::api::ResultT &result) const
{
if (!algorithms.HasMapMatching())
{
return Error("NotImplemented",
"Map matching is not implemented for the chosen search algorithm.",
json_result);
result);
}
if (!CheckAlgorithms(parameters, algorithms, json_result))
if (!CheckAlgorithms(parameters, algorithms, result))
return Status::Error;
const auto &facade = algorithms.GetFacade();
@@ -132,12 +132,12 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
if (max_locations_map_matching > 0 &&
static_cast<int>(parameters.coordinates.size()) > max_locations_map_matching)
{
return Error("TooBig", "Too many trace coordinates", json_result);
return Error("TooBig", "Too many trace coordinates", result);
}
if (!CheckAllCoordinates(parameters.coordinates))
{
return Error("InvalidValue", "Invalid coordinate value.", json_result);
return Error("InvalidValue", "Invalid coordinate value.", result);
}
if (max_radius_map_matching > 0 && std::any_of(parameters.radiuses.begin(),
@@ -148,7 +148,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
return *radius > max_radius_map_matching;
}))
{
return Error("TooBig", "Radius search size is too large for map matching.", json_result);
return Error("TooBig", "Radius search size is too large for map matching.", result);
}
// Check for same or increasing timestamps. Impl. note: Incontrast to `sort(first,
@@ -158,8 +158,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
if (!time_increases_monotonically)
{
return Error(
"InvalidValue", "Timestamps need to be monotonically increasing.", json_result);
return Error("InvalidValue", "Timestamps need to be monotonically increasing.", result);
}
SubMatchingList sub_matchings;
@@ -180,9 +179,8 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
(tidied.parameters.waypoints[0] != 0 ||
tidied.parameters.waypoints.back() != (tidied.parameters.coordinates.size() - 1)))
{
return Error("InvalidValue",
"First and last coordinates must be specified as waypoints.",
json_result);
return Error(
"InvalidValue", "First and last coordinates must be specified as waypoints.", result);
}
// assuming radius is the standard deviation of a normal distribution
@@ -225,7 +223,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
{
return Error("NoSegment",
std::string("Could not find a matching segment for any coordinate."),
json_result);
result);
}
// call the actual map matching
@@ -238,13 +236,13 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
if (sub_matchings.size() == 0)
{
return Error("NoMatch", "Could not match the trace.", json_result);
return Error("NoMatch", "Could not match the trace.", result);
}
// trace was split, we don't support the waypoints parameter across multiple match objects
if (sub_matchings.size() > 1 && !parameters.waypoints.empty())
{
return Error("NoMatch", "Could not match the trace with the given waypoints.", json_result);
return Error("NoMatch", "Could not match the trace with the given waypoints.", result);
}
// Error: Check if user-supplied waypoints can be found in the resulting matches
@@ -260,8 +258,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
}
if (!tidied_waypoints.empty())
{
return Error(
"NoMatch", "Requested waypoint parameter could not be matched.", json_result);
return Error("NoMatch", "Requested waypoint parameter could not be matched.", result);
}
}
// we haven't errored yet, only allow leg collapsing if it was originally requested
@@ -313,7 +310,7 @@ Status MatchPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
}
api::MatchAPI match_api{facade, parameters, tidied};
match_api.MakeResponse(sub_matchings, sub_routes, json_result);
match_api.MakeResponse(sub_matchings, sub_routes, result);
return Status::Ok;
}
+7 -7
View File
@@ -21,11 +21,11 @@ NearestPlugin::NearestPlugin(const int max_results_) : max_results{max_results_}
Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::NearestParameters &params,
util::json::Object &json_result) const
osrm::engine::api::ResultT &result) const
{
BOOST_ASSERT(params.IsValid());
if (!CheckAlgorithms(params, algorithms, json_result))
if (!CheckAlgorithms(params, algorithms, result))
return Status::Error;
const auto &facade = algorithms.GetFacade();
@@ -36,27 +36,27 @@ Status NearestPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms
return Error("TooBig",
"Number of results " + std::to_string(params.number_of_results) +
" is higher than current maximum (" + std::to_string(max_results) + ")",
json_result);
result);
}
if (!CheckAllCoordinates(params.coordinates))
return Error("InvalidOptions", "Coordinates are invalid", json_result);
return Error("InvalidOptions", "Coordinates are invalid", result);
if (params.coordinates.size() != 1)
{
return Error("InvalidOptions", "Only one input coordinate is supported", json_result);
return Error("InvalidOptions", "Only one input coordinate is supported", result);
}
auto phantom_nodes = GetPhantomNodes(facade, params, params.number_of_results);
if (phantom_nodes.front().size() == 0)
{
return Error("NoSegment", "Could not find a matching segments for coordinate", json_result);
return Error("NoSegment", "Could not find a matching segments for coordinate", result);
}
BOOST_ASSERT(phantom_nodes.front().size() > 0);
api::NearestAPI nearest_api(facade, params);
nearest_api.MakeResponse(phantom_nodes, json_result);
nearest_api.MakeResponse(phantom_nodes, result);
return Status::Ok;
}
+1 -1
View File
@@ -31,7 +31,7 @@ TablePlugin::TablePlugin(const int max_locations_distance_table)
Status TablePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::TableParameters &params,
util::json::Object &result) const
osrm::engine::api::ResultT &result) const
{
if (!algorithms.HasManyToManySearch())
{
+2 -1
View File
@@ -665,10 +665,11 @@ void encodeVectorTile(const DataFacadeBase &facade,
Status TilePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::TileParameters &parameters,
std::string &pbf_buffer) const
osrm::engine::api::ResultT &result) const
{
BOOST_ASSERT(parameters.IsValid());
auto &pbf_buffer = result.get<std::string>();
const auto &facade = algorithms.GetFacade();
auto edges = getEdges(facade, parameters.x, parameters.y, parameters.z);
auto segregated_nodes = getSegregatedNodes(facade, edges);
+11 -11
View File
@@ -144,19 +144,19 @@ void ManipulateTableForFSE(const std::size_t source_id,
Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::TripParameters &parameters,
util::json::Object &json_result) const
osrm::engine::api::ResultT &result) const
{
if (!algorithms.HasShortestPathSearch())
{
return Error("NotImplemented",
"Shortest path search is not implemented for the chosen search algorithm.",
json_result);
result);
}
if (!algorithms.HasManyToManySearch())
{
return Error("NotImplemented",
"Many to many search is not implemented for the chosen search algorithm.",
json_result);
result);
}
BOOST_ASSERT(parameters.IsValid());
@@ -177,21 +177,21 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
bool fixed_end = (destination_id == number_of_locations - 1);
if (!IsSupportedParameterCombination(fixed_start, fixed_end, parameters.roundtrip))
{
return Error("NotImplemented", "This request is not supported", json_result);
return Error("NotImplemented", "This request is not supported", result);
}
// enforce maximum number of locations for performance reasons
if (max_locations_trip > 0 && static_cast<int>(number_of_locations) > max_locations_trip)
{
return Error("TooBig", "Too many trip coordinates", json_result);
return Error("TooBig", "Too many trip coordinates", result);
}
if (!CheckAllCoordinates(parameters.coordinates))
{
return Error("InvalidValue", "Invalid coordinate value.", json_result);
return Error("InvalidValue", "Invalid coordinate value.", result);
}
if (!CheckAlgorithms(parameters, algorithms, json_result))
if (!CheckAlgorithms(parameters, algorithms, result))
return Status::Error;
const auto &facade = algorithms.GetFacade();
@@ -201,14 +201,14 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
return Error("NoSegment",
std::string("Could not find a matching segment for coordinate ") +
std::to_string(phantom_node_pairs.size()),
json_result);
result);
}
BOOST_ASSERT(phantom_node_pairs.size() == number_of_locations);
if (fixed_start && fixed_end && (source_id >= parameters.coordinates.size() ||
destination_id >= parameters.coordinates.size()))
{
return Error("InvalidValue", "Invalid source or destination value.", json_result);
return Error("InvalidValue", "Invalid source or destination value.", result);
}
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
@@ -231,7 +231,7 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
if (!IsStronglyConnectedComponent(result_duration_table))
{
return Error("NoTrips", "No trip visiting all destinations possible.", json_result);
return Error("NoTrips", "No trip visiting all destinations possible.", result);
}
if (fixed_start && fixed_end)
@@ -275,7 +275,7 @@ Status TripPlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const std::vector<std::vector<NodeID>> trips = {duration_trip};
const std::vector<InternalRouteResult> routes = {route};
api::TripAPI trip_api{facade, parameters};
trip_api.MakeResponse(trips, routes, snapped_phantoms, json_result);
trip_api.MakeResponse(trips, routes, snapped_phantoms, result);
return Status::Ok;
}
+13 -14
View File
@@ -28,7 +28,7 @@ ViaRoutePlugin::ViaRoutePlugin(int max_locations_viaroute, int max_alternatives)
Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithms,
const api::RouteParameters &route_parameters,
util::json::Object &json_result) const
osrm::engine::api::ResultT &result) const
{
BOOST_ASSERT(route_parameters.IsValid());
@@ -37,7 +37,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
return Error("NotImplemented",
"Shortest path search is not implemented for the chosen search algorithm. "
"Only two coordinates supported.",
json_result);
result);
}
if (!algorithms.HasDirectShortestPathSearch() && !algorithms.HasShortestPathSearch())
@@ -45,7 +45,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
return Error(
"NotImplemented",
"Direct shortest path search is not implemented for the chosen search algorithm.",
json_result);
result);
}
if (max_locations_viaroute > 0 &&
@@ -55,7 +55,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
"Number of entries " + std::to_string(route_parameters.coordinates.size()) +
" is higher than current maximum (" +
std::to_string(max_locations_viaroute) + ")",
json_result);
result);
}
// Takes care of alternatives=n and alternatives=true
@@ -65,12 +65,12 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
return Error("TooBig",
"Requested number of alternatives is higher than current maximum (" +
std::to_string(max_alternatives) + ")",
json_result);
result);
}
if (!CheckAllCoordinates(route_parameters.coordinates))
{
return Error("InvalidValue", "Invalid coordinate value.", json_result);
return Error("InvalidValue", "Invalid coordinate value.", result);
}
// Error: first and last points should be waypoints
@@ -78,12 +78,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
(route_parameters.waypoints[0] != 0 ||
route_parameters.waypoints.back() != (route_parameters.coordinates.size() - 1)))
{
return Error("InvalidValue",
"First and last coordinates must be specified as waypoints.",
json_result);
return Error(
"InvalidValue", "First and last coordinates must be specified as waypoints.", result);
}
if (!CheckAlgorithms(route_parameters, algorithms, json_result))
if (!CheckAlgorithms(route_parameters, algorithms, result))
return Status::Error;
const auto &facade = algorithms.GetFacade();
@@ -93,7 +92,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
return Error("NoSegment",
std::string("Could not find a matching segment for coordinate ") +
std::to_string(phantom_node_pairs.size()),
json_result);
result);
}
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
@@ -162,7 +161,7 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
}
}
route_api.MakeResponse(routes, start_end_nodes, json_result);
route_api.MakeResponse(routes, start_end_nodes, result);
}
else
{
@@ -175,11 +174,11 @@ Status ViaRoutePlugin::HandleRequest(const RoutingAlgorithmsInterface &algorithm
if (not_in_same_component)
{
return Error("NoRoute", "Impossible route between points", json_result);
return Error("NoRoute", "Impossible route between points", result);
}
else
{
return Error("NoRoute", "No route found between points", json_result);
return Error("NoRoute", "No route found between points", result);
}
}
+12 -7
View File
@@ -151,18 +151,20 @@ inline void async(const Nan::FunctionCallbackInfo<v8::Value> &info,
void Execute() override try
{
osrm::json::Object r;
osrm::engine::api::ResultT r;
r = osrm::util::json::Object();
const auto status = ((*osrm).*(service))(*params, r);
ParseResult(status, r);
auto json_result = r.get<osrm::json::Object>();
ParseResult(status, json_result);
if (pluginParams.renderJSONToBuffer)
{
std::ostringstream buf;
osrm::util::json::render(buf, r);
osrm::util::json::render(buf, json_result);
result = buf.str();
}
else
{
result = r;
result = json_result;
}
}
catch (const std::exception &e)
@@ -230,8 +232,10 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
void Execute() override try
{
result = std::string();
const auto status = ((*osrm).*(service))(*params, result);
ParseResult(status, result);
auto str_result = result.get<std::string>();
ParseResult(status, str_result);
}
catch (const std::exception &e)
{
@@ -243,7 +247,8 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
Nan::HandleScope scope;
const constexpr auto argc = 2u;
v8::Local<v8::Value> argv[argc] = {Nan::Null(), render(result)};
auto str_result = result.get<std::string>();
v8::Local<v8::Value> argv[argc] = {Nan::Null(), render(str_result)};
callback->Call(argc, argv);
}
@@ -254,7 +259,7 @@ inline void asyncForTiles(const Nan::FunctionCallbackInfo<v8::Value> &info,
const ParamPtr params;
const PluginParameters pluginParams;
std::string result;
osrm::engine::api::ResultT result;
};
auto *callback = new Nan::Callback{info[info.Length() - 1].As<v8::Function>()};
+10 -6
View File
@@ -57,33 +57,37 @@ OSRM &OSRM::operator=(OSRM &&) noexcept = default;
// Forward to implementation
engine::Status OSRM::Route(const engine::api::RouteParameters &params,
util::json::Object &result) const
osrm::engine::api::ResultT &result) const
{
return engine_->Route(params, result);
}
engine::Status OSRM::Table(const engine::api::TableParameters &params, json::Object &result) const
engine::Status OSRM::Table(const engine::api::TableParameters &params,
osrm::engine::api::ResultT &result) const
{
return engine_->Table(params, result);
}
engine::Status OSRM::Nearest(const engine::api::NearestParameters &params,
json::Object &result) const
osrm::engine::api::ResultT &result) const
{
return engine_->Nearest(params, result);
}
engine::Status OSRM::Trip(const engine::api::TripParameters &params, json::Object &result) const
engine::Status OSRM::Trip(const engine::api::TripParameters &params,
osrm::engine::api::ResultT &result) const
{
return engine_->Trip(params, result);
}
engine::Status OSRM::Match(const engine::api::MatchParameters &params, json::Object &result) const
engine::Status OSRM::Match(const engine::api::MatchParameters &params,
osrm::engine::api::ResultT &result) const
{
return engine_->Match(params, result);
}
engine::Status OSRM::Tile(const engine::api::TileParameters &params, std::string &result) const
engine::Status OSRM::Tile(const engine::api::TileParameters &params,
osrm::engine::api::ResultT &result) const
{
return engine_->Tile(params, result);
}
+11
View File
@@ -110,6 +110,17 @@ void RequestHandler::HandleRequest(const http::request &current_request, http::r
util::json::render(current_reply.content, result.get<util::json::Object>());
}
else if (result.is<flatbuffers::FlatBufferBuilder>())
{
auto &buffer = result.get<flatbuffers::FlatBufferBuilder>();
current_reply.content.resize(buffer.GetSize());
std::copy(buffer.GetBufferPointer(),
buffer.GetBufferPointer() + buffer.GetSize(),
current_reply.content.begin());
current_reply.headers.emplace_back(
"Content-Type", "application/x-flatbuffers;schema=osrm.engine.api.fbresult");
}
else
{
BOOST_ASSERT(result.is<std::string>());
+11 -3
View File
@@ -41,8 +41,9 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters &parameters)
}
} // anon. ns
engine::Status
MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status MatchService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
result = util::json::Object();
auto &json_result = result.get<util::json::Object>();
@@ -68,7 +69,14 @@ MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
}
BOOST_ASSERT(parameters->IsValid());
return BaseService::routing_machine.Match(*parameters, json_result);
if (parameters->format)
{
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
{
result = flatbuffers::FlatBufferBuilder();
}
}
return BaseService::routing_machine.Match(*parameters, result);
}
}
}
+11 -3
View File
@@ -35,8 +35,9 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters &parameters)
}
} // anon. ns
engine::Status
NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status NearestService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
result = util::json::Object();
auto &json_result = result.get<util::json::Object>();
@@ -62,7 +63,14 @@ NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT
}
BOOST_ASSERT(parameters->IsValid());
return BaseService::routing_machine.Nearest(*parameters, json_result);
if (parameters->format)
{
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
{
result = flatbuffers::FlatBufferBuilder();
}
}
return BaseService::routing_machine.Nearest(*parameters, result);
}
}
}
+11 -3
View File
@@ -39,8 +39,9 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters &parameters)
}
} // anon. ns
engine::Status
RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status RouteService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
result = util::json::Object();
auto &json_result = result.get<util::json::Object>();
@@ -66,7 +67,14 @@ RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
}
BOOST_ASSERT(parameters->IsValid());
return BaseService::routing_machine.Route(*parameters, json_result);
if (parameters->format)
{
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
{
result = flatbuffers::FlatBufferBuilder();
}
}
return BaseService::routing_machine.Route(*parameters, result);
}
}
}
+11 -3
View File
@@ -70,8 +70,9 @@ std::string getWrongOptionHelp(const engine::api::TableParameters &parameters)
}
} // anon. ns
engine::Status
TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status TableService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
result = util::json::Object();
auto &json_result = result.get<util::json::Object>();
@@ -97,7 +98,14 @@ TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &r
}
BOOST_ASSERT(parameters->IsValid());
return BaseService::routing_machine.Table(*parameters, json_result);
if (parameters->format)
{
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
{
result = flatbuffers::FlatBufferBuilder();
}
}
return BaseService::routing_machine.Table(*parameters, result);
}
}
}
+4 -3
View File
@@ -15,7 +15,9 @@ namespace server
namespace service
{
engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status TileService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
auto query_iterator = query.begin();
auto parameters =
@@ -43,8 +45,7 @@ engine::Status TileService::RunQuery(std::size_t prefix_length, std::string &que
BOOST_ASSERT(parameters->IsValid());
result = std::string();
auto &string_result = result.get<std::string>();
return BaseService::routing_machine.Tile(*parameters, string_result);
return BaseService::routing_machine.Tile(*parameters, result);
}
}
}
+11 -2
View File
@@ -41,7 +41,9 @@ std::string getWrongOptionHelp(const engine::api::TripParameters &parameters)
}
} // anon. ns
engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
engine::Status TripService::RunQuery(std::size_t prefix_length,
std::string &query,
osrm::engine::api::ResultT &result)
{
result = util::json::Object();
auto &json_result = result.get<util::json::Object>();
@@ -69,7 +71,14 @@ engine::Status TripService::RunQuery(std::size_t prefix_length, std::string &que
}
BOOST_ASSERT(parameters->IsValid());
return BaseService::routing_machine.Trip(*parameters, json_result);
if (parameters->format)
{
if (parameters->format == engine::api::BaseParameters::OutputFormatType::FLATBUFFERS)
{
result = flatbuffers::FlatBufferBuilder();
}
}
return BaseService::routing_machine.Trip(*parameters, result);
}
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(con
}
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
service::BaseService::ResultT &result)
osrm::engine::api::ResultT &result)
{
const auto &service_iter = service_map.find(parsed_url.service);
if (service_iter == service_map.end())