Implemented 'skip_waypoints' for the 'Nearest' service.
It actually makes no sence, as the only output on the 'Nearest' service is a list of wypoints. On the other hand it can be used now as a simple health check.
This commit is contained in:
parent
10c1b38139
commit
1b47242a58
@ -6,6 +6,7 @@
|
||||
|
||||
#include "engine/api/json_factory.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "base_result.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@ -54,6 +55,8 @@ class NearestAPI final : public BaseAPI
|
||||
data_version_string = fb_result.CreateString(data_timestamp);
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> waypoints_vector;
|
||||
if (!parameters.skip_waypoints) {
|
||||
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||
waypoints.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
@ -71,8 +74,11 @@ class NearestAPI final : public BaseAPI
|
||||
return waypoint.Finish();
|
||||
});
|
||||
|
||||
auto waypoints_vector = fb_result.CreateVector(waypoints);
|
||||
waypoints_vector = fb_result.CreateVector(waypoints);
|
||||
}
|
||||
|
||||
fbresult::FBResultBuilder response(fb_result);
|
||||
|
||||
response.add_waypoints(waypoints_vector);
|
||||
if (data_version_string)
|
||||
{
|
||||
@ -83,6 +89,7 @@ class NearestAPI final : public BaseAPI
|
||||
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
|
||||
util::json::Object &response) const
|
||||
{
|
||||
if (!parameters.skip_waypoints) {
|
||||
util::json::Array waypoints;
|
||||
waypoints.values.resize(phantom_nodes.front().size());
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
@ -102,9 +109,10 @@ class NearestAPI final : public BaseAPI
|
||||
|
||||
return waypoint;
|
||||
});
|
||||
response.values["waypoints"] = std::move(waypoints);
|
||||
}
|
||||
|
||||
response.values["code"] = "Ok";
|
||||
response.values["waypoints"] = std::move(waypoints);
|
||||
}
|
||||
|
||||
const NearestParameters ¶meters;
|
||||
|
Loading…
Reference in New Issue
Block a user