Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add osm nodes to nearest response #4436

Merged
merged 3 commits into from
Oct 19, 2017
Merged

Add osm nodes to nearest response #4436

merged 3 commits into from
Oct 19, 2017

Conversation

daudrain
Copy link
Contributor

@daudrain daudrain commented Aug 23, 2017

Issue

The goal is to provide OSM node ids in nearest response as requested by #2548.

TODO list

  • update http docs
  • add regression / cucumber cases (see docs/testing.md)
  • review
  • adjust for comments

Requirements / Relations

Related to PR #2581

@MoKob MoKob changed the title Add osm nodes to nearest response [wip] Add osm nodes to nearest response Aug 24, 2017
nodes.values.push_back(from_node);
nodes.values.push_back(to_node);
}
waypoint.values["nodes"] = std::move(nodes);
Copy link
Member

Choose a reason for hiding this comment

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

Could you assert we never return the special osm id sentinel set above here please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current implementation may return SPECIAL_OSM_NODEID . This happens while doing a scan of Monaco area.
Would you suggest using an another special osm id value? or not returning such value in the response?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah we should not expose the osrm internal special node id to the outside. We should probably just ail with an error code in this edge case.

Copy link
Member

Choose a reason for hiding this comment

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

Hrm, would be interesting to see how this could happen. From my understanding there is a guarantee that at least one of forward and backward is enabled. The code in nearest.cpp should already bail out with NoSegement if we didn't found candidates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of edge case are one way case. In that case reverse_segment_id.enabled is false.

I wonder if it would not be better to use forward_segment_id only and get the previous node like this

auto osm_node_id = facade.GetOSMNodeIDOfNode(geometry[phantom_node.fwd_segment_position - 1]);

As @danpat commented in #2581 , the edge case would be when fwd_segment_position is zero. I guess this would require to find segments linked to forward_segment_id to access to their geometry.
Do you think this would be correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any feedback on my comment?

Copy link
Member

@TheMarex TheMarex left a comment

Choose a reason for hiding this comment

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

Thanks for pushing this forward! We have some integration tests in features/nearest/pick.feature that could use a test case. You might want to extend features/step_definitions/nearest.js to be able to check the nodes in the response.

This change also needs a CHANGELOG.md entry for adding the nodes property. Thanks!

std::uint64_t to_node = static_cast<std::uint64_t>(SPECIAL_OSM_NODEID);

auto segment_id = phantom_node.forward_segment_id.id;
if (segment_id != SPECIAL_SEGMENTID)
Copy link
Member

Choose a reason for hiding this comment

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

This checks should be replaced with phantom_node.forward_segment_id.enabled. There are cases where the ID is valid but the direction should not be used.

nodes.values.push_back(from_node);
nodes.values.push_back(to_node);
}
waypoint.values["nodes"] = std::move(nodes);
Copy link
Member

Choose a reason for hiding this comment

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

Hrm, would be interesting to see how this could happen. From my understanding there is a guarantee that at least one of forward and backward is enabled. The code in nearest.cpp should already bail out with NoSegement if we didn't found candidates.

@TheMarex
Copy link
Member

@DavidAudrain sorry I completely forgot about this PR. Anyway I've looked at your changes again and this iteration looks great. However our CI is complaining about code formatting.

Could you rerun ./scripts/format.sh? You will need clang-format version 3.8. Otherwise this looks good to merge to me.

@daudrain
Copy link
Contributor Author

Thank you @TheMarex for your feedback, I ran ./scripts/format.sh , it should be ok now.

@TheMarex TheMarex added this to the 5.14.0 milestone Oct 16, 2017
@TheMarex
Copy link
Member

Great, going to include this in 5.14.

@TheMarex TheMarex merged commit 963c042 into Project-OSRM:master Oct 19, 2017
@daniel-j-h
Copy link
Member

Ah just noticed, this should probably have a changelog entry and should show up in the release announcements.

@daudrain
Copy link
Contributor Author

@daniel-j-h I've added an entry to the changelog on the same branch. Should I do another PR to submit this modification?

@daniel-j-h
Copy link
Member

Either that or @TheMarex please include it in the final release changelog if you tag a release the next days.

@DraXus
Copy link
Contributor

DraXus commented Mar 6, 2018

This is handy, thanks! However there's no mention in the documentation about this new attribute: https://github.com/Project-OSRM/osrm-backend/blob/faff2c774d09a7227c77ae4fa40d22d54bb00b45/docs/http.md#nearest-service

Is there anything left on this pull request? Otherwise, I wouldn't mind to update the docs.

@TheMarex
Copy link
Member

TheMarex commented Mar 6, 2018

Is there anything left on this pull request? Otherwise, I wouldn't mind to update the docs.

Sorry about that, a PR would be much appreciated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants