mapzen/on-the-road_android

Multiple Waypoints

sangeetaggomes opened this issue · 5 comments

I am trying route with multiple location (more than two say three points). When I do route.getGeometry() in RouteCallback success I get the latitude and longitude only between the first and second location. Is there any way where in I can get the latitude and longitude of the route between all the 3 points ?
Thanks in advance

Multiple waypoints is not yet officially supported. Well it is by the Valhalla service just not yet in this project.

Currently the query string is hardcoded to only support two locations and likely the polyline parsing algorithm would also need to be updated but I have not tested it yet.

You could try updating JSON.java to allow more than two locations and see what breaks?

Hi,

Im currently working on adding this. I've made changes so that the request sends along all the added waypoints, but I'm still only getting 2 points in return.

I'm currently looking at the "polyline parsing algorithm" but since I'm not really familiar with Kotlin, I can't seem to figure out why it only returns the first 2 points.

Any help would be well apreciated

Currently initializePolyline(...) is only called for the first "leg" in the trip.

initializePolyline(jsonObject.getJSONObject(KEY_TRIP).getJSONArray(KEY_LEGS).
        getJSONObject(0).getString(KEY_SHAPE))

https://github.com/mapzen/on-the-road_android/blob/master/library/src/main/java/com/mapzen/valhalla/Route.kt#L69-L70

For a response that includes waypoints the shape field in each "leg" will need to be parsed then concatenated to build the complete list of nodes for the entire route.

I have added support and created a pull request for this.

This has been implemented