relative waypoint locations
This commit is contained in:
committed by
Patrick Niklaus
parent
482e18ccdb
commit
6605f293b4
@@ -39,7 +39,8 @@ class MatchAPI final : public RouteAPI
|
||||
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
||||
sub_routes[index].unpacked_path_segments,
|
||||
sub_routes[index].source_traversed_in_reverse,
|
||||
sub_routes[index].target_traversed_in_reverse);
|
||||
sub_routes[index].target_traversed_in_reverse,
|
||||
nullptr);
|
||||
route.values["confidence"] = sub_matchings[index].confidence;
|
||||
routes.values.push_back(std::move(route));
|
||||
}
|
||||
@@ -62,7 +63,7 @@ class MatchAPI final : public RouteAPI
|
||||
{
|
||||
MatchingIndex() = default;
|
||||
MatchingIndex(unsigned sub_matching_index_, unsigned point_index_)
|
||||
: sub_matching_index(sub_matching_index_), point_index(point_index_)
|
||||
: sub_matching_index(sub_matching_index_), point_index(point_index_)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
#include "engine/internal_route_result.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace engine
|
||||
@@ -33,21 +36,24 @@ class RouteAPI : public BaseAPI
|
||||
{
|
||||
}
|
||||
|
||||
void MakeResponse(const InternalRouteResult &raw_route, util::json::Object &response) const
|
||||
void MakeResponse(const InternalRouteResult &raw_route,
|
||||
util::json::Object &response,
|
||||
const std::vector<util::Coordinate> *const locations) const
|
||||
{
|
||||
auto number_of_routes = raw_route.has_alternative() ? 2UL : 1UL;
|
||||
util::json::Array routes;
|
||||
routes.values.resize(number_of_routes);
|
||||
routes.values[0] =
|
||||
MakeRoute(raw_route.segment_end_coordinates, raw_route.unpacked_path_segments,
|
||||
raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse);
|
||||
raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse,
|
||||
locations);
|
||||
if (raw_route.has_alternative())
|
||||
{
|
||||
std::vector<std::vector<PathData>> wrapped_leg(1);
|
||||
wrapped_leg.front() = std::move(raw_route.unpacked_alternative);
|
||||
routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, wrapped_leg,
|
||||
raw_route.alt_source_traversed_in_reverse,
|
||||
raw_route.alt_target_traversed_in_reverse);
|
||||
raw_route.alt_target_traversed_in_reverse, locations);
|
||||
}
|
||||
response.values["waypoints"] = BaseAPI::MakeWaypoints(raw_route.segment_end_coordinates);
|
||||
response.values["routes"] = std::move(routes);
|
||||
@@ -70,7 +76,8 @@ class RouteAPI : public BaseAPI
|
||||
util::json::Object MakeRoute(const std::vector<PhantomNodes> &segment_end_coordinates,
|
||||
std::vector<std::vector<PathData>> unpacked_path_segments,
|
||||
const std::vector<bool> &source_traversed_in_reverse,
|
||||
const std::vector<bool> &target_traversed_in_reverse) const
|
||||
const std::vector<bool> &target_traversed_in_reverse,
|
||||
const std::vector<util::Coordinate> *const locations) const
|
||||
{
|
||||
std::vector<guidance::RouteLeg> legs;
|
||||
std::vector<guidance::LegGeometry> leg_geometries;
|
||||
@@ -78,7 +85,8 @@ class RouteAPI : public BaseAPI
|
||||
legs.reserve(number_of_legs);
|
||||
leg_geometries.reserve(number_of_legs);
|
||||
|
||||
unpacked_path_segments = guidance::postProcess( std::move(unpacked_path_segments) );
|
||||
unpacked_path_segments = guidance::postProcess(std::move(unpacked_path_segments));
|
||||
BOOST_ASSERT(locations.size() == number_of_legs + 1);
|
||||
for (auto idx : util::irange(0UL, number_of_legs))
|
||||
{
|
||||
const auto &phantoms = segment_end_coordinates[idx];
|
||||
@@ -95,9 +103,18 @@ class RouteAPI : public BaseAPI
|
||||
|
||||
if (parameters.steps)
|
||||
{
|
||||
const auto getLoc = [](const std::vector<util::Coordinate> *const locations,
|
||||
int idx) -> boost::optional<util::Coordinate>
|
||||
{
|
||||
if (locations)
|
||||
return (*locations)[idx];
|
||||
return {};
|
||||
};
|
||||
leg.steps = guidance::assembleSteps(
|
||||
BaseAPI::facade, path_data, leg_geometry, phantoms.source_phantom,
|
||||
phantoms.target_phantom, reversed_source, reversed_target);
|
||||
phantoms.target_phantom, reversed_source, reversed_target,
|
||||
getLoc(locations, idx), getLoc(locations, idx + 1));
|
||||
;
|
||||
}
|
||||
|
||||
leg_geometries.push_back(std::move(leg_geometry));
|
||||
|
||||
@@ -28,7 +28,8 @@ class TripAPI final : public RouteAPI
|
||||
void MakeResponse(const std::vector<std::vector<NodeID>> &sub_trips,
|
||||
const std::vector<InternalRouteResult> &sub_routes,
|
||||
const std::vector<PhantomNode> &phantoms,
|
||||
util::json::Object &response) const
|
||||
util::json::Object &response,
|
||||
const std::vector<std::vector<util::Coordinate>> * const coordinates) const
|
||||
{
|
||||
auto number_of_routes = sub_trips.size();
|
||||
util::json::Array routes;
|
||||
@@ -39,7 +40,8 @@ class TripAPI final : public RouteAPI
|
||||
auto route = MakeRoute(sub_routes[index].segment_end_coordinates,
|
||||
sub_routes[index].unpacked_path_segments,
|
||||
sub_routes[index].source_traversed_in_reverse,
|
||||
sub_routes[index].target_traversed_in_reverse);
|
||||
sub_routes[index].target_traversed_in_reverse,
|
||||
coordinates ? &((*coordinates)[index]) : nullptr);
|
||||
routes.values.push_back(std::move(route));
|
||||
}
|
||||
response.values["waypoints"] = MakeWaypoints(sub_trips, phantoms);
|
||||
|
||||
Reference in New Issue
Block a user