Skip to content

fix: force 'units' kwarg to 'kilometers' in Valhalla router #146

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

Merged
merged 2 commits into from
Jul 28, 2025

Conversation

mthh
Copy link
Owner

@mthh mthh commented Jul 28, 2025

Following #139, we shouldn't allow the user to pass a “units” argument as a kwarg for the directions and matrix methods of the Valhalla router.

If users use a units kwarg, perhaps it would be a good idea to warn them with a warning saying that their units argument has not been taken into account?
@nilsnolde what do you think?

If we ever support kwargs for OpenRouteService (cf. #42) , we should do the same thing.

@nilsnolde
Copy link
Collaborator

I didn't really follow up on the other PR, but yeah, I'd also argue to remove all support for units for any router (if that's the argument). It's too trivial for users to convert themselves. And anyways, fuck imperial units haha they're straight outta hell.

@mthh
Copy link
Owner Author

mthh commented Jul 28, 2025

I didn't really follow up on the other PR, but yeah, I'd also argue to remove all support for units for any router (if that's the argument). It's too trivial for users to convert themselves. And anyways, fuck imperial units haha they're straight outta hell.

Indeed, that is already the case (#139 removes unit conversion logic from the various routers concerned, makes explicit the fact that Duration.distance is always in meter, and adds methods to Direction to convert to miles / kilometers).

But still, since we dont control what users pass as kwargs to the relevant routers (listed in #42), they can break the constraint “Direction.distance is always in meters” without routingpy noticing.
So this PR is about preventing the user from passing units=“mi” as a kwarg for Valhalla (which would break the assumption that Direction.distance stores the value in meters).

@mthh mthh merged commit b1f1dcd into master Jul 28, 2025
13 of 17 checks passed
@mthh mthh deleted the kwarg-units-val branch July 28, 2025 17:20
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

Successfully merging this pull request may close these issues.

2 participants