Sort messages on same road
Currently messages referring to locations on the same road are sorted as follows:
- By directionality and direction (first forward, then bidirectional, then backwards)
- Parent locations before their children (e.g. the road is before its constituent points)
- Order of locations on the road (in the order in which they are encountered in the given direction)
An earlier sorting based on junction numbers was abandoned as it was unreliable (not every location has a junction number, and road direction is not guaranteed to correspond to the direction of numbering).
However, the current approach breaks when roads are non-contiguous. For example, the A93 in Bavaria is made up of two unconnected segments: one from Hof (interchange with A72) to Holledau (interchange with A9), another from Rosenheim (interchange with A8) to Kiefersfelden (where it becomes the Austrian A12). Points on one segment are not reachable from the other through a series of offsets, causing the sorting to fail. Options to deal with this:
- When locations of the same type are not connected through a series of offsets, compare their parents (after ensuring we are not comparing a location to its parent). Note, however, that disjoint segments may not be connected through offsets either.
- Failing that, fall back to junction numbers. Try to determine a pattern between junction numbers (which works only if at least one of the two locations has a true secondary location); failing that, assume junction numbers ascend when traveling in the direction of the road.
There are still corner cases which will not be caught by this, but I expect this to be an improvement over the current situation.