If you publish routing services using configure routing services dialog box from ArcGIS Enterprise portal website, or publish using publish routing services command line utility, use the following endpoint to access the /solve direct request. The {{folder represents the folder in which the services are being published.
GET https://{{machineName}}/{{serverWebAdaptorName}}/rest/services/{{folderName}}/NetworkAnalysis/NAServer/Route/solveThe /solve direct request find the best way to get from one location to another or to visit several locations.
The Route service can be used to find the best way to get from one location to another or to visit several locations.
The best route can be the quickest route for a given time of day considering the traffic conditions during that time, or it can be the shortest route that minimizes the travel distance. The Route service can also find the best route that visits each stop during permitted time windows you specify. If you have more than two stops to visit, the best route can be determined for the fixed order of locations you specify. This is called a simple route. Alternatively, the Route service can determine the best sequence in which to visit the locations (the traveling salesman problem). This is called an optimized route.
The solve operation is performed on a network layer resource. The solve operation is supported on a network layer with a layer value of esri.
Parameters
| Name | Required | Type | Default | Description |
|---|---|---|---|---|
f | string | The request response format, either | ||
token | string | An access token with the required privileges. | ||
stops | locations | feature | layer | Two or more locations between which the route is generated. | ||
travelMode | object | The mode of transportation for the analysis provided as a JSON object. | ||
startTime | datetime | "now" | The time at which travel begins from the input stops. | ||
startTimeIsUTC | boolean |
| The time zone or zones of the | |
timeWindowsAreUTC | boolean |
| The time, either coordinated universal time (UTC) or geographically local time, for the | |
findBestSequence | boolean |
| Reorders stops to find an optimized route. | |
preserveFirstStop | boolean |
| Preserves the first stop while reordering others. Used if | |
preserveLastStop | boolean |
| Preserves the last stop while reordering others. Used if | |
useTimeWindows | boolean |
| Sets whether the service will consider time windows specified on stops. | |
restrictUTurns | string |
| Restricts or allows a route to make U-turns at junctions. | |
useHierarchy | boolean |
| Specifies whether hierarchy will be used when finding the shortest path. | |
impedanceAttributeName | string |
| The type of impedance, such as | |
accumulateAttributeNames | string |
| Accumulates values other than the value set in the | |
restrictionAttributeNames | string | The restrictions that should be honored by the service. | ||
attributeParameterValues | [object] | Additional values required by an attribute or restriction. | ||
barriers | locations | feature | layer | One or more points that act as temporary restrictions, additional time, or distance. | ||
polylineBarriers | feature | layer | One ore more lines that prohibit travel anywhere the lines intersect the streets. | ||
polygonBarriers | feature | layer | Polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets. | ||
returnDirections | boolean |
| Generates the driving directions for each route. | |
directionsLanguage | string |
| The language used when generating driving directions. | |
directionsOutputType | string |
| The content and length of the driving directions. Used if | |
directionsStyleName | string |
| The formatting style for the directions. Used if | |
directionsLengthUnits | string |
| The units to display the travel distance in driving directions. Used if | |
returnRoutes | boolean |
| Returns routes. | |
directionsTimeAttributeName | string |
| A time-based impedance attribute to display the duration of a maneuver. | |
outputLines | string |
| The type of route features that are returned. | |
returnStops | boolean |
| Returns stops. | |
returnBarriers | boolean |
| Returns barriers. | |
returnPolylineBarriers | boolean |
| Returns polyline barriers. | |
returnPolygonBarriers | boolean |
| Returns polygon barriers. | |
returnTraversedEdges | boolean |
| Returns traversed edges. | |
returnTraversedJunctions | boolean |
| Returns traversed junctions. | |
returnTraversedTurns | boolean |
| Returns traversed turns. | |
returnZ | boolean |
| Returns z- values for the returned geometries. | |
ignoreInvalidLocations | boolean |
| Ignores invalid input locations. | |
outSR | string | The spatial reference of output geometries. | ||
outputGeometryPrecision | number |
| Simplifies route geometry. | |
outputGeometryPrecisionUnits | string |
| The units for the value in the | |
geometryPrecision | integer | The number of decimal places in the response geometries. Applies to x and y values only. | ||
geometryPrecisionM | integer | The number of decimal places in the response geometries. Applies to m-values only. | ||
geometryPrecisionZ | integer | The number of decimal places in the response geometries. Applies to z-values only. | ||
overrides | string | For internal use only. | ||
preserveObjectID | boolean |
| Preserves the object IDs from input locations when the input locations are returned as output. | |
returnEmptyResults | boolean |
| Returns empty results instead of the error property when a request fails. | |
locateSettings | object | Determines how input data are located. |
Required parameters
token
Specify a token that provides the identity of a user that has the permissions to access the service. The security and authentication page provides more information about how an access token can be obtained.
"token=<yourToken>"stops
The locations the output route or routes will visit.
When specifying the stops, you can set attributes for each as follows:
Show attributes for stops
Attributes for stops
-
Namestring (length: 500)nullable
The name of the stop. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output stops, routes, and directions.
-
ObjectIDinteger (non-negative)nullable
The object ID of the stop.
Objectis a unique identifier for the stop. If you want to maintain a relationship between input and output, setID preservetoObject ID true, and theObjectvalue of the input stop is included in the output routes (as theID Stopfield). TheID Objectvalue is also included in the output stops (as theID Objectfield) and can be used to join additional information from the analysis outputs to the attribute of the stops. If theID Objectvalue is not specified, a unique ID is automatically generated in the output.ID
-
SourceIDinteger (non-negative)nullable
The numeric identifier of the network dataset source feature class on which the input point is located.
-
SourceOIDinteger (non-negative)nullable
The object ID of the feature in the source on which the input point is located.
-
PosAlongnumber (non-negative)nullable
The position along the digitized direction of the source line feature. This value is stored as a ratio. This attribute is null if the network location references a junction.
-
SideOfEdgeint enumnullable
Allowed values:
1,2The side of the edge in relation to the digitized direction of the line feature.
This attribute is limited to a domain of two values:
1: Right Side2: Left Side
-
RouteNamestring (length: 1024)nullable
The name of the route to which the stop is assigned. Assigning the same route name to different stops causes those stops to be grouped together and visited by the same route. You can generate many routes in a single solve by assigning unique route names to different groups of stops.
For example, to find two distinct routes—a route with four stops and another with six stops—set
RoutetoName Route1for each of the four stops andRoute2for each of the six stops. The service will produce two distinct routes and driving directions for each group of stops in a single request.If
Routeis not specified for any stops, all stops belong to the same route. IfName Routeis not specified for some stops, those stops are treated as unassigned and are not included in any route.Name -
Sequenceintegernullable
If the
findparameter is set toBest Sequence false, the output routes will visit the stops in the order you specify with this attribute. In a group of stops that have the sameRoutevalue, the sequence number should be greater than 0 but not greater than the total number of stops. Also, the sequence number should not be duplicated.Name
-
TimeWindowStartdatetimenullable
The earliest time the stop can be visited. By specifying a start and end time for a stop's time window, you are defining when a route should visit the stop. When the impedance attribute is either specified by the
impedanceparameter value or theAttribute Name impedanceparameter value of the travel mode is time-based, the analysis will find a solution that minimizes overall travel and reaches the stop within the prescribed time window.Attribute Name The value is specified as an integer that represents the number of milliseconds since epoch (January 1, 1970).
This value can be specified either in UTC or local time, depending on the value given for the
timeparameter.Windows Are UTC If you specify this attribute, you also need to specify the
Timeattribute.Window End
-
TimeWindowEnddatetimenullable
The latest time the stop can be visited. By specifying a start and end time for a stop's time window, you are defining when a route will visit the stop. When the travel mode for the analysis uses an impedance attribute that is time based, specifying time-window values will cause the analysis to find a solution that minimizes overall travel and reaches the stop within the prescribed time window.
Together, the
TimeandWindow Start Timeattributes make up the time window within which a route can visit the stop. As withWindow End Time, theWindow Start Timevalue is specified as an integer that represents the number of milliseconds since epoch (January 1, 1970) and is interpreted as UTC or local time, depending on the value specified for theWindow End timeparameter.Windows Are UTC The time window specified using the
TimeandWindow Start Timeattributes is not considered a hard constraint by the service. That is, the service doesn't fail if the stop cannot be visited during the time window; instead, the service tries to find a route that visits the stop during its time window, but if time-window violations are inevitable, the service tries to find a solution that minimizes the time-window violation time for all stops in the problem.Window End If a route has to arrive early at the stop, a wait time is added to the total travel time of the route. Similarly, if the route arrives late at the stop, a violation time is added to the total travel time of the route. For example, If the time window on the stop is set as 10:00 AM to 11:00 AM and the earliest a route can reach the stop is 11:25 AM, a violation of 25 minutes is added to the total travel time.
-
CurbApproachint enumdefault:0
Allowed values:
0,1,2,3Specify the direction a vehicle can arrive at and depart from the stop. The options are as following:
0: Either side of vehicle. The vehicle can approach and depart the stop in either direction. U-turns are allowed. You should choose this setting if your vehicle can make a U-turn at the order or if it can pull into a driveway or parking lot and turn around.1: Right side of vehicle. When the vehicle approaches and departs the stop, the curb must be on the right side of the vehicle. A U-turn is prohibited.2: Left side of vehicle. When the vehicle approaches and departs the stop, the curb must be on the left side of the vehicle. A U-turn is prohibited.3: No U-turn. When the vehicle approaches the stop, the curb can be on either side of the vehicle; however, the vehicle must depart without turning around. Learn more about U-turn policies
Show illustration
Setting Coded value Description Either side of vehicle
0
The vehicle can approach and depart the stop in either direction, so a U-turn is allowed at the stop. This is the default value. This setting can be chosen if it is possible and desirable for a vehicle to turn around at the stop. This decision may depend on the width of the road and the amount of traffic or whether the stop has a parking lot where vehicles can pull in and turn around.
All arrival and departure combinations are allowed with the Either side of vehicle curb approach.
Right side of vehicle
1
When the vehicle approaches and departs the stop, the stop must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the right side.
The allowed arrival and departure combination for the Right side of vehicle curb approach is shown.
Left side of vehicle
2
When the vehicle approaches and departs the stop, the stop must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the left side.
The allowed arrival and departure combination for the Left side of vehicle curb approach is shown.
No U-Turn
3
When the vehicle approaches the stop, the stop can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived. A U-turn is prohibited.
The allowed arrival and departure combinations for the No U-Turn curb approach are shown.
The
Curbattribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, choose 1 (Right side of vehicle) in the United States and 2 (Left side of vehicle) in the United Kingdom.Approach
With right-hand traffic, the curb approach that leaves the vehicle closest to the stop is Right side of vehicle.
With left-hand traffic, the curb approach that leaves the vehicle closest to the stop is Left side of vehicle.
-
Attr_[Cost]number (non-negative)default:0nullable
The name of the attribute can be:
Attr,_Travel Time Attr,_Truck Travel Time Attr,_Minutes Attr,_Truck Minutes Attr,_Walk Time Attr,_Miles Attr_Kilometers This attribute specifies how much additional time spent or distance traveled can occur at the stop. The value for this attribute is included in the total travel time or distance for the output routes and is also displayed in output directions or directionPoints as service time.
The value for this attribute is specified in the units of the cost attribute. For instance,
Attris in minutes._Travel Time Use cases:
You can add time to a stop to represent how long it takes to make a delivery, install equipment, or perform another task at the stop. Or the time required to reach the actual destination location from the location the stop locates on the streets. Similarly, adding extra distance may be useful to account for a long driveway or other road that isn't represented by the network dataset.
For example, suppose you are finding the best route through three stops. Suppose it requires 2 minutes to walk to the street location from where the route starts, you need to spend 10 minutes at Stop 2, and it takes 5 minutes to walk from the street location to the destination. The
Attrattribute should be given values of 2, 10, and 5 for Stop 1, Stop 2, and Stop 3, respectively. If it takes 10 minutes to travel from Stop 1 to Stop 2 and 10 minutes to travel from Stop 2 to Stop 3, the total travel time to reach Stop 3 is displayed as 37 minutes (2 + 10 + 10 + 10 + 5), even though there is only 20 minutes of traveling to reach Stop 3._Travel Time However, when a distance-based cost attribute like
Milesis used, it specifies the distance in miles that will be added when calculating total distance of the route. Generally the locations of the stops are not exactly on the streets but are set back somewhat from the road. TheAttrattribute can be used to model the distance between the actual stop location and its location on the street if it is important to include that distance in the total travel distance._Miles Attris only referenced if_Miles Milesis used in the analysis as impedance or accumulate attribute. -
LocationTypeint enumdefault:0
Allowed values:
0,1,2Specifies the stop type. The field value is specified as one of the following integers (use the numeric code, not the name in the parentheses):
0: Stop—A location that the route will visit.1: Waypoint—A location that the route will travel through without making a stop. Waypoints can be used to force the route to take a specific path (to go through the waypoint) without being considered an actual stop. Waypoints do not appear in directions.2: Break—A location where the route stops for the driver to take a break.
-
Bearingnumber (non-negative)nullable
The direction in which a point is moving. The units are degrees and are measured clockwise from true north.
This attribute is used in conjunction with the
Bearingattribute. Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle. Using this attribute tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass, for example. Bearing also helps the solver determine the side of the street that the point is on.Tol -
BearingTolnumber (range: 0 - 180)default:30nullable
The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the
Bearingattribute.If the
Bearingattribute value is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated. The units are in degrees. A value of 30 means that when Network Analyst attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge. -
NavLatencynumber (non-negative)nullable
Indicates how much cost is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.
This attribute is only used in the solve process if the
BearingandBearingfields also have values; however, providing aTol Navattribute value is optional, even when values are present in theLatency BearingandBearing.Tol
Example
The example shows how to specify the Name attribute for each stop and group four stops into two routes, Route A and Route B, using the Route attribute.
{
"features": [
{
"geometry": {
"x": -122.4079,
"y": 37.78356
},
"attributes": {
"Name": "From",
"RouteName": "Route A"
}
},
{
"geometry": {
"x": -122.404,
"y": 37.782
},
"attributes": {
"Name": "To",
"RouteName": "Route A"
Optional parameters
travelMode
Choose the mode of transportation for the analysis.
Travel modes are managed and configured in ArcGIS Enterprise by the administrator of your organization to better reflect the organization's workflows.
startTime
Specify the time at which travel begins from the input stops.
The start parameter can be used in the following three ways in your analysis:
startis not specified— If theTime startparameter has no value specified, the service uses static road speeds based on average historical speeds or posted speed limits. It uses posted speeds in areas where historical traffic information isn't available.Time
startspecified asTime now—If thestartparameter is specified asTime now, live traffic will be used where available.
Example
Specify value of now
The analysis will begin at current time and live traffic speeds are referenced in the analysis.
{ "startTime": "now" }startspecified as specific day/time— If theTime startparameter is specified as a time and day of the week, or live traffic is not available, historical traffic will be used.Time
Example
Typical traffic on Sundays
17:00, January 7, 1990. Typical traffic on Sundays at 5:00 p.m.
{ "startTime": 631731600000 }startTimeIsUTC
Specify the time zone or zones of the start parameter.
If a value of now is passed to start parameter, the travel begins at current time. This will also override start parameter value to be true.
-
false—Thestartvalue refers to the time zone in which the first stop of each route is located. The start time uses the time zone that is geographically local to the first stop.Time Illustration of setting the value to
false(use geographically Local time zone)Setting
startto 9:00 a.m., January 4, 1990 (631443600000 milliseconds);Time starttoTime Is UTC false; and submitting a valid request causes the drive times for points in the eastern time zone to start at 9:00 a.m. eastern Time and 9:00 a.m. central time for points in the central time zone. (The start times are offset by an hour in real or UTC time.)
Input: startis 9:00 a.m., January 4, 1990 (631443600000 milliseconds), andTime startis set toTime Is UTC false -
true—Thestartvalue refers to coordinated universal time (UTC). The start times for all points are simultaneous, regardless of time zones.Time Illustration of setting the value to
true(use UTC)Setting
startto 9:00 a.m., January 4, 1990 (631443600000 milliseconds);Time starttoTime Is UTC true, the start times for points in the eastern time zone is 4:00 a.m. Eastern Time and 3:00 a.m. central time for those in the central time zone.
Input: startis 9:00 a.m., January 4, 1990 (631443600000 milliseconds), andTime startis set toTime Is UTC true
timeWindowsAreUTC
Specify whether the Time and Time attribute values on stops are specified in UTC or geographically local time.
See the startTimeIsUTC parameter for an explanation of UTC versus local time.
findBestSequence
Specify whether the service should reorder stops to find the optimized route.
false—The service returns a route that visits stops in the order you define.true—The service finds the best order to visit the stops. The service will account for a variety of variables so that the total travel distance or travel time for the route is minimized.
You can preserve the origin and the destination stops while allowing the service to reorder intermediary stops by setting the preserve and preserve parameters.
preserveFirstStop
Specify whether the service will keep the first stop fixed when reordering the stops.
true—The service won't reorder the first stop. Choose this option if you are starting from a known location, such as your home, headquarters, or current location.false—The service will not preserve the first stop and reorder all the stops.
This parameter is applicable only if the find parameter value is true .
preserveLastStop
Specify whether the service will keep the last stop fixed when reordering the stops.
true—The service won't reorder the last stop. The output routes may begin at any stop but must end at the predetermined last stop.false—The service will not preserve the last stop and reorder all the stops.
This parameter is applicable only if the find parameter value is true .
useTimeWindows
Specify whether the service will consider time windows specified on the stops when finding the best route. The time windows are specified on stops using the Time and Time attributes.
restrictUTurns
Allowed values: esri, esri, esri, esri
Specify whether to restrict or permit the route from making U-turns at junctions.
To understand the available parameter values, a junction is a point where only two streets intersect each other. If three or more streets intersect at a point, it is called as an intersection. A cul-de-sac is a dead-end.
Expand to learn more about the available parameter values
This parameter can have the following values:
| Parameter Value | Description |
|---|---|
| U-turns are permitted everywhere. Permitting U-turns implies that the vehicle can turn around at a junction and double back on the same street.
U-turns are permitted at junctions with any number of adjacent streets. |
| U-turns are prohibited at junctions where exactly two adjacent streets meet.
U-turns are permitted only at intersections or dead ends. |
| U-turns are prohibited at all junctions and intersections and are permitted only at dead ends.
U-turns are permitted only at dead ends. |
| U-turns are prohibited at all junctions, intersections, and dead-ends. Even when this parameter value is chosen, a route can still make U-turns at stops. To prohibit U-turns at a stop, you can set its |
useHierarchy
Specify whether hierarchy will be used when finding the shortest paths.
true—Use hierarchy when travelling between stops. When hierarchy is used, the service prefers higher-order streets (such as freeways) to lower-order streets (such as local roads) and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes to faraway locations, because drivers on long-distance trips tend to prefer traveling on freeways where stops, intersections, and turns can be avoided. Using hierarchy is computationally faster, especially for long-distance routes, since the service can determine the best route from a relatively smaller subset of streets.false