I've written code in Java using the
CodePudding user response:
All ways in the OpenStreetMap database have a direction. This is defined by the order of the referenced nodes: They are ordered from the start to the end of the way.
By itself, this direction has no meaning – it simply depends on where the mapper has started drawing. But certain tags on ways refer to the way's direction. If those tags appear on a way, you need to take the direction into account.
Examples for these tags appear in the documentation on the OSM wiki:
If you're creating edges for routing, you should also consider ...
- ... that it's possible to leave a way at any node that are shared with other ways, not just at the first and last node. Therefore, there is no 1:1 relationship between OSM ways and edges in a routing graph.
- ... that turn restrictions can prevent some turns at shared nodes.
- ... that the possible travel directions depend on your mode of transport (for example, a road may be oneway for cars, but two-way for bicycles).
- ... that other factors besides your mode of transport can affect direction of travel, such as the time of day for reversible oneways. However, this is something even many professional routing engines do not fully support.