osmnx icon indicating copy to clipboard operation
osmnx copied to clipboard

get_nearest_edges() does not distinguish between parallel edges

Open alexvhicks opened this issue 6 years ago • 4 comments

Problem description (what did you do, what did you expect to happen, and what actually happened)

get_nearest_edges() specifies each edge by returning the osmid of the "u" and "v" nodes for the edge. Because the graph is a MultiDiGraph and supports parallel edges, this function should return the Key of the edge as well. My suggested fix is as follows:

On line 461 in geo_utils.py, in the function get_nearest_edges(),

ne = edges.loc[eidx, ['u', 'v', 'key']]

alexvhicks avatar Apr 06 '20 04:04 alexvhicks

Would you like to open a PR and I'll take a look?

gboeing avatar Apr 06 '20 16:04 gboeing

Sure!

alexvhicks avatar Apr 06 '20 18:04 alexvhicks

As noted there, it seems the issue I opened yesterday was a duplicate of this one. As such it's been closed in favor of discussion here.

II had a code solution suggested there as well, visible at https://github.com/gboeing/osmnx/issues/435. That said, it sounds like the above treats this as something that should be fixed rather than added as an option, which I agree with as a better approach. In that case all the places where I added if/else statements there could be reduced to just the part with the key, and the input variables could be removed. My local environment has finished reinstalling so if I get a moment today I'l try and submit a PR.

JNatael avatar Apr 30 '20 08:04 JNatael

Pull request submitted #439.

tomshaffner avatar Apr 30 '20 10:04 tomshaffner