How to implement costs on routes?

487
0
08-26-2016 09:28 AM
Pedro_LuizCumino
New Contributor

I have the report coming from an external service, which comes as a JSON object. It informs me the location where an issue is present and must be considered when calculating the route, like a cost to the lane stretch pointed by the latitude and longitude from the issue JSON object. The issues are classified as highmedium or low level. I need to set this cost to the lane stretch and then compare if it's worthwhile to select the late stretch where the issue is present or if select another route is a better decision.

 

How open is the route solver service in order to implement this kind of cost over a route? The idea at the end is to select the lower cost route by comparing the issue level, the time travelling and the travelled distance using my own algorithm.

 

What I've seen so far were these links below. However, I'm struggling to understand if it can be or not implemented using the Javascript API.

RouteParameters-amd | API Reference | ArcGIS API for JavaScript 

RestrictionAttributes Property 

Using parameters with network attributes—Help | ArcGIS for Desktop 

 

The figures 1 and 2 illustrate what I'm looking for. The figure 1 shows the route A as the best one to be chosen, even with an issue place on it (the issue with the lowest level). The route B is the worst since it has the highest issue level/cost. The route D is possible to reach the end, but the cost would be too high to be chosen, what makes it the worst route. Figure 2 shows the route B as the best route to be chosen because the cost of the issue on B is lower than the cost that the total distance of D represents. 

Figure 1

Figure 2

This is the given example of restriction given by the API reference. But how it is implemented as a restriction when calculating the route?

 

routeParams.attributeParameterValues = [{
attributeName: "Restriction",
parameterName: "25 MPH",
value: "2.5"
}];

In summary, I need a way to insert a cost to certain routes (using the information from coming from another service) and then calculate the route considering such costs. At the end, the algorithm to be implemented will consider both issues and route distances.

Thanks in advance!

0 Kudos
0 Replies