Get distance from source to destination via way-points

423
3
10-30-2017 07:46 AM
PrakashMani
New Contributor II

I am using asynchronous routing service to find the distance between source and destination via way-points. When I give way-points, I am getting different value in the Total_Kilometers(83) field but the actual distance is only 33 KM. Can someone please tell to get the actual distance from source to destination via way-points?

Request:

{
"type": "features",
"LocationType": "1",
"features": [{
"geometry": {
"x": 80.1604766845703,
"y": 13.0624952316284
}
},
{
"geometry": {
"x": 80.1640701293945,
"y": 13.1163520812988
}
},
{
"geometry": {
"x": 80.2768020629883,
"y": 13.218768119812
}
},
{
"geometry": {
"x": 80.0792617797852,
"y": 12.8535680770874
}
}
]
}

Response:

{
"paramName": "Output_Routes",
"dataType": "GPFeatureRecordSetLayer",
"value": {
"displayFieldName": "",
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
}
...
...
"features": [{
"attributes": {
"OID": 1,
"Name": "Location 1 - Location 4",
"StopCount": 4,
"Total_Minutes": 124.55307562869066,
"Total_Kilometers": 83.201435897857806,
"FirstStopOID": 1,
"LastStopOID": 4,
"Total_Miles": 51.698979999999999,
"Shape_Length": 0.75629657258452343
},
...

Tags (1)
0 Kudos
3 Replies
JaySandhu
Esri Regular Contributor

I think you should check your inputs. 

You are sending in three points but the output response says four stops:

   "Name": "Location 1 - Location 4",
   "StopCount": 4,

So there could be an extra "stop" being sent that is causing the path to be longer.

Jay Sandhu

PrakashMani
New Contributor II

Sorry Jay, gave wrong request. Updated the question with correct(4 stops) request payload. 

As the stop points are getting increased, the Total_Kilometers is also getting increased. Actual distance b/w source and destination is 33 KM. If I just give source and destination, I am getting correct result, 33 KM. If I add 4 stops(2 interim, 1 source, 1 destination), KM is getting increased to 83, If add 2 more stops, its getting increased to 126 KM. I don't know hot to get only 33 KM even if I add interim points.

0 Kudos
JaySandhu
Esri Regular Contributor

The route solver will solve a path through the stops in the order you give them in. So If you solve a path with the coordinates you provided, you get a path that is 83 KM. See the order in the screen shot below.