REST: Get only distance for solve route.

2796
2
08-21-2011 05:24 AM
MagusTan
New Contributor
Hello Guys,

Is there a way to retrieve only the distance for solve route function?

I'm only able to retrieve the entire data but my application just need to total distance.
0 Kudos
2 Replies
RaviNarayanan
Esri Contributor
The option to return directions will totalLength, but it includes the directions as well.

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route/solve?stops={+...
0 Kudos
DmitryKudinov
Occasional Contributor
Hi Magus,

If you need to find shortest (not fastest) route, you can solve using a distance-based cost attribute. The name of such attribute depends on particular network dataset service is working with, e.g. in case of Route service on sampleserver3.arcgisonline.com this is the "Length" cost attribute. List of available attributes can be found in the REST service directory e.g. http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route

So, if you are solving based on a Distance cost attribute (shortest path):

Ask server to return no directions, no route geometry:
http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route/solve?stops=-1...

In another case, when route is built using a Time-based cost attribute (fastest route), in order to return length of the built route (Distance value), you will need ask the service to accumulate Distance-based costs along the route using the accumulateAttributeNames parameter, e.g.:

http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route/solve?stops=-1...

Dmitry
0 Kudos