In From Paper Maps to Digital Routing Engine, we reviewed what it took to develop a scalable technology forward approach for delivering turn-by-turn directions in Denver to improve upon the digital and paper maps that had previously been distributed. This implementation was primarily focused on Denver which meant that it was roughly one single routing server that needed to be production ready at any given time. The next phase of growth for Bike Streets meant that we needed to replace this singularly Denver focused process with a process that could run for any supported city.
This work chronicles the migration from a process that was shipping new Denver data approximately every one to two months to a more advanced process that has allowed ~500 different routing engines to be deployed across the 20 currently supported cities in the 9 months since the work was initially completed.
Scale Map Editing
The initial approach for this, as discussed in the previous post, was to have a copy of OpenStreetMap (OSM) data with an internally accessible openstreetmap-website Rails application for editing. Edits on this website were made directly to our internal fork of OSM data but this hampered our ability to scale since we had little control over what was allowed to be changed with the tight coupling to the OSM structure. Within this process, as anyone who has edited OSM data knows, iD is the typical tool used by map contributors to add, update, or remove data in OSM. The goal was to retain the use of this familiar tool but add the ability to edit more metadata as well as handling OSM data changes that might require subsequent review.
The initial part of scaling up this process involved moving the storage of what is Low-Stress (and other internal Bike Streets metadata) to our normal internal database instead of a fork of OSM data that would be updated infrequently. We forked iD as the main interface to mark up and edit OSM within the Bike Streets system.
OpenStreetMap iD editor showing Flagstaff, AZ
The typical iD functionality will gradually download the visualized data via tiled requests (for example, /api/0.6/map.json?bbox=-122.26684570312499,37.84015683604136,-122.2613525390625,37.844494798834575) to the OSM backend and then allow the user to make changes, additions, or removals to that data. The edits are accumulated and then ultimately an OSM changeset packages up these edits to encapsulate the data change in OSM.
The process with Bike Streets included isn’t much different since the data still needs to be requested per tile but now a compound request is made to the OSM and Bike Streets backend which results in the normal OSM data with the Bike Streets data merged into it. The changeset side of the operations is a little more complex but generally works similar to the standard workflow. The Bike Streets iD fork will take the Network Editor’s set of changes, remove all the Bike Streets information to avoid adding clutter to OSM, and then create a changeset like normal. The result of that changeset (which typically results in a new version of any underlying ways) will be used as the source of truth to upload to the Bike Streets backend with the internal information included. This internal information includes whether the way has been reviewed (more on that later), an internal name override to help with directions for pieces of infrastructure like sidewalks that are unnamed in OSM, and whether people should explicitly ride or walk a bicycle on the way.
Processing OSM Diffs
Now the Bike Streets backend had a copy of the OSM data for all ways that were on the Low-Stress network. This data can be changed by anyone in the world and therefore a process was needed to process chunks of changes to make sure our representation was truthful to the on-the-ground Low-Stress network. OSM (thankfully!) provides a set of diffs updated minutely to keep datastores up to date. Overpass API (thankfully!) provides the same set of diffs but augmented to be slightly more useful for our purposes (primarily marking up way nodes with their coordinates). A minutely task was added to the Bike Streets backend to download these diffs and compare the resulting data to what we have in our database.
Mapmaker QA tool showing Denver, CO
The first type of conflict happens when a way is deleted. This means an OSM contributor removed the way from the public data and (typically) replaced it with another one. The internal Bike Streets way is updated to this state so Network Editors know that the previous way needs to be replaced by a new or existing OSM way. This is odd to show in the internal iD editor because (unlike most of the data) this will no longer exist in the rendered OSM data. Instead, we rely on iD’s ability to render overlays and highlight the missing geometry in red so what needs to be replaced is obvious. This overlay approach, which uses standard raster tile images, also enables rendering the Low-Stress network at lower zoom levels where iD hides the OSM data.
Editor with data that needs reviewed
The second type of conflict happens when a way geometry is changed. This means that an OSM contributor either added, edited, or deleted some set of nodes in the underlying way. This could be as simple as moving nodes to make them better follow the on-the-ground infrastructure from satellite images or as complex as doubling the length by merging multiple ways together. Similar to the deletion case, the internal Bike Streets way is updated to a modified state and highlighted in orange so a Network Editor can confirm this still represents the desired Low-Stress network. This information is shown both in the overlay and an alternate color in the displayed OSM data to make it easier for a Network Editor to quickly validate the network.
Both conflict types intentionally require a human to inspect the data to ensure that the result is a reviewed and (still) Low-Stress option for people to use in their city.
Quality Assurance
Because we now controlled the web frontend presentation of the OSM data backing the Low-Stress network and otherwise, we could show the result of processing the OSM diffs (including edited way geometries and deleted ways) and more. This dramatically helped decrease the complexity of managing conflicts in the OSM data. Unrelated to OSM changes, there was still a desire to validate endpoints (leaf nodes) of the Low-Stress network. Previously, this relied on using a separate tool to visualize the parsed output of the network and wasn’t dynamically regenerated when the network was changed.
Old interface for viewing network leaf nodes.
These can now easily be displayed right in the Network Editor interface to validate or fix all the endpoints. It’s common for data changes in the diff process to produce missing connections when ways are edited because, typically, a new way was split off an existing one to provide a higher fidelity of information on some portion. In the current process, the new way, despite being likely the same nodes as before, isn’t included in our internal data yet and needs to be reviewed by a Network Editor. But this means that there will be a gap in the Low-Stress network at this location so this tooling helps simply visualize these problems.
New Orleans, LA endpoints while being built.
iD was now in charge of a handful of things:
Downloading the underlying OSM data (in normal iD fashion) and merging in any internal information from our database.
Editing OSM data (in normal iD fashion) and uploading the post-changeset information to our database.
Displaying deleted and mutated ways.
Displaying Low-Stress network endpoints.
Deployment
Now that the data was represented in our system in a more dynamic fashion, the mechanism to deploy the underlying OSRM servers needed to be updated. The new approach downloads a slice of OSM data from OSM By The Slice representing a city, applies the internal OSM data fixups such as name overrides and inaccessible way removal, creates a new server, and then gives the modified OSM to the computer to start the OSRM server. This part is a relatively simple orchestration of a handful of computers but it was a drastic departure from before since we now had infrastructure to deploy new data easily. This helps to evaluate changes to our internal OSRM profile all with the click of a button by deploying multiple routing servers in a given city to compare routes before and after some changes.
Router showing Petaluma, CA.
A simple internal tool known as Router is used to validate that a given server is generating the routes that would be expected for a given city (sorta like a simple version of getting directions in Google Maps or otherwise). And, similar to before but now dynamically accessible, Network Editors can use the Inspector to validate that the output of OSRM looks as expected.
New Orleans, LA OSRM Inspector.
Wrapping Up
These changes made it possible, along with the countless contributions of our distributed group of Network Editors, to get Low-Stress bike routes in many more cities such as Flagstaff, AZ, Indianapolis, IN, and many others.
Download the Bike Streets app today to discover Low-Stress routes to any destination in your city. And support our work to help us keep building the bike movement in cities across the country!