When joining ways for routes that split and then re-join, there are many cases where the joining process will cause the resulting collection to spiral back on itself at a roundabout or divided highway merger rather than continuing along with the main length of highway.
Here are a few examples:
One potential way to fix this is that instead of ordering ways in a route solely by OSM-id before joining, instead the ways could be sorted such that two-way ways come first, followed by normal one-way ways, followed by roundabout ways, *_link ways, and other connectors. Within these groups, ways would be still ordered by OSM-id. This would allow the join process to always try to attach the two-way non-divided highway ways first when encountering a split/merge. Only if no two-way ways can be joined would the join continue on to the other-type ways.
When joining ways for routes that split and then re-join, there are many cases where the joining process will cause the resulting collection to spiral back on itself at a roundabout or divided highway merger rather than continuing along with the main length of highway.
Here are a few examples:
One potential way to fix this is that instead of ordering ways in a route solely by OSM-id before joining, instead the ways could be sorted such that two-way ways come first, followed by normal one-way ways, followed by roundabout ways, *_link ways, and other connectors. Within these groups, ways would be still ordered by OSM-id. This would allow the join process to always try to attach the two-way non-divided highway ways first when encountering a split/merge. Only if no two-way ways can be joined would the join continue on to the other-type ways.