We’re building support for external raster data sources in OSRM. This will unlock countless possibilities in OSRM — most immediately for us it means the ability to run elevation-aware routing profiles, letting us better optimize for the way humans really bike or walk.
The OSRM raster source feature is data-agnostic, meaning it’s BYOData — it can consume just about any geo-referenced raster dataset. The elevation case is obvious, where queried values are numeric, but you could also write a routing profile to optimize for any kind of data you have — air quality, crime rates, you name it. Since it’s written natively in C++, it doesn’t introduce the magnitude of slowdown inherent to database queries.
Using an external data source in a routing profile is easy — just as OSRM Lua profiles require a node_function and a way_function, they’ll optionally call a source_function to load a source into memory and a segment_function to query that source per graph segment. So your profile would now have two additional functions that look like this:
That means later this summer, the bicycle profile on the Mapbox Directions API, which has thus far been insensitive to any kind of hill or mountain, will return something much more sensible for the average urban bicyclist. We’re fine-tuning the parameters on a sample we’ve got running with a Bay Area extract, and we’re pretty excited about the results. Below, the red and pink lines represent new routes, dashed gray is the default bicycle route, and the graph represents elevation:
Keep an eye out for the raster source feature to be merged into mainline OSRM in the near future and the elevation-aware bicycle routing profile in the Mapbox Directions API. Hit me up on Twitter if you want to talk routing at @lbudorick.