Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
- FIXED: Ensure required file check in osrm-routed is correctly enforced. [#6655](https://github.com/Project-OSRM/osrm-backend/pull/6655)
- FIXED: Correct HTTP docs to reflect summary output dependency on steps parameter. [#6655](https://github.com/Project-OSRM/osrm-backend/pull/6655)
- ADDED: Extract prerelease/build information from package semver [#6839](https://github.com/Project-OSRM/osrm-backend/pull/6839)
- FIXED: Nearest api returning node with id 0 [#7047](https://github.com/Project-OSRM/osrm-backend/issues/7047)
- Profiles:
- FIXED: Bicycle and foot profiles now don't route on proposed ways [#6615](https://github.com/Project-OSRM/osrm-backend/pull/6615)
- ADDED: Add optional support of cargo bike exclusion and width to bicyle profile [#7044](https://github.com/Project-OSRM/osrm-backend/pull/7044)
Expand Down
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be more readable?

else if (phantom_node.forward_segment_id.enabled && phantom_node.fwd_segment_position == 0)
{
    // At the very beginning of a one-way forward geometry.
    // Segment runs from the first OSM node to the second OSM node.
    // We require at least 2 nodes in forward_geometry to form a valid edge.
    BOOST_ASSERT(forward_geometry.size() >= 2);

    auto from_osm_node = facade.GetOSMNodeIDOfNode(forward_geometry[0]);
    auto to_osm_node   = facade.GetOSMNodeIDOfNode(forward_geometry[1]);

    from_node = static_cast<std::uint64_t>(from_osm_node);
    to_node   = static_cast<std::uint64_t>(to_osm_node);
}

{
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