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

Issue in Valhalla distances #138

Open
gmcrocetti opened this issue Feb 14, 2025 · 0 comments
Open

Issue in Valhalla distances #138

gmcrocetti opened this issue Feb 14, 2025 · 0 comments

Comments

@gmcrocetti
Copy link

Hello @nilsnolde ,

Great library, it helps me a lot.

I believe we have a problem in how distances of the Valhalla router are computed.

There are two places where this happens:

  1. In the directions response:
    factor = 0.621371 if units == "mi" else 1
  2. In matrix computation:
    factor = 0.621371 if units == "mi" else 1

So consider the following request:

valhalla_client = Valhalla()

points = [[-122.332070, 47.606210], [-122.200676, 47.610378]]  # Seattle, WA to Bellevue, WA ~10.4 miles
result = valhalla_client.matrix(points, profile="auto", sources=[0], destinations=[1], units="mi")

The response should be ~10.4 (using google maps as the source of truth) but it is 6416 which is ~10.4 * 0.621371 * 1000. Despite Valhalla responding in miles it is converted again.

I'm going to submit a patch for this, makes sense ?

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