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

Consider oneway:bus for bidirectionality #1216

Open
3 tasks done
stertingen opened this issue Sep 9, 2024 · 1 comment
Open
3 tasks done

Consider oneway:bus for bidirectionality #1216

stertingen opened this issue Sep 9, 2024 · 1 comment

Comments

@stertingen
Copy link

Contributing guidelines

  • I understand the contributing guidelines

Documentation

  • My proposal is not addressed by the documentation or examples

Existing issues

  • Nothing similar appears in an existing issue

What problem does your feature proposal solve?

Consider https://www.openstreetmap.org/way/6878440
This street is only bidirectional for buses.
When searching for a path for city buses, edges along this way are not considered.

What is your proposed solution?

Expose oneway exception types to graph API, similar to network_type.

https://wiki.openstreetmap.org/wiki/Key:oneway:bus
https://wiki.openstreetmap.org/wiki/Key:oneway:psv
https://wiki.openstreetmap.org/wiki/Key:oneway:bicycle

graph = ox.graph_from_polygon(bounds, network_type="drive_service", oneway_type="bus")
should consider oneway:bus if it exists, oneway otherwise.

What alternatives have you considered?

Workaround considered: Download graph, change oneway attribute, rebuild graph

ox.settings.useful_tags_way = list(
    dict.fromkeys(ox.settings.useful_tags_way + ["oneway:bus"])
)
graph = ox.graph_from_polygon(bounds, network_type="drive_service", simplify=False)
nodes, edges = ox.graph_to_gdfs(graph, nodes=True, edges=True)
edges["oneway"] = edges["oneway"] & ~edges["oneway:bus"].eq("no")
graph = ox.graph_from_gdfs(nodes, edges)

However, it seems to me that graph_from_gdfs does not consider oneway.

Additional context

Example: https://www.openstreetmap.org/way/6878440

@stertingen
Copy link
Author

Functional workaround:

nodes, edges = ox.graph_to_gdfs(graph, nodes=True, edges=True)
bidirectionalEdges = edges[edges["oneway:bus"].eq("no")]
bidirectionalEdges.index.rename(["v", "u", "key"], inplace=True)
bidirectionalEdges = bidirectionalEdges.reorder_levels(["u", "v", "key"])
graph = ox.graph_from_gdfs(nodes, pd.concat([edges, bidirectionalEdges]))

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

No branches or pull requests

1 participant