Hi, I found this PhantomNode struct really interesting. Yet, I was confused about the following piece of code except from the file phantom_node.hpp.
EdgeDistance GetForwardDistance() const
{
// ..... <-- forward_distance
// .... <-- offset
// ......... <-- desired distance
// x <-- this is PhantomNode.location
// 0----1----2----3----4 <-- EdgeBasedGraph Node segments
BOOST_ASSERT(forward_segment_id.enabled);
return forward_distance + forward_distance_offset;
}
EdgeDistance GetReverseDistance() const
{
// .......... <-- reverse_distance
// ... <-- offset
// ............. <-- desired distance
// x <-- this is PhantomNode.location
// 0----1----2----3----4 <-- EdgeBasedGraph Node segments
BOOST_ASSERT(reverse_segment_id.enabled);
return reverse_distance + reverse_distance_offset;
}
I was wondering, where to find any explanations for this PhantomNode?
The road network is built up of nodes and edges, as people draw them in OpenStreetmap.
The routing algorithm implemented in OSRM assumes you'll start on a "node".
However, when you supply a longitude/latitude to OSRM, it's very rarely exactly on an intersection point on the road network - it's usually off to the side of the road.
The PhantomNode class represents a temporary node that's inserted into the graph at the position where your input longitude/latitude is. This acts as the starting and ending "node"s for the routing algorithm, and allows the algorithm to not have a special case for the initial/last iteration.
Most helpful comment
The road network is built up of nodes and edges, as people draw them in OpenStreetmap.
The routing algorithm implemented in OSRM assumes you'll start on a "node".
However, when you supply a longitude/latitude to OSRM, it's very rarely exactly on an intersection point on the road network - it's usually off to the side of the road.
The
PhantomNodeclass represents a temporary node that's inserted into the graph at the position where your input longitude/latitude is. This acts as the starting and ending "node"s for the routing algorithm, and allows the algorithm to not have a special case for the initial/last iteration.