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

Include better OTP results in walk/bike directions when available. #351

Merged
merged 3 commits into from
May 9, 2024

Conversation

michaelkirk
Copy link
Member

Motivation

Finally following through with something I observed back in January: https://mapstodon.space/@ikawe/111744706335291719

bike route drawn on a map highlight quiet streets and a park cut through

OTP seems to provide consistently better biking directions than valhalla, so I want to prefer OTP over Valhalla when possible.

Background

We have two route providing backends: Valhalla and OpenTripPlanner. These are independent projects, and both sit behind our bespoke routing frontend travelmux.

Valhalla is fast, lightweight, and capable of spanning the entire planet, but doesn't provide transit directions (though I see some work has been done to move that forward in the last year).

OpenTripPlanner support transit, but is not capable of covering the entire planet. Instead we have separate regions that support transit — each with its own OTP instance. You can read more about our setup at https://about.maps.earth/posts/2023/03/adding-transit-directions-to-maps.earth/.

Previously, travelmux would simply delegate all transit requests to OTP and everything else would go to Valhalla.

However, OTP provides (in my anecdotal experience, see above) consistently better biking directions than Valhalla.

With this PR, we'll query OTP for bike/walk directions if OTP is available for that region. Then we'll mix that result in with the Valhalla results. Note OTP will only provide one result for biking and walking.

Valhalla provides some nice amenities like narrative route directions ("Go north on Broadway for 1.3 miles"), whereas OTP only provides schematic maneuvers { direction: "North", street: "Broadway", distance_meters: 2092}. There is an OTP frontend that builds some narration, but it's pretty simple (e.g. Unlike Valhalla, it doesn't consider previous steps for things like "Continue on the same street"), and it's in javascript. So part of this work was synthesizing narration. For now I've done a quick and crude job. There's not even any localization apart from km/miles. But I'd be happy to localize it if I get any feedback that anyone outside of en-US is using it. 🙃

A nice milestone reached is that, with this integration, www no longer uses the raw valhalla response. For expediency, up until this point I've been cheating — although there was a travelmux response that intended to abstract the differences between OTP and Valhalla, as a pragmatic concession (read: quick hack), I've also been including the original valhalla/OTP responses, allowing me to slowly migrate things into the travelmux response. I think we're done with that now (for valhalla anyway, OTP is still TBD). Even though I'm not using it directly, the valhalla response will remain for a while - it's useful for debugging.

And adapts www to use this new API.

Valhalla provides narrative instructions like "Turn left on 15th", for
OTP I had to synthesize them.

Note: there's currently no localization other than unit preference.
@michaelkirk michaelkirk merged commit fb250fb into main May 9, 2024
9 checks passed
@michaelkirk michaelkirk deleted the mkirk/otp-bike branch May 9, 2024 19:36
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.

1 participant