taxicab
taxicab copied to clipboard
Taxicab bug exceptional case two nodes
I am having an exceptional case. My nx_shortest path is giving me 2 nodes. The taxicab algorithm then solves two partial edges. However in the code, my route is set to nx_route=[ ]. After that, the intersections is solved between the partial edges, which cannot be found. Thus, this path is giving an error.
The description in code is saying: "when the nx route is just a single node, this is a bit of an edge case", however it includes routes of two nodes. I think this is a bug.
This is an image of how the path should look like (blue: nx_route, green: partial edges)
Fixed it by adding following in taxicab shortest_path. Also changed first case from 2 to 1.
elif len(nx_route) == 2:
route_edge = get_edge_geometry(G, (nx_route[0], nx_route[1], 0))
if route_edge.intersects(orig_partial_edge_1):
orig_partial_edge = orig_partial_edge_1
if route_edge.intersects(orig_partial_edge_2):
orig_partial_edge = orig_partial_edge_2
if route_edge.intersects(dest_partial_edge_1):
dest_partial_edge = orig_partial_edge_1
if route_edge.intersects(orig_partial_edge_2):
dest_partial_edge = orig_partial_edge_2