Skip to content

Commit

Permalink
Project-OSRM#7047: Nearest api returning node with id 0
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Oct 4, 2024
1 parent becfd8a commit 573f110
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions include/engine/api/nearest_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,23 @@ class NearestAPI final : public BaseAPI
facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1));
from_node = static_cast<std::uint64_t>(osm_node_id);
}
else if (phantom_node.forward_segment_id.enabled && phantom_node.fwd_segment_position > 0)
else if (phantom_node.forward_segment_id.enabled)
{
// In the case of one way, rely on forward segment only
auto osm_node_id =
facade.GetOSMNodeIDOfNode(forward_geometry(phantom_node.fwd_segment_position - 1));
if (phantom_node.fwd_segment_position > 0)
{
auto osm_node_id = facade.GetOSMNodeIDOfNode(
forward_geometry(phantom_node.fwd_segment_position - 1));
from_node = static_cast<std::uint64_t>(osm_node_id);
}
else if (phantom_node.fwd_segment_position == 0)
{
auto osm_node_id = facade.GetOSMNodeIDOfNode(
forward_geometry(phantom_node.fwd_segment_position + 1));
from_node = to_node;
to_node = static_cast<std::uint64_t>(osm_node_id);
}
}

return std::make_pair(from_node, to_node);
}
Expand Down

0 comments on commit 573f110

Please sign in to comment.