Google Summer of Code Final Report: Reintroducing Transit to Valhalla
Posted by ChrisPark on 11 September 2022 in English.Project Abstract
The primary aim of this Google Summer of Code project is to re-introduce transit support in Valhalla, the OpenStreetMap based Routing Engine. Initially, Valhalla supported a mode to route transit, but due to a bottleneck from a third-party library, it became unviable to continue support transit routing. Therefore, the aim of the project is to directly parse raw General Transit Feed Specification (GTFS) data and remove the dependency.
The high level overview of the project is visible here:
Specific details of each pull request will be described below.
What has been done
The first stage of the project was importing GTFS and ensuring that we can parse the data. GTFS is a set of text files, and rather than iterating through them manually, I decided to use a third party library to automize the read-write process. Just_gtfs allows us to read and store transit data in variables rather than manually trying to parse text. Moreover, I can create sample test data without being concerned about creating invalid data.
After parsing GTFS data, the next step was to pre-process them so that they could fit into Valhalla’s existing data format. Firstly, since the map is divided into tiles – square regions of equal area – I sorted the data according to which tile it belongs to. Tiles are beneficial to save computing power because only the information that belong inside the tile need to be processed when routing through small regions.
The sorted data then needed to be built into protobufs, which are used as intermediary data storage before they are converted to tiles. Protobufs are much more condense and versatile than raw GTFS data, so we extract the relevant information from GTFS into protobufs and gather the data. This is further useful because instead of iterating through each stop or trip of a tile, the tile could be read as one whole entity, streamlining the reading process.
