Thursday, April 28, 2016

A little update on transit routing in Maps

So, I thought it is high time for a little update about the transit routing project in gnome-maps (thought I should make some post while we're still in April).
I talked a bit with Mattias Bengtsson before, and since he had been contemplating using OpenTripPlanner (OTP) for his GSoC project a couple of year ago and found it didn't scale too well for general turn-based routing, he was quite excited about my idea of combing GraphHopper and OTP, using OTP with just transit data (loaded from GTFS feeds).

The basic idea here (when in transit mode) is to first run a query against OTP and as a further step do a ”refinement“ by re-running the parts of the routes where OTP selects walking between two transit locations.

An additional step has proven nessesary, since OTP, when running without OpenStreetMap ”street data” will approximate the walking ”legs“ of the trip as a straight line, which can be too optimistic in some instances. Therefore we do an extra safe-calculation to see if a particular itinerary seems reasonable with respect to time needed for walking (this is needed when there's walking in the middle of an itinerary, and there's an upcoming transit section that needs to be ”caught”).

Anyway, some screenshots:

Here we can see an itinerary where there's some walking in the start, it also tries to recalculate walking parts in the start and end by using the actual starting points as selected in the routing pane, instead of relying on the ones returned by OTP, which are based on the nearest transit stop.
The reason the transit part of trip (the solid line) is “jagged“ is that the data used here doesn't include shapes for the transit lines, so in this case OTP will interpolate with intermediate stops passed by in between.

A bit more beatiful routes can be obtained using data from the bus company serving the island of Honolulu:

Currenly it is hard-wired to always show the first returned trip. Also, as you can see it still doesn't render any intructions lists and the combobox to select departing/arrival time is not hooked up to anything yet.

As before the code can be found in the wip/mlundblad/transit-routing branch.

Also, there's some bug that sometimes gives a segmentation fault in Clutter (possibly there's some race condition in the code I rewrote to allow dynamically creating routing layers, to allow showing the dashed and solid lines interchangably). Unfortunatly debugging these things from JS is not all that fun…