Skip to content

Fix distance calculation consistency #5316

@danpat

Description

@danpat

For various historical reasons, OSRM is using a mix of great circle distance, haversine distance, and https://github.com/mapbox/cheap-ruler-cpp to calculate distances in various points throughout the codebase. This leads to some weird behaviour, like route(A->B) giving a different distance to table(A->B).

We should use https://github.com/mapbox/cheap-ruler-cpp everywhere - it offers good performance, and very good precision (https://github.com/mapbox/cheap-ruler#precision) for the use-cases that OSRM cares about.

What'll change here:

  • Test data.js should be updated to more accurately place coordinates for test cases
  • Test results should be updated for new distances - my hope is to have more round numbers (100m, etc) for simple test cases, rather than lots of "100.1" or "99.8".
  • Some route selection might change due to slightly different distance being used to calculate edge costs. Impacts should be fairly small here, and will only show up in cases when two distances were very close.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions