Azure Map's get route directions not working with duplicate coordinates.

Priyanka Solanki 0 Reputation points
2024-09-23T09:49:36.47+00:00

I am using Azure Map's route/directions API and passing some duplicate locations but I am not able to get the result. If I remove duplicate locations get the response.

Following this documentation https://learn.microsoft.com/en-us/rest/api/maps/route/get-route-directions?view=rest-maps-2024-04-01&tabs=HTTP but not able to find anything regarding duplicate coordinates.

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
734 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Faraz Siddiqui 90 Reputation points Microsoft Employee
    2024-09-25T19:55:36.66+00:00

    Are you able to share the request? If not, what error does the service return and is there a use case for passing duplicate waypoints?

    We have a new Route Directions service which is the most recent version and based on the Bing Maps Routing. Can you please give it a try and let us know if it works for your scenario.

    https://learn.microsoft.com/en-us/rest/api/maps/route/post-directions?view=rest-maps-2023-10-01-preview&tabs=HTTP

    1 person found this answer helpful.
    0 comments No comments

  2. rbrundritt 18,671 Reputation points Microsoft Employee
    2024-09-23T17:02:20.31+00:00

    Generally you shouldn't put duplicate locations into a route request. In many cases it won't matter, but in some situations it could become an unrouteable request. The routing service takes your locations and snaps them to the nearest logical road, within a few limitations. It will often take the last snapped coordinate into consideration. This could result in a situation where your duplicate location is snapped to a point behind where the first coordinate was, and would require a U-turn, but if the road is a one-way road, may not be an option. Sure a much longer route could potentially be calculated but the routing service likely notices that something isn't right and stops.

    That said, there is a newer route service that will likely make it to Azure Maps in the next year or so that would likely handle this situation much better.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.