Use coorect osm ids for start/target segment

This commit is contained in:
Patrick Niklaus 2016-10-24 19:15:45 -07:00 committed by Patrick Niklaus
parent ccf5552406
commit 08a5648e3e
3 changed files with 27 additions and 11 deletions

View File

@ -94,8 +94,12 @@ class RouteAPI : public BaseAPI
const bool reversed_source = source_traversed_in_reverse[idx];
const bool reversed_target = target_traversed_in_reverse[idx];
auto leg_geometry = guidance::assembleGeometry(
BaseAPI::facade, path_data, phantoms.source_phantom, phantoms.target_phantom);
auto leg_geometry = guidance::assembleGeometry(BaseAPI::facade,
path_data,
phantoms.source_phantom,
phantoms.target_phantom,
reversed_source,
reversed_target);
auto leg = guidance::assembleLeg(facade,
path_data,
leg_geometry,

View File

@ -35,7 +35,9 @@ namespace guidance
inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
const std::vector<PathData> &leg_data,
const PhantomNode &source_node,
const PhantomNode &target_node)
const PhantomNode &target_node,
const bool reversed_source,
const bool reversed_target)
{
LegGeometry geometry;
@ -43,12 +45,17 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
geometry.segment_offsets.push_back(0);
geometry.locations.push_back(source_node.location);
// Need to get the node ID preceding the source phantom node
// TODO: check if this was traversed in reverse?
// u * v
// 0 -- 1 -- 2 -- 3
// fwd_segment_position: 1
// source node fwd: 1 1 -> 2 -> 3
// source node rev: 2 0 <- 1 <- 2
const auto source_segment_start_coordinate =
source_node.fwd_segment_position + (reversed_source ? 1 : 0);
const std::vector<NodeID> source_geometry =
facade.GetUncompressedForwardGeometry(source_node.packed_geometry_id);
geometry.osm_node_ids.push_back(
facade.GetOSMNodeIDOfNode(source_geometry[source_node.fwd_segment_position]));
facade.GetOSMNodeIDOfNode(source_geometry[source_segment_start_coordinate]));
auto cumulative_distance = 0.;
auto current_distance = 0.;
@ -90,12 +97,17 @@ inline LegGeometry assembleGeometry(const datafacade::BaseDataFacade &facade,
geometry.segment_offsets.push_back(geometry.locations.size());
geometry.locations.push_back(target_node.location);
// Need to get the node ID following the destination phantom node
// TODO: check if this was traversed in reverse??
// u * v
// 0 -- 1 -- 2 -- 3
// fwd_segment_position: 1
// target node fwd: 2 0 -> 1 -> 2
// target node rev: 1 1 <- 2 <- 3
const auto target_segment_end_coordinate =
target_node.fwd_segment_position + (reversed_target ? 0 : 1);
const std::vector<NodeID> target_geometry =
facade.GetUncompressedForwardGeometry(target_node.packed_geometry_id);
geometry.osm_node_ids.push_back(
facade.GetOSMNodeIDOfNode(target_geometry[target_node.fwd_segment_position + 1]));
facade.GetOSMNodeIDOfNode(target_geometry[target_segment_end_coordinate]));
BOOST_ASSERT(geometry.segment_distances.size() == geometry.segment_offsets.size() - 1);
BOOST_ASSERT(geometry.locations.size() > geometry.segment_distances.size());

View File

@ -209,13 +209,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
const PhantomNodes &phantom_node_pair,
std::vector<PathData> &unpacked_path) const
{
BOOST_ASSERT(std::distance(packed_path_begin, packed_path_end) > 0);
const bool start_traversed_in_reverse =
(*packed_path_begin != phantom_node_pair.source_phantom.forward_segment_id.id);
const bool target_traversed_in_reverse =
(*std::prev(packed_path_end) != phantom_node_pair.target_phantom.forward_segment_id.id);
BOOST_ASSERT(std::distance(packed_path_begin, packed_path_end) > 0);
BOOST_ASSERT(*packed_path_begin == phantom_node_pair.source_phantom.forward_segment_id.id ||
*packed_path_begin == phantom_node_pair.source_phantom.reverse_segment_id.id);
BOOST_ASSERT(