Find better bicycle routes with new Valhalla options
Valhalla, Mapzen’s free and open source routing and navigation engine, has been updated with an assortment of bicycle navigation enhancements. You can now influence the path of the bicycle route and the estimated travel time by including optional costing settings for the type of bicycle, your speed, or whether you want to ride on streets with traffic.
By specifying the bicycle type in a query to the routing service API, Valhalla can suggest more appropriate routes and accurate times for you. While some kinds of bicycles are designed only for paved surfaces, others also work well on gravel and dirt paths, and Valhalla can route and estimate accordingly. Each bicycle type has a default cycling speed, which is intended to be what an average rider can comfortably maintain over the length of the route. You may ride faster or slower than the defaults, so you can now override the speed with your own value.
For example, if you are riding a road bike (a lightweight bicycle with narrow tires), you want your route only to follow paved surfaces. Perhaps you also want to take a slower-paced trip and minimize riding on roads where you must travel with cars.
The JSON for this query might look something like this:
This particular query builds a bicycle route to the library at the University of California, Santa Barbara. It includes parameters for riding a
Road bicycle at a
cycling_speed of 17 kilometers per hour. The
use_roads value is a range from 0 to 1, indicating an increasing tolerance for riding with vehicle traffic. By specifying a value closer to 0, though, your query shows a preference for designated bicycle paths, when available. (Note that you would need to substitute your own API key at the end to perform the query.)
To visualize your trip, which is a little over a kilometer in length, you can draw the route line over an OpenCycleMap basemap, which is built from OpenStreetMap data to emphasize cycling. On OpenCycleMap, cycle paths are shown with dashed blue lines, and footpaths are the dashed brown lines.
The Valhalla response provides distances and estimated times en route for the entire trip, as well as details for the component legs. Each maneuver has turn-by-turn instructions, including for the bicycle-only roundabouts you will pass through on this trip.
If you choose not to set any bicycle costing options, the route is tuned for road bicycles and the kinds of roads they can access, with a slight preference for using cycleways or roads with bicycle lanes.
Keep in mind that Valhalla bicycle routes do not currently consider elevation factors such as hills and steepness, but this is coming soon.