Fix foward/backwad swap
This commit is contained in:
parent
8218d5a47e
commit
4e8fe89faa
@ -93,8 +93,7 @@ class RouteAPI : public BaseAPI
|
||||
auto leg_geometry = guidance::assembleGeometry(
|
||||
BaseAPI::facade, path_data, phantoms.source_phantom, phantoms.target_phantom);
|
||||
auto leg = guidance::assembleLeg(BaseAPI::facade, path_data, leg_geometry,
|
||||
phantoms.source_phantom, phantoms.target_phantom,
|
||||
reversed_source, reversed_target);
|
||||
phantoms.target_phantom, reversed_target);
|
||||
|
||||
if (parameters.steps)
|
||||
{
|
||||
|
@ -96,18 +96,12 @@ template <typename DataFacadeT>
|
||||
RouteLeg assembleLeg(const DataFacadeT &facade,
|
||||
const std::vector<PathData> &route_data,
|
||||
const LegGeometry &leg_geometry,
|
||||
const PhantomNode &source_node,
|
||||
const PhantomNode &target_node,
|
||||
const bool source_traversed_in_reverse,
|
||||
const bool target_traversed_in_reverse)
|
||||
{
|
||||
const auto source_duration =
|
||||
(source_traversed_in_reverse ? source_node.GetReverseWeightPlusOffset()
|
||||
: source_node.GetForwardWeightPlusOffset()) /
|
||||
10.;
|
||||
const auto target_duration =
|
||||
(target_traversed_in_reverse ? target_node.GetReverseWeightPlusOffset()
|
||||
: target_node.GetForwardWeightPlusOffset()) /
|
||||
(target_traversed_in_reverse ? target_node.reverse_weight
|
||||
: target_node.forward_weight) /
|
||||
10.;
|
||||
|
||||
auto distance = std::accumulate(leg_geometry.segment_distances.begin(),
|
||||
@ -136,13 +130,9 @@ RouteLeg assembleLeg(const DataFacadeT &facade,
|
||||
// The phantom node of t will contain:
|
||||
// `forward_weight`: duration of (d,t)
|
||||
// `forward_offset`: duration of (c, d)
|
||||
//
|
||||
// TODO discuss, this should not be the case after danpats fixes
|
||||
// The PathData will contain entries of b, c and d. But only c will contain
|
||||
// a duration value since its the only point associated with a turn.
|
||||
// As such we want to slice of the duration for (a,s) and add the duration for
|
||||
// (c,d,t)
|
||||
duration = duration - source_duration + target_duration;
|
||||
// path_data will have entries for (s,b), (b, c), (c, d) but (d, t) is only
|
||||
// caputed by the phantom node. So we need to add the target duration here.
|
||||
duration = duration + target_duration;
|
||||
auto summary_array = detail::summarizeRoute<detail::MAX_USED_SEGMENTS>(route_data);
|
||||
|
||||
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
|
||||
|
@ -41,12 +41,12 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
||||
const bool target_traversed_in_reverse)
|
||||
{
|
||||
const EdgeWeight source_duration =
|
||||
source_traversed_in_reverse ? source_node.forward_weight : source_node.reverse_weight;
|
||||
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
|
||||
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
|
||||
: source_node.forward_travel_mode;
|
||||
|
||||
const EdgeWeight target_duration =
|
||||
target_traversed_in_reverse ? target_node.forward_weight : target_node.reverse_weight;
|
||||
target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight;
|
||||
const auto target_mode = target_traversed_in_reverse ? target_node.backward_travel_mode
|
||||
: target_node.forward_travel_mode;
|
||||
|
||||
|
@ -299,8 +299,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
weight_vector);
|
||||
BOOST_ASSERT(weight_vector.size() > 0);
|
||||
|
||||
auto total_weight =
|
||||
std::accumulate(weight_vector.begin(), weight_vector.end(), 0);
|
||||
auto total_weight = std::accumulate(weight_vector.begin(), weight_vector.end(), 0);
|
||||
|
||||
BOOST_ASSERT(weight_vector.size() == id_vector.size());
|
||||
// ed.distance should be total_weight + penalties (turn, stop, etc)
|
||||
@ -330,6 +329,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
if (is_first_segment)
|
||||
{
|
||||
auto source_weight = start_traversed_in_reverse
|
||||
? phantom_node_pair.source_phantom.reverse_weight
|
||||
: phantom_node_pair.source_phantom.forward_weight;
|
||||
// Given this geometry:
|
||||
// U---v---w---x---Z
|
||||
// s
|
||||
@ -337,12 +339,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
// However the first segment duration needs to be adjusted to the fact that the
|
||||
// source phantom is in the middle of the segment.
|
||||
// We do this by subtracting v--s from the duration.
|
||||
BOOST_ASSERT(unpacked_path.front().duration_until_turn >=
|
||||
phantom_node_pair.source_phantom.forward_weight);
|
||||
unpacked_path.front().duration_until_turn -=
|
||||
start_traversed_in_reverse
|
||||
? phantom_node_pair.source_phantom.forward_weight
|
||||
: phantom_node_pair.source_phantom.reverse_weight;
|
||||
BOOST_ASSERT(unpacked_path.front().duration_until_turn >= source_weight);
|
||||
unpacked_path.front().duration_until_turn -= source_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -388,7 +386,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
// s: fwd_segment 0
|
||||
// t: fwd_segment 3
|
||||
// -> (U, v), (v, w), (w, x)
|
||||
// note that (x, t) is _not_ included but needs to
|
||||
// note that (x, t) is _not_ included but needs to be added later.
|
||||
for (std::size_t i = start_index; i != end_index; (start_index < end_index ? ++i : --i))
|
||||
{
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
@ -403,14 +401,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
|
||||
if (is_local_path && unpacked_path.size() > 0)
|
||||
{
|
||||
auto source_weight = start_traversed_in_reverse
|
||||
? phantom_node_pair.source_phantom.reverse_weight
|
||||
: phantom_node_pair.source_phantom.forward_weight;
|
||||
// The above code will create segments for (v, w), (w,x), (x, y) and (y, Z).
|
||||
// However the first segment duration needs to be adjusted to the fact that the source
|
||||
// phantom
|
||||
// is in the middle of the segment. We do this by subtracting v--s from the duration.
|
||||
BOOST_ASSERT(unpacked_path.front().duration_until_turn >=
|
||||
phantom_node_pair.source_phantom.forward_weight);
|
||||
unpacked_path.front().duration_until_turn -=
|
||||
phantom_node_pair.source_phantom.forward_weight;
|
||||
// phantom is in the middle of the segment. We do this by subtracting v--s from the
|
||||
// duration.
|
||||
BOOST_ASSERT(unpacked_path.front().duration_until_turn >= source_weight);
|
||||
unpacked_path.front().duration_until_turn -= source_weight;
|
||||
}
|
||||
|
||||
// there is no equivalent to a node-based node in an edge-expanded graph.
|
||||
|
Loading…
Reference in New Issue
Block a user