Built-in support for OSRM
This library should offer built-in support for talking to an OSRM server directly. Similar to the existing support for Directions API v4, an OSRMRouteOptions class would inherit from RouteOptions, and we'd have subclasses of Route, RouteLeg, and RouteStep that perform any necessary translation of the JSON data into the Directions API format.
/ref mapbox/MapboxNavigation.swift#46 /cc @danpat
The scope of this feature would be a minimal compatibility layer; I don't think it would be worth porting all of the Directions API's logic directly to Swift. 😉
@freenerd points out that the Directions object would need to avoid setting the access_token parameter when used in conjunction with an OSRMRouteOptions object.
Copied from https://github.com/mapbox/mapbox-navigation-ios/issues/46#issuecomment-296352234:
Since MapboxDirections.swift currently only knows how to issue requests to the Mapbox Directions API, you’ll need to write your own code to construct the request URL to your OSRM server and send a request using URLRequest (in Swift) or NSURLRequest (in Objective-C). Then, use JSONSerialization/NSJSONSerialization to turn the response data into a Dictionary/NSDictionary before passing it to the Route initializer.
You’ll want to compare the OSRM response format with the Mapbox Directions API response format. Modify the dictionary representation of the response data to match the Directions API format. They already look very similar; I couldn’t spot any differences at a glance.