Implemented 'skip_waypoints' for the 'Table' service.

This commit is contained in:
Denis Chaplygin 2019-09-16 14:32:53 +03:00
parent 600f48e15a
commit 660c0cc602
3 changed files with 27 additions and 9 deletions

View File

@ -2,11 +2,11 @@
#define ENGINE_API_NEAREST_API_HPP
#include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/nearest_parameters.hpp"
#include "engine/api/json_factory.hpp"
#include "engine/phantom_node.hpp"
#include "base_result.hpp"
#include <boost/assert.hpp>

View File

@ -3,6 +3,7 @@
#include "extractor/maneuver_override.hpp"
#include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/json_factory.hpp"
#include "engine/api/route_parameters.hpp"

View File

@ -2,6 +2,7 @@
#define ENGINE_API_TABLE_HPP
#include "engine/api/base_api.hpp"
#include "engine/api/base_result.hpp"
#include "engine/api/json_factory.hpp"
#include "engine/api/table_parameters.hpp"
@ -83,24 +84,32 @@ class TableAPI final : public BaseAPI
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>> sources;
if (parameters.sources.empty())
{
sources = MakeWaypoints(fb_result, phantoms);
if (!parameters.skip_waypoints) {
sources = MakeWaypoints(fb_result, phantoms);
}
number_of_sources = phantoms.size();
}
else
{
sources = MakeWaypoints(fb_result, phantoms, parameters.sources);
if (!parameters.skip_waypoints) {
sources = MakeWaypoints(fb_result, phantoms, parameters.sources);
}
}
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<fbresult::Waypoint>>>
destinations;
if (parameters.destinations.empty())
{
destinations = MakeWaypoints(fb_result, phantoms);
if (!parameters.skip_waypoints) {
destinations = MakeWaypoints(fb_result, phantoms);
}
number_of_destinations = phantoms.size();
}
else
{
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations);
if (!parameters.skip_waypoints) {
destinations = MakeWaypoints(fb_result, phantoms, parameters.destinations);
}
}
boost::optional<flatbuffers::Offset<flatbuffers::Vector<float>>> durations = boost::none;
@ -162,22 +171,30 @@ class TableAPI final : public BaseAPI
// symmetric case
if (parameters.sources.empty())
{
response.values["sources"] = MakeWaypoints(phantoms);
if (!parameters.skip_waypoints) {
response.values["sources"] = MakeWaypoints(phantoms);
}
number_of_sources = phantoms.size();
}
else
{
response.values["sources"] = MakeWaypoints(phantoms, parameters.sources);
if (!parameters.skip_waypoints) {
response.values["sources"] = MakeWaypoints(phantoms, parameters.sources);
}
}
if (parameters.destinations.empty())
{
response.values["destinations"] = MakeWaypoints(phantoms);
if (!parameters.skip_waypoints) {
response.values["destinations"] = MakeWaypoints(phantoms);
}
number_of_destinations = phantoms.size();
}
else
{
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
if (!parameters.skip_waypoints) {
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
}
}
if (parameters.annotations & TableParameters::AnnotationsType::Duration)