diff --git a/include/engine/api/nearest_api.hpp b/include/engine/api/nearest_api.hpp index 0e2a9edbfd..779e293561 100644 --- a/include/engine/api/nearest_api.hpp +++ b/include/engine/api/nearest_api.hpp @@ -149,13 +149,23 @@ class NearestAPI final : public BaseAPI facade.GetOSMNodeIDOfNode(geometry(phantom_node.fwd_segment_position + 1)); from_node = static_cast(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(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(osm_node_id); + } + } return std::make_pair(from_node, to_node); }