Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow custom OSRM servers #46

Closed
emiltin opened this issue Feb 22, 2017 · 9 comments
Closed

allow custom OSRM servers #46

emiltin opened this issue Feb 22, 2017 · 9 comments

Comments

@emiltin
Copy link

emiltin commented Feb 22, 2017

many users of OSRM run their own OSRM servers. it would make MapboxNavigation.swift more useful if it's easy to connect to your own OSRM server.

a problem is that the mapbox directions API does not return raw OSRM responses, but use a node app to modify/amend it before returning it. either the expected format should be documented or the code used to modify the OSRM response should be open sourced.

@willylambert
Copy link

Exactly the feature i'm looking for.

@1ec5
Copy link
Contributor

1ec5 commented Apr 5, 2017

MapboxNavigation.swift doesn't deal with API responses directly; it uses Route objects that MapboxDirections.swift creates from the API response. MapboxDirections.swift has methods to produce Route objects from JSON (deserialized as Foundation objects).

My understanding is that the OSRM v5 and Directions API v5 responses are already very similar, so an OSRM response wouldn't need to be modified heavily before being passed into those JSON-based initializers. Still, I agree that it would be nice for MapboxDirections.swift to have built-in support for OSRM v5 alongside the existing support for Directions API v4 and v5: mapbox/mapbox-directions-swift#121.

Closing, because there won't be anything to modify in this project once MapboxDirections.swift gains OSRM support.

@blinters
Copy link

so whats the conclusion?

@1ec5
Copy link
Contributor

1ec5 commented Apr 20, 2017

It’s already possible to use this library with a custom OSRM server, as long as you pass the right JSON structure into Route(json:waypoints:routeOptions:). (This may require modifying the JSON response you get from OSRM; I’m not sure how involved that would be, but it doesn’t sound particularly difficult.) Please see mapbox/mapbox-directions-swift#121, which would simplify this step so that you’d be able to pass in an unmodified OSRM response.

This ticket is closed because MapboxNavigation and MapboxCoreNavigation use the Route object created by MapboxDirections.swift, regardless of the server endpoint that provided the underlying data.

@blinters
Copy link

will try it out! thanks pal!

@blinters
Copy link

Has anyone managed to connect to your own OSRM server and modify your own JSON response structure? 1ec5 mentioned mapbox/mapbox-directions-swift#121 "which would simplify this step so that you’d be able to pass in an unmodified OSRM response". Apparently that post doesn't have much information to go about doing it

@1ec5
Copy link
Contributor

1ec5 commented Apr 22, 2017

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.

@jadiaheno
Copy link

Any news on this particular issue?

@sajeel
Copy link

sajeel commented Nov 10, 2019

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants