JS API Directions Widget Accuracy

1310
8
Jump to solution
02-12-2018 10:16 AM
by Anonymous User
Not applicable

Hello,

I would like to implement the Directions widget, but I have some reservation about the accuracy of the drive times, and directions provided by the sample service which powers the widget. For example, I am using the following troute and want to know the shortest path:

Start: 1400 Pike St, Marietta, OH, 45750, USA

End: 3210 State Route 345 NE, New Lexington, Ohio, 43764, USA

When you do this in the Sandbox for the Direction Widget Sample you get a totally different path then you would if you enter the same route for directions in Google Maps. Therefore I am hesitant to trust this ArcGIS JS API Directions Widget. Does anyone know if there is a bug here, or can anyone explain to me the logic used in the widget that is making it unable to produce a more accurate/efficient route?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
DeeleshMandloi
Esri Contributor

Dru,

    You are getting a sub-optimal route because of how the routing algorithm works for this particular case. Let me elaborate a bit more on this. By default, the routing algorithm is using hierarchy which is a way to say that get on higher level streets such as freeways as quickly as you can from your starting location and then stay on higher level streets for as long as you can until you are close to your destination.

The opposite approach to this is to use all the available streets and find the shortest route. This is called exact route. Finding an exact route is computationally intensive as the "search" space can be very large. For example, imagine finding a route between LA and New York, using the exact approach. Such a request has the possibility of searching through most of the street network and probably run out of memory or time out.

So for any "long" routes, the routing service in ArcGIS Online (the one used by Directions widget by default) only finds hierarchical routes. The service does support finding exact routes but limits the extent of input stops to be up to 50 miles. That's to say you can do exact routes only for short routes.

The routing service API also supports what we call as overrides. These are additional settings that can be passed to the service to override certain default behavior of the algorithms. One such override setting is called TopHierarchyLevel. The default value for this setting is 1. Setting this to a higher value essentially allows the service to consider more streets before it hops on to a higher level street. Using your stops as input and a value of 4 for this property, gets you a route very similar to the one you are getting on google maps.

Below are the request parameters for the same route but with TopHierarchyLevel set to 4. With this the total travel time is now 85 minutes (as compared to 95.4 minutes).

The directions widget does not expose setting the overrides. However if you can use the RouteTask from ArcGIS JavaScript API, you can set the overrides parameter on RouteParameters to get this route.

In general the hierarchical routing algorithms works fine for most cases. But occasionally, you run into such cases for which you need to override some settings to get the desired route. 

f=json&returnDirections=true&returnRoutes=false&returnZ=true&returnStops=true&returnBarriers=false&returnPolygonBarriers=false&returnPolylineBarriers=false&outSR=102100&outputLines=esriNAOutputLineTrueShape&findBestSequence=false&preserveFirstStop=true&preserveLastStop=true&useTimeWindows=true&startTime=1519240930076&startTimeIsUTC=true&timeWindowsAreUTC=true&accumulateAttributeNames=Miles%2CKilometers%2CMinutes%2CTravelTime&ignoreInvalidLocations=true&restrictUTurns=esriNFSBAtDeadEndsOnly&directionsLanguage=en&outputGeometryPrecision=0&outputGeometryPrecisionUnits=esriMeters&directionsLengthUnits=esriNAUMiles&travelMode=%7B%22attributeParameterValues%22%3A%5B%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Unpaved+Roads%22%2C%22value%22%3A%22AVOID_HIGH%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Private+Roads%22%2C%22value%22%3A%22AVOID_MEDIUM%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Driving+an+Automobile%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Through+Traffic+Prohibited%22%2C%22value%22%3A%22AVOID_HIGH%22%7D%2C%7B%22parameterName%22%3A%22Vehicle+Maximum+Speed+(km%2Fh)%22%2C%22attributeName%22%3A%22TravelTime%22%2C%22value%22%3A0%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Roads+Under+Construction+Prohibited%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Gates%22%2C%22value%22%3A%22AVOID_MEDIUM%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Express+Lanes%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Carpool+Roads%22%2C%22value%22%3A%22PROHIBITED%22%7D%5D%2C%22description%22%3A%22Models+the+movement+of+cars+and+other+similar+small+automobiles%2C+such+as+pickup+trucks%2C+and+finds+solutions+that+optimize+travel+time.+Travel+obeys+one-way+roads%2C+avoids+illegal+turns%2C+and+follows+other+rules+that+are+specific+to+cars.+When+you+specify+a+start+time%2C+dynamic+travel+speeds+based+on+traffic+are+used+where+it+is+available.%22%2C%22impedanceAttributeName%22%3A%22TravelTime%22%2C%22simplificationToleranceUnits%22%3A%22esriMeters%22%2C%22uturnAtJunctions%22%3A%22esriNFSBAtDeadEndsAndIntersections%22%2C%22restrictionAttributeNames%22%3A%5B%22Avoid+Unpaved+Roads%22%2C%22Avoid+Private+Roads%22%2C%22Driving+an+Automobile%22%2C%22Through+Traffic+Prohibited%22%2C%22Roads+Under+Construction+Prohibited%22%2C%22Avoid+Gates%22%2C%22Avoid+Express+Lanes%22%2C%22Avoid+Carpool+Roads%22%5D%2C%22useHierarchy%22%3Atrue%2C%22simplificationTolerance%22%3A10%2C%22timeAttributeName%22%3A%22TravelTime%22%2C%22distanceAttributeName%22%3A%22Kilometers%22%2C%22type%22%3A%22AUTOMOBILE%22%2C%22id%22%3A%22FEgifRtFndKNcJMJ%22%2C%22name%22%3A%22Driving+Time%22%7D&stops=%7B%22type%22%3A%22features%22%2C%22features%22%3A%5B%7B%22geometry%22%3A%7B%22x%22%3A-9061941.545%2C%22y%22%3A4778115.294699997%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%2C%22latestWkid%22%3A3857%7D%7D%2C%22attributes%22%3A%7B%22CurbApproach%22%3Anull%2C%22TimeWindowStart%22%3Anull%2C%22TimeWindowEnd%22%3Anull%2C%22Attr_Minutes%22%3A0%2C%22Attr_TravelTime%22%3A0%2C%22Attr_Miles%22%3A0%2C%22Attr_Kilometers%22%3A0%2C%22Attr_TimeAt1KPH%22%3A0%2C%22Attr_WalkTime%22%3A0%2C%22Attr_TruckMinutes%22%3A0%2C%22Attr_TruckTravelTime%22%3A0%2C%22Name%22%3A%221400+Pike+St%2C+Marietta%2C+OH%2C+45750%2C+USA_1008%22%7D%7D%2C%7B%22geometry%22%3A%7B%22x%22%3A-9149838.8682%2C%22y%22%3A4827500.293799996%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%2C%22latestWkid%22%3A3857%7D%7D%2C%22attributes%22%3A%7B%22CurbApproach%22%3Anull%2C%22TimeWindowStart%22%3Anull%2C%22TimeWindowEnd%22%3Anull%2C%22Attr_Minutes%22%3A0%2C%22Attr_TravelTime%22%3A0%2C%22Attr_Miles%22%3A0%2C%22Attr_Kilometers%22%3A0%2C%22Attr_TimeAt1KPH%22%3A0%2C%22Attr_WalkTime%22%3A0%2C%22Attr_TruckMinutes%22%3A0%2C%22Attr_TruckTravelTime%22%3A0%2C%22Name%22%3A%223210+State+Route+345+NE%2C+New+Lexington%2C+Ohio%2C+43764%2C+USA_1009%22%7D%7D%5D%2C%22doNotLocateOnRestrictedElements%22%3Atrue%7D&directionsOutputType=esriDOTComplete&overrides=%7B%22TopHierarchyLevel%22+%3A+4%7D

View solution in original post

8 Replies
RobertScheitlin__GISP
MVP Emeritus

Dru,

   The road network data behind esri data may be less robust then the data provided by Google which spends a great deal of money and investment in it road network data collection.

0 Kudos
by Anonymous User
Not applicable

While yes you are correct, Google has invested a lot into this feature. However ESRI is supposed to be the worldwide leader in Geospatial software, tools and solutions. ESRI has resources, one would think they would be more inclined to provide a better sample service for the directions function. If the routes were only 5 maybe 10 minutes difference I would NOT be as concerned. However they are as much as 30-40 mins different, which is wild! If I am ESRI I am doing my best to make this service more useful... 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Dru,

  You also need to consider that you are using a sample service not one that is to be used in production applications.

by Anonymous User
Not applicable

I definitely hear what your saying, and it is a valid point. However when you use that sample in a demo in front of an audience and it fails. It has one scratching their head that is for sure. 

BjornSvensson
Esri Regular Contributor
by Anonymous User
Not applicable

Any idea why its giving me inefficient directions? As I pointed out you get completely different directions then when you would use Google Maps. The widget gives directions that are greater distances and travel times then the best possible route. Input the following directions into the ESRI widget, then do so using Google Maps. The difference in distance and travel time is absurd. 

Start: 1400 Pike St, Marietta, OH, 45750, USA

End: 3210 State Route 345 NE, New Lexington, Ohio, 43764, USA

0 Kudos
DeeleshMandloi
Esri Contributor

Dru,

    You are getting a sub-optimal route because of how the routing algorithm works for this particular case. Let me elaborate a bit more on this. By default, the routing algorithm is using hierarchy which is a way to say that get on higher level streets such as freeways as quickly as you can from your starting location and then stay on higher level streets for as long as you can until you are close to your destination.

The opposite approach to this is to use all the available streets and find the shortest route. This is called exact route. Finding an exact route is computationally intensive as the "search" space can be very large. For example, imagine finding a route between LA and New York, using the exact approach. Such a request has the possibility of searching through most of the street network and probably run out of memory or time out.

So for any "long" routes, the routing service in ArcGIS Online (the one used by Directions widget by default) only finds hierarchical routes. The service does support finding exact routes but limits the extent of input stops to be up to 50 miles. That's to say you can do exact routes only for short routes.

The routing service API also supports what we call as overrides. These are additional settings that can be passed to the service to override certain default behavior of the algorithms. One such override setting is called TopHierarchyLevel. The default value for this setting is 1. Setting this to a higher value essentially allows the service to consider more streets before it hops on to a higher level street. Using your stops as input and a value of 4 for this property, gets you a route very similar to the one you are getting on google maps.

Below are the request parameters for the same route but with TopHierarchyLevel set to 4. With this the total travel time is now 85 minutes (as compared to 95.4 minutes).

The directions widget does not expose setting the overrides. However if you can use the RouteTask from ArcGIS JavaScript API, you can set the overrides parameter on RouteParameters to get this route.

In general the hierarchical routing algorithms works fine for most cases. But occasionally, you run into such cases for which you need to override some settings to get the desired route. 

f=json&returnDirections=true&returnRoutes=false&returnZ=true&returnStops=true&returnBarriers=false&returnPolygonBarriers=false&returnPolylineBarriers=false&outSR=102100&outputLines=esriNAOutputLineTrueShape&findBestSequence=false&preserveFirstStop=true&preserveLastStop=true&useTimeWindows=true&startTime=1519240930076&startTimeIsUTC=true&timeWindowsAreUTC=true&accumulateAttributeNames=Miles%2CKilometers%2CMinutes%2CTravelTime&ignoreInvalidLocations=true&restrictUTurns=esriNFSBAtDeadEndsOnly&directionsLanguage=en&outputGeometryPrecision=0&outputGeometryPrecisionUnits=esriMeters&directionsLengthUnits=esriNAUMiles&travelMode=%7B%22attributeParameterValues%22%3A%5B%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Unpaved+Roads%22%2C%22value%22%3A%22AVOID_HIGH%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Private+Roads%22%2C%22value%22%3A%22AVOID_MEDIUM%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Driving+an+Automobile%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Through+Traffic+Prohibited%22%2C%22value%22%3A%22AVOID_HIGH%22%7D%2C%7B%22parameterName%22%3A%22Vehicle+Maximum+Speed+(km%2Fh)%22%2C%22attributeName%22%3A%22TravelTime%22%2C%22value%22%3A0%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Roads+Under+Construction+Prohibited%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Gates%22%2C%22value%22%3A%22AVOID_MEDIUM%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Express+Lanes%22%2C%22value%22%3A%22PROHIBITED%22%7D%2C%7B%22parameterName%22%3A%22Restriction+Usage%22%2C%22attributeName%22%3A%22Avoid+Carpool+Roads%22%2C%22value%22%3A%22PROHIBITED%22%7D%5D%2C%22description%22%3A%22Models+the+movement+of+cars+and+other+similar+small+automobiles%2C+such+as+pickup+trucks%2C+and+finds+solutions+that+optimize+travel+time.+Travel+obeys+one-way+roads%2C+avoids+illegal+turns%2C+and+follows+other+rules+that+are+specific+to+cars.+When+you+specify+a+start+time%2C+dynamic+travel+speeds+based+on+traffic+are+used+where+it+is+available.%22%2C%22impedanceAttributeName%22%3A%22TravelTime%22%2C%22simplificationToleranceUnits%22%3A%22esriMeters%22%2C%22uturnAtJunctions%22%3A%22esriNFSBAtDeadEndsAndIntersections%22%2C%22restrictionAttributeNames%22%3A%5B%22Avoid+Unpaved+Roads%22%2C%22Avoid+Private+Roads%22%2C%22Driving+an+Automobile%22%2C%22Through+Traffic+Prohibited%22%2C%22Roads+Under+Construction+Prohibited%22%2C%22Avoid+Gates%22%2C%22Avoid+Express+Lanes%22%2C%22Avoid+Carpool+Roads%22%5D%2C%22useHierarchy%22%3Atrue%2C%22simplificationTolerance%22%3A10%2C%22timeAttributeName%22%3A%22TravelTime%22%2C%22distanceAttributeName%22%3A%22Kilometers%22%2C%22type%22%3A%22AUTOMOBILE%22%2C%22id%22%3A%22FEgifRtFndKNcJMJ%22%2C%22name%22%3A%22Driving+Time%22%7D&stops=%7B%22type%22%3A%22features%22%2C%22features%22%3A%5B%7B%22geometry%22%3A%7B%22x%22%3A-9061941.545%2C%22y%22%3A4778115.294699997%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%2C%22latestWkid%22%3A3857%7D%7D%2C%22attributes%22%3A%7B%22CurbApproach%22%3Anull%2C%22TimeWindowStart%22%3Anull%2C%22TimeWindowEnd%22%3Anull%2C%22Attr_Minutes%22%3A0%2C%22Attr_TravelTime%22%3A0%2C%22Attr_Miles%22%3A0%2C%22Attr_Kilometers%22%3A0%2C%22Attr_TimeAt1KPH%22%3A0%2C%22Attr_WalkTime%22%3A0%2C%22Attr_TruckMinutes%22%3A0%2C%22Attr_TruckTravelTime%22%3A0%2C%22Name%22%3A%221400+Pike+St%2C+Marietta%2C+OH%2C+45750%2C+USA_1008%22%7D%7D%2C%7B%22geometry%22%3A%7B%22x%22%3A-9149838.8682%2C%22y%22%3A4827500.293799996%2C%22spatialReference%22%3A%7B%22wkid%22%3A102100%2C%22latestWkid%22%3A3857%7D%7D%2C%22attributes%22%3A%7B%22CurbApproach%22%3Anull%2C%22TimeWindowStart%22%3Anull%2C%22TimeWindowEnd%22%3Anull%2C%22Attr_Minutes%22%3A0%2C%22Attr_TravelTime%22%3A0%2C%22Attr_Miles%22%3A0%2C%22Attr_Kilometers%22%3A0%2C%22Attr_TimeAt1KPH%22%3A0%2C%22Attr_WalkTime%22%3A0%2C%22Attr_TruckMinutes%22%3A0%2C%22Attr_TruckTravelTime%22%3A0%2C%22Name%22%3A%223210+State+Route+345+NE%2C+New+Lexington%2C+Ohio%2C+43764%2C+USA_1009%22%7D%7D%5D%2C%22doNotLocateOnRestrictedElements%22%3Atrue%7D&directionsOutputType=esriDOTComplete&overrides=%7B%22TopHierarchyLevel%22+%3A+4%7D

by Anonymous User
Not applicable

I will give this a shot. I figured the issue was related to Hierarchy, however I was thinking there was a bug. I am elated to learn there is an override.

0 Kudos