Incorrect Duration when using Minute as Unit TimeUnitType.Minute

Reny Mathew Abraham 20 Reputation points
2023-06-26T09:38:14.66+00:00

While using BingMapsRESTToolkit to calculate distance with unit as TimeUnitType.Minute the duration returned in incorrect and larger than the value return while using unit TimeUnitType.Second.

TimeUnits = TimeUnitType.Minute //returns 180600

TimeUnits = TimeUnitType.Second // returns 3010

Value returned for Second unit type seems correct. Keeping the Vehicle spec as same for both.

Shouldn't Minute values be larger that seconds value

Is this the right way to get distance

var time2 = responseList[0].GetTime(0, 0);

        var duration = responseList[0].GetCell(0, 0).TravelDuration;
     var request = new DistanceMatrixRequest()
Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
0 comments No comments
{count} votes

Answer accepted by question author
  1. rbrundritt 21,576 Reputation points Microsoft Employee Moderator
    2023-06-26T16:15:55.6933333+00:00

    I double checked the source code the BingMapsRESTToolkit and it is correctly setting Minute as the time unit on the distance matrix request. The response is parsed as-is returned from the service. As a test, you can check the POST body being created for your request using the GetPostRequestBody method. In there you should see timeUnit: 'minute'

    Can you provide a sample of the POST body where you are seeing the issue. Then we can try calling the service directly and seeing if its an issue with the response from the service.

    Update

    The Bing Maps Distance Matric API does not support truck, so the BingMapsRESTToolkit tries to workaround this by leveraging the truck routing service using this code: https://github.com/microsoft/BingMapsRESTToolkit/blob/master/Source/Internal/TruckDistanceMatrixGenerator.cs Digging through the code it looks like for the first cell it accidentally multiplies by 60 rather than dividing in this line of code: https://github.com/microsoft/BingMapsRESTToolkit/blob/3a18ed3d5c4ab9516423ec54ad9f2658dfce5eff/Source/Internal/TruckDistanceMatrixGenerator.cs#L113 All other cells look to be converted correctly. I made a pull request on the project to fix this issue, however I'm not sure when the NuGet package will be updated again (last updated in 2018). With this in mind, you might want to just divide the first cell by 3600 (divide by 60 to get back to seconds, then divide by 60 to get to minutes).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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