Direct request

URL:
https://<root>/<serviceName>/NAServer/<layerName>/solveClosestFacility
Methods:
GETPOST
Version Introduced:
10.0

Finding the closest hospital to an accident, the closest police cars to a crime scene, and the closest store to a customer's address are examples of problems that can be solved using the Closest facility service. When finding the closest facilities, you can specify how many to find and whether the direction of travel is toward or away from them. Once you've found the closest facilities, you can display the best route to or from them and include the travel time, travel distance, and driving directions to each facility. The service can use current traffic conditions when determining the best routes. You can also specify an impedance cutoff beyond which the service will not search for a facility. For instance, you can set up a Closest facility service to search for hospitals within a 15-minute drive time of the site of an accident. Any hospitals that take longer than 15 minutes to reach will not be included in the results. The hospitals are referred to as facilities, and the accident is referred to as an incident. The service allows you to perform multiple closest facility analyses simultaneously. This means you can have multiple incidents and find the closest facility or facilities to each incident.

The solveClosestFacility operation is performed on a network layer resource of type closest facility.

You can provide arguments to the solveClosestFacility operation as query parameters defined in the parameters table below.

Update at 11.0

  • Use locateSettings to specify settings that affect how inputs are located.
  • Use returnEmptyResults to return empty results instead of an error when the request fails.

Updates at 10.9.1

Updates at 10.8.1

When the authoring application for services is ArcGIS Pro, you can specify the now value in the timeOfDay parameter to set the analysis to begin or end at the current time.

Updates at 10.8

Use the preserveObjectID parameter to specify whether the object IDs from the input locations will be preserved when the input locations are returned as output.

Updates at 10.5

Use the overrides parameter to specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

Updates at 10.4

Pass in a complete JSON representation of a travel mode through travelMode and automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.

Updates at 10.3

Use the travelMode parameter to automatically set override values for various other parameters to quickly and consistently model cars, trucks, a type of truck, and so on.

Updates at 10.2.1

Use the timeOfDayIsUTC parameter to specify whether the timeOfDay parameter value is in UTC or the time zone of the facilities or incidents. Using timeOfDayIsUTC , you can start or end all routes at the same time regardless of the time zone where the facilities and incidents are located.

Updates at 10.1

  • M-values—The OutputLines parameter supports a new value: esriNAOutputLineTrueShapeWithMeasure . If specified, returned routes, compressed geometry, and service area lines will contain m-values on each vertex.
  • Z-values—The Closest Facility solver supports the new returnZ parameter. If returnZ=true and the Closest Facility solver is using a z-aware network dataset, returned routes and compressed geometry will contain z-values on each vertex. Input point and line locations can have z-values on them.
  • Routes—Directions in the response include the hasZ or hasM property to indicate whether the geometry includes z-values or m-values, respectively.
  • CompressedGeometryCompressedGeometry can contain m- and z-values and indicates how to decompress them.
  • Use the optional url property to specify input facilities , incidents , barriers , polylineBarriers , or polygonBarriers values. The url value contains a REST Query request to a feature, map, or geoprocessing service returning a JSON feature set. The advantage of using this property is that locations can be passed directly from a service endpoint as input to the network analysis operation, bypassing the client as intermediate storage.
  • TimeOfDay and TimeOfDayUsage —The 10.1 Closest Facility solver is time aware and can be used in conjunction with historic and real-time traffic information.

Request parameters

ParameterDescription

incidents

(Required)

One or more locations from which the service searches for the nearby locations. These locations are referred to as incidents.

Syntax:

facilities

(Required)

One or more locations that are searched for when finding the closest location.

Syntax:

token

(Required)

The identity of a user who has permissions to access the service.

f

(Optional)

Specify the response format. The default value is html .

Values: html | json | pjson

travelMode

(Optional)

The mode of transportation for the analysis.

Value: JSON object

defaultTargetFacilityCount

(Optional)

The number of closest facilities to find per incident.

travelDirection

(Optional)

Specify whether the search for the closest facility is measured from the incident to the facility or from the facility to the incident.

Values: esriNATravelDirectionToFacility | esriNATravelDirectionFromFacility

defaultCutoff

(Optional)

The travel time or travel distance value at which to stop searching for facilities for a given incident.

timeOfDay

(Optional)

The time and date to depart from or arrive at incidents or facilities. You can also use the now value to set the depart or arrive time to the current time.

timeOfDayIsUTC

(Optional)

Specify the time zone or zones of the timeOfDay parameter.

Values: true | false

timeOfDayUsage

(Optional)

Specify whether the timeOfDay parameter value represents the arrival or departure time for the routes.

Values: esriNATimeOfDayUseAsStartTime | esriNATimeOfDayUseAsEndTime

useHierarchy

(Optional)

Specify whether hierarchy will be used when finding the shortest paths.

Values: true | false

restrictUTurns

(Optional)

Specify how U-turns at junctions will be handled on the route.

Values: esriNFSBAtDeadEndsAndIntersections | esriNFSBAllowBacktrack | esriNFSBAtDeadEndsOnly | esriNFSBNoBacktrack

impedanceAttributeName

(Optional)

Specify the impedance.

Values: TravelTime | Minutes | TruckTravelTime | TruckMinutes | WalkTime | Miles | Kilometers

accumulateAttributeNames

(Optional)

Specify whether the service will accumulate values other than the value specified for impedanceAttributeName . You can specify the values as in the example below:

Use dark colors for code blocksCopy
1
accumulateAttributeNames=Miles,Kilometers

Values: TravelTime | Minutes | TruckTravelTime | TruckMinutes | WalkTime | Miles | Kilometers

restrictionAttributeNames

(Optional)

Specify the restrictions that will be honored by the service. You can specify the values as in the example below:

Use dark colors for code blocksCopy
1
restrictionAttributeNames=Avoid Carpool Roads, Avoid Express Lanes, Avoid Gates, Avoid Private Roads, Avoid Unpaved Roads, Driving an Automobile, Roads Under Construction Prohibited, Through Traffic Prohibited

For a complete list of values, see the restrictionAttributeNames section below.

attributeParameterValues

(Optional)

Specify additional values required by an attribute or restriction. For a complete list of accepted values, see the attributeParameterValues section below.

barriers

(Optional)

One or more points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets.

Syntax:

polylineBarriers

(Optional)

One or more lines that prohibit travel where the lines intersect the streets.

Syntax:

polygonBarriers

(Optional)

The polygons that either prohibit travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

Syntax:

returnDirections

(Optional)

Specify whether the service will generate driving directions for each route. The default value is false .

Values: true | false

returnCFRoutes

(Optional)

Specify whether the service will return routes. The default value is false .

Values: true | false

directionsLanguage

(Optional)

Specify the language that will be used when generating driving directions. This parameter is required only when the returnDirections parameter is set to true . For a complete list of accepted values, see the directionsLanguage section below.

directionsOutputType

(Optional)

Specify the content and verbosity of the driving directions. This parameter is required only when the returnDirections parameter is set to true . The default value is esriDOTStandard .

Values: esriDOTStandard | esriDOTComplete | esriDOTCompleteNoEvents | esriDOTInstructionsOnly | esriDOTSummaryOnly | esriDOTFeatureSets

directionsStyleName

(Optional)

Specify the name of the formatting style for the directions. This parameter is required only when the returnDirections parameter is set to true . The default value is NA Desktop .

Values: NA Desktop | NA Navigation | NA Campus

directionsLengthUnits

(Optional)

Specify the units for displaying travel distance in the driving directions. This parameter is required only when the returnDirections parameter is set to true . The default value is esriNAUMiles .

Values: esriNAUFeet | esriNAUKilometers | esriNAUMeters | esriNAUMiles | esriNAUNauticalMiles | esriNAUYards

directionsTimeAttributeName

(Optional)

Specify the time-based impedance attribute to display the duration of a maneuver.

Values: TravelTime | Minutes | TruckTravelTime | TruckMinutes | WalkTime

outputLines

(Optional)

Specify the type of route features that are output by the service.

Values: esriNAOutputLineTrueShape | esriNAOutputLineTrueShapeWithMeasure | esriNAOutputLineStraight | esriNAOutputLineNone

returnFacilities

(Optional)

Specify whether facilities will be returned by the service. The default value is false .

Values: true | false

returnIncidents

(Optional)

Specify whether incidents will be returned by the service. The default value is false .

Values: true | false

returnBarriers

(Optional)

Specify whether barriers will be returned by the service. The default value is false .

Values: true | false

returnPolylineBarriers

(Optional)

Specify whether polyline barriers will be returned by the service. The default value is false .

Values: true | false

returnPolygonBarriers

(Optional)

Specify whether polygon barriers will be returned by the service. The default value is false .

Values: true | false

returnTraversedEdges

(Optional)

Specify whether traversed edges will be returned by the service. The default value is false .

Values: true | false

When this parameter is set to true , the traversed edges are available in the traversedEdges property of the JSON response.

returnTraversedJunctions

(Optional)

Specify whether traversed junctions will be returned by the service. The default value is false .

Values: true | false

When this parameter is set to true , the traversed junctions are available in the traversedJunctions property of the JSON response.

returnTraversedTurns

(Optional)

Specify whether traversed turns will be returned by the service. The default value is false .

Values: true | false

When this parameter is set to true , the traversed turns are available in the traversedTurns property of the JSON response.

returnZ

(Optional)

Specify whether z-values will be included for the returned geometries if supported by the underlying network.

The default value is false .

Values: true | false

ignoreInvalidLocations

(Optional)

Specify whether invalid input locations will be ignored when finding the best solution. The default value is true .

Values: true | false

outSR

(Optional)

The spatial reference of the geometries.

outputGeometryPrecision

(Optional)

Indicate how the route geometry will be simplified. The units for this parameter are set using the outputGeometryPrecisionUnits parameter.

outputGeometryPrecisionUnits

(Optional)

Specify the units for the outputGeometryPrecision parameter value.

Values: esriMeters | esriCentimeters | esriDecimalDegrees | esriDecimeters | esriFeet | esriInches | esriKilometers | esriMiles | esriMillimeters | esriNauticalMiles | esriPoints | esriYards

geometryPrecision

(Optional)

The number of decimal places in the response geometries returned by the solve operation. This applies to x- and y-values only (not m- or z-values).

Use dark colors for code blocksCopy
1
geometryPrecision = 3

geometryPrecisionZ

(Optional)

The number of decimal places in the response geometries returned by the solve operation. This applies to z-values only (not x-,y-, or m-values).

Use dark colors for code blocksCopy
1
geometryPrecisionZ = 3

geometryPrecisionM

(Optional)

The number of decimal places in the response geometries returned by the solve operation. This applies to m-values only (not x-,y-, or z-values).

Use dark colors for code blocksCopy
1
geometryPrecisionM = 3

overrides

(Optional)

preserveObjectID

(Optional)

Specify whether the object IDs from the input locations will be preserved when the input locations are returned as output. The default value is false .

Values: true | false

locateSettings

(Optional)

Additional input location settings.

Value: JSON object

returnEmptyResults

(Optional)

Specify whether the service will return empty results instead of the error property when the request fails.

The default value is false .

Required parameters

incidents

Use this parameter to specify one or more locations from which the service searches for the nearby locations. These locations are referred to as incidents.

You can use a simple comma- and semicolon-based syntax if you are passing the input locations using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for incidents

Use dark colors for code blocksCopy
1
incidents=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

Use dark colors for code blocksCopy
1
incidents=-117.1957,34.0564; -117.184,34.0546

The incidents parameter can be specified using a JSON structure that references a set of point features. The property is optional; however, the JSON structure must specify either the features , url , or layer property:

  • url —Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • features —Specify an array of features.

    Each feature in the features array represents an incident and contains the following properties:

    • geometry —Specify the input point geometry containing x and y properties along with the spatialReference property. If the spatialReference property is defined for the entire JSON, you don't need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has many features and improves performance. This property is not required if the coordinates are in the default spatial reference, WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See Using spatial references to look up WKID values.

    • attributes —Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • layer —Specify a feature layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:

    • type —Set type to layer to indicate that you're specifying the incidents by referencing a layer.

    • layerName —The name or ID of the data layer in the map service that is being referenced.

    • where (optional)—A WHERE clause for the query filter. Any legal SQL WHERE clause operating on the fields in the layer is allowed.

    • geometry (optional)—The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry object returned by the ArcGIS REST API.

      The geometry type is specified using the geometryType property.

    • geometryType (optional)—The type of geometry specified by the geometry property. The supported geometry types are envelope, point, line, and polygon. The default geometry type is esriGeometryEnvelope .

      Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

    • spatialRel (optional)—The spatial relationship to be applied to the input geometry . The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is esriSpatialRelIntersects .

      Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .

Attributes for incidents

When specifying the incidents, you can set properties for each—such as its name or service time—using the following attributes:

  • Name

    The name of the incident. 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 routes and directions.

  • ObjectID

    The object ID of the incident. ObjectID is a unique identifier for the incident. If you want to maintain a relationship between input and output, set preserveObjectID to true , and the ObjectID value of the input incident is included in the output routes (as the IncidentID field). The ObjectID value is also included in the output incidents (as the ObjectID field) and can be used to join additional information from the analysis outputs to the attribute of the incidents. If the ObjectID value is not specified, a unique ID is automatically generated in the output.

  • SourceID

    The numeric identifier of the network dataset source feature class on which the input point is located.

  • SourceOID

    The ObjectID of the feature in the source on which the input point is located.

  • PosAlong

    The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

  • SideOfEdge

    The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

  • TargetFacilityCount

    Specify the number of facilities that need to be found for the incident. If TargetFacilityCount is not set for an incident, the service will use the value specified in the defaultTargetFacilityCount parameter. The value for the TargetFacilityCount attribute allows the defaultTargetFacilityCount value to be overridden on a per-incident basis. The default value for this attribute is null , which causes the service to use the value set for the defaultTargetFacilityCount parameter. If the TargetFacilityCount attribute is set to a value other than null , the defaultTargetFacilityCount value is overwritten.

  • CurbApproach

    Specifies the direction a vehicle may arrive at and depart from the incident. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

    One of the integers listed in the Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you may have seen when using the ArcGIS Network Analyst extension software.

    SettingCoded valueDescription

    Either side of vehicle

    0

    The vehicle can approach and depart the incident in either direction, so a U-turn is allowed at the incident. This setting can be chosen if it is possible and desirable for a vehicle to turn around at the incident. This decision may depend on the width of the road and the amount of traffic or whether the location has a parking lot where vehicles can pull in and turn around.

    Either side of vehicle

    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 incident, the incident 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.

    Right side of vehicle

    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 incident, the incident 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.

    Left side of vehicle

    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 incident, the incident 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.

    No U-turns

    The allowed arrival and departure combinations for the No U-Turn curb approach are shown.

    The CurbApproach attribute 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.

    Right side of vehicle with right-hand traffic

    With right-hand traffic, the curb approach that leaves the vehicle closest to the incident is Right side of vehicle.

    Left side of vehicle with left-hand traffic

    With left-hand traffic, the curb approach that leaves the vehicle closest to the incident is Left side of vehicle.

  • Attr_[Cost]

    This field specifies how much additional time spent or distance traveled can occur at the incident.

    To determine the units of the field, refer to the units of the network cost attribute specified in the field name. For instance, if there is a TravelTime cost attribute that has a unit of minutes, Attr_TravelTime will be in minutes.

    A zero or null value indicates that the incident requires no service time or extra distance traveled. The default value is 0.

    You can add time to a incident to represent how long it takes to make a delivery, install equipment, or perform some other task at the incident. Similarly, adding extra distance may be useful to account for a long driveway or other road that isn't represented by the network dataset.

    If you have multiple network cost attributes, there will be multiple Attr_[Cost] fields. Consequently, you may have more than one time- or distance-based Attr_[Cost] field. The field values you provide are only referenced if the cost attribute referred to in the field name is used in the analysis, for instance, to minimize or accumulate time or distance.

  • Cutoff_[Cost]

    Specify the travel time or distance at which to stop searching for facilities for a given incident.

    If Cutoff_[Cost] is not set for an incident, the service will use the value specified for the defaultCutoff parameter. The default value for this attribute is null, which causes the service to use the value set for the defaultCutoff parameter. If the Cutoff_[Cost] attribute is set to a value other than null, the defaultCutoff value is overridden.

    If you have multiple network cost attributes, there will be multiple Cutoff_[Cost] fields. Consequently, you may have more than one time- or distance-based Cutoff_[Cost] field. The field values you provide are only referenced if the cost attribute referred to in the field name is used in the analysis as an impedance attribute; it is not used if the attribute is used in the analysis as an accumulate attribute.

  • Bearing

    The direction in which a point is moving. The units are degrees and are measured clockwise from true north. This field is used in conjunction with the BearingTol field.

    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 field 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 tool determine on which side of the street the point is.

    Learn more about bearing and bearing tolerance

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the Bearing field 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, and the default value is 30. Values must be greater than 0 and less than 180. 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.

    Learn more about bearing and bearing tolerance

  • NavLatency

    This field is only used in the solve process if the Bearing and BearingTol fields also have values; however, entering a NavLatency field value is optional, even when values are present in Bearing and BearingTol . NavLatency 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.

    The units of NavLatency are the same as the units of the impedance attribute.

Syntax examples for incidents

Syntax for specifying incidents using JSON structure for features

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ],
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying incidents using a URL returning a JSON response

Use dark colors for code blocksCopy
1
2
3
4
{
  "url": "<url>"
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying incidents using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
  "doNotLocateOnRestrictedElements": true | false
}

Examples for incidents

Example 1: Specify incident geometries and attributes using a JSON structure

This example also shows how to specify the Name attribute for each incident as well as a service time for each incident using the Attr_TraveTime attribute.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.4079,
        "y": 37.78356
      },
      "attributes": {
        "Name": "Fire Incident 1",
        "Attr_TravelTime": 4
      }
    },
    {
      "geometry": {
        "x": -122.404,
        "y": 37.782
      },
      "attributes": {
        "Name": "Crime Incident 45",
        "Attr_TravelTime": 5
      }
    }
  ]
}

Example 2: Specify incident geometries in the Web Mercator spatial reference using a JSON structure

This example also shows how to specify the Name attribute for each incident as well as the distance in miles between the actual incident location and its location on the street using the Attr_Miles attribute.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001,
      },
      "attributes": {
        "Name": "123 Main St",
        "Attr_Miles": 0.29
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002,
      },
      "attributes": {
        "Name": "845 Mulberry St",
        "Attr_Miles" : 0.31
      }
    }
  ]
}

Example 3: Specify incidents using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

Use dark colors for code blocksCopy
1
2
3
{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&f=json"
}

Example 4: Specify incidents using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
{
  "type" : "layer",
  "layerName" : "TrafficAccidents",
  "where" : "SEVERITY > 0"
}

facilities

Use this parameter to specify one or more locations that are searched for when finding the closest location. These locations are referred to as facilities.

You can use a simple comma- and semicolon-based syntax if you are passing the facilities using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for facilities

Use dark colors for code blocksCopy
1
facilities=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

Use dark colors for code blocksCopy
1
facilities=-117.1957,34.0564; -117.184,34.0546

The facilities parameter can be specified using a JSON structure that references a set of point features. The property is optional however, the JSON structure must specify either the features , url , or layer property:

  • url —Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • features —Specify an array of features.

    Each feature in the features array represents a facility and contains the following properties:

    • geometry —Specify the input point geometry containing x and y properties along with the spatialReference property. If the spatialReference property is defined for the entire JSON, you don't need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has many features and improves performance. This property is not required if the coordinates are in the default spatial reference, WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See Using spatial references to look up WKID values.

    • attributes —Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • layer —Specify a feature layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:

    • type —Set type to layer to indicate that you're specifying the facilities by referencing a layer.

    • layerName —The name or ID of the data layer in the map service that is being referenced.

    • where (optional)—A WHERE clause for the query filter. Any legal SQL WHERE clause operating on the fields in the layer is allowed.

    • geometry (optional)—The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

      The geometry type is specified using the geometryType property.

    • geometryType (optional)—The type of geometry specified by the geometry property. The supported geometry types are envelope, point, line, and polygon. The default geometry type is esriGeometryEnvelope .

      Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

    • spatialRel (optional)—The spatial relationship to be applied to the input geometry . The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is esriSpatialRelIntersects .

      Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .

Attributes for facilities

When specifying the stops using a JSON structure, you can specify additional properties for facilities such as their names using attributes. The facilities parameter can be specified with the following attributes:

  • Name

    The name of the facility. 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 routes and directions.

  • ObjectID

    The object ID of the facility. ObjectID is a unique identifier for the facility. If you want to maintain a relationship between input and output, set preserveObjectID to true , and the ObjectID value of the input facility is included in the output routes (as the FacilityID field). The ObjectID value is also included in the output facilities (as the ObjectID field) and can be used to join additional information from the analysis outputs to the attribute of the facilities. If the ObjectID value is not specified, a unique ID is automatically generated in the output.

  • SourceID

    The numeric identifier of the network dataset source feature class on which the input point is located.

  • SourceOID

    The ObjectID of the feature in the source on which the input point is located.

  • PosAlong

    The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

  • SideOfEdge

    The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

  • CurbApproach

    Specify the direction a vehicle can arrive at and depart from the facility.

    One of the integers listed in the Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you may have seen when using the ArcGIS Network Analyst extension software.

    SettingCoded valueDescription

    Either side of vehicle

    0

    The vehicle can approach and depart the facility in either direction, so a U-turn is allowed at the facility. This setting can be chosen if it is possible and desirable for a vehicle to turn around at the facility. This decision may depend on the width of the road and the amount of traffic or whether the facility has a parking lot where vehicles can pull in and turn around.

    Either side of vehicle

    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 facility, the facility 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-hand side.

    Right side of vehicle

    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 facility, the facility 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.

    Left side of vehicle

    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 facility, the facility 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.

    No U-turns

    The allowed arrival and departure combinations for the No U-Turn curb approach are shown.

    The CurbApproach attribute 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.

     Right side of vehicle with right-hand traffic

    With right-hand traffic, the curb approach that leaves the vehicle closest to the facility is Right side of vehicle.

     Left side of vehicle with left-hand traffic

    With left-hand traffic, the curb approach that leaves the vehicle closest to the facility is Left side of vehicle.

  • Attr_[Cost]

    This field specifies how much additional time spent or distance traveled can occur at the facility.

    To determine the units of the field, refer to the units of the network cost attribute specified in the field name. For instance, if there is a TravelTime cost attribute that has a unit of minutes, Attr_TravelTime will be in minutes.

    A zero or null value indicates that the facility requires no service time or extra distance traveled. The default value is 0.

    You can add time to a facility to represent how long it takes to perform other tasks at the facility. Similarly, adding extra distance may be useful to account for a long driveway or other road that isn't represented by the network dataset.

    If you have multiple network cost attributes, you'll see multiple Attr_[Cost] fields. Consequently, you may have more than one time- or distance-based Attr_[Cost] field. The field values you provide are only referenced if the cost attribute referred to in the field name is used in the analysis, for instance, to minimize or accumulate time or distance.

  • Cutoff_[Cost]

    Specify the travel time or distance at which to stop searching for facilities for a given incident.

    If Cutoff_[Cost] is not set for an incident, the service will use the value specified for the defaultCutoff parameter. The default value for this attribute is null, which causes the service to use the value set for the defaultCutoff parameter. If the Cutoff_[Cost] attribute is set to a value other than null, the defaultCutoff value is overridden.

    If you have multiple network cost attributes, there will be multiple Cutoff_[Cost] fields. Consequently, you may have more than one time- or distance-based Cutoff_[Cost] field. The field values you provide are only referenced if the cost attribute referred to in the field name is used in the analysis as an impedance attribute; it is not used if the attribute is used in the analysis as an accumulate attribute.

  • Bearing

    The direction in which a point is moving. The units are degrees and are measured clockwise from true north. This field is used in conjunction with the BearingTol field.

    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 field 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 tool determine on which side of the street the point is.

    Learn more about bearing and bearing tolerance

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the Bearing field 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, and the default value is 30. Values must be greater than 0 and less than 180. 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.

    Learn more about bearing and bearing tolerance

  • NavLatency

    This field is only used in the solve process if the Bearing and BearingTol fields also have values; however, entering a NavLatency field value is optional, even when values are present in Bearing and BearingTol . NavLatency 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.

    The units of NavLatency are the same as the units of the impedance attribute.

Syntax for facilities

Syntax for specifying facilities using a JSON structure for features

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ],
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying facilities using a URL returning a JSON response

Use dark colors for code blocksCopy
1
2
3
4
{
  "url": "<url>"
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying facilities using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
  "doNotLocateOnRestrictedElements": true | false
}

Examples for facilities

Example 1: Specify facility geometries and attributes using a JSON structure

This example also shows how to specify the Name attribute and a service time for each facility using the Attr_TravelTime attribute.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.4079,
        "y": 37.78356
      },
      "attributes": {
        "Name": "Fire Station 34",
        "Attr_TravelTime": 4
      }
    },
    {
      "geometry": {
        "x": -122.404,
        "y": 37.782
      },
      "attributes": {
        "Name": "Fire Station 29",
        "Attr_TravelTime": 5
      }
    }
  ]
}

Example 2: Specify facility geometries in the Web Mercator spatial reference using a JSON structure

This example also shows how to specify the Name attribute for each facility and the distance in miles between the actual facility location and its location on the street using the Attr_Miles attribute.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001,
      },
      "attributes": {
        "Name": "Store 45",
        "Attr_Miles": 0.29
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002,
      },
      "attributes": {
        "Name": "Store 67",
        "Attr_Miles" : 0.31
      }
    }
  ]
}

Example 3: Specify facilities using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

Use dark colors for code blocksCopy
1
2
3
{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&f=json"
}

Example 4: Specify facilities using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
{
  "type" : "layer",
  "layerName" : "Hospitals",
  "where" : "BEDS > 100"
}

token

Use this parameter to 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.

Use dark colors for code blocksCopy
1
token=<yourToken>

Optional parameters

f

Use this parameter to specify the response format. The parameter can have html , json or pjson as arguments, for example, f=json . The pjson value is used for printing the JSON response in a prettified format.

travelMode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Enterprise and can be configured by the administrator of your organization to better reflect the organization's workflows.

To learn more about travel modes, see Configure travel modes.

The value for the travelMode parameter is the JSON object containing the settings for a travel mode supported by your organization. To get the supported travel modes, run the retrieveTravelModes service.

You can make a request to retrieve travel modes using the following form:

Use dark colors for code blocksCopy
1
https://machine.domain.com/webadaptor/rest/services/Routing/NetworkAnalysis/NAServer/ClosestFacilty/retrieveTravelModes?f=json&token=<yourToken>

The response below is returned by the retrieveTravelModes service.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{
  "currentVersion": 10.8,
  "defaultTravelMode": "FEgifRtFndKNcJMJ",
  "supportedTravelModes": [
    {
      "attributeParameterValues": [
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Private Roads",
          "value": "AVOID_MEDIUM"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Walking",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Preferred for Pedestrians",
          "value": "PREFER_LOW"
        },
        {
          "parameterName": "Walking Speed (km/h)",
          "attributeName": "WalkTime",
          "value": 5
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Roads Unsuitable for Pedestrians",
          "value": "AVOID_HIGH"
        }
      ],
      "description": "Follows paths and roads that allow pedestrian traffic and finds
                     solutions that optimize travel time. The walking speed is set to
                     5 kilometers per hour.",
      "impedanceAttributeName": "WalkTime",
      "simplificationToleranceUnits": "esriMeters",
      "uturnAtJunctions": "esriNFSBAllowBacktrack",
      "restrictionAttributeNames": [
        "Avoid Private Roads",
        "Avoid Roads Unsuitable for Pedestrians",
        "Preferred for Pedestrians",
        "Walking"
      ],
      "useHierarchy": false,
      "simplificationTolerance": 2,
      "timeAttributeName": "WalkTime",
      "distanceAttributeName": "Kilometers",
      "type": "WALK",
      "id": "caFAgoThrvUpkFBW",
      "name": "Walking Time"
    },
    {
      "attributeParameterValues": [
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Unpaved Roads",
          "value": "AVOID_HIGH"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Private Roads",
          "value": "AVOID_MEDIUM"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Driving an Automobile",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Through Traffic Prohibited",
          "value": "AVOID_HIGH"
        },
        {
          "parameterName": "Vehicle Maximum Speed (km/h)",
          "attributeName": "TravelTime",
          "value": 0
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Roads Under Construction Prohibited",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Gates",
          "value": "AVOID_MEDIUM"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Express Lanes",
          "value": "PROHIBITED"
        },
        {
          "parameterName": "Restriction Usage",
          "attributeName": "Avoid Carpool Roads",
          "value": "PROHIBITED"
        }
      ],
      "description": "Models the movement of cars and other similar small automobiles,
                      such as pickup trucks, and finds solutions that optimize travel
                      time. Travel obeys one-way roads, avoids illegal turns, and
                      follows other rules that are specific to cars. When you specify
                      a start time, dynamic travel speeds based on traffic are used
                      where it is available.",
      "impedanceAttributeName": "TravelTime",
      "simplificationToleranceUnits": "esriMeters",
      "uturnAtJunctions": "esriNFSBAtDeadEndsAndIntersections",
      "restrictionAttributeNames": [
        "Avoid Unpaved Roads",
        "Avoid Private Roads",
        "Driving an Automobile",
        "Through Traffic Prohibited",
        "Roads Under Construction Prohibited",
        "Avoid Gates",
        "Avoid Express Lanes",
        "Avoid Carpool Roads"
      ],
      "useHierarchy": true,
      "simplificationTolerance": 10,
      "timeAttributeName": "TravelTime",
      "distanceAttributeName": "Kilometers",
      "type": "AUTOMOBILE",
      "id": "FEgifRtFndKNcJMJ",
      "name": "Driving Time"
    }
  ]
}

From the JSON above, to pass Walking Time as the travel mode, use the following JSON as the value for the travelMode parameter:

Use dark colors for code blocksCopy
1
travelMode={"attributeParameterValues": [{"parameterName": "Restriction Usage","attributeName": "Walking","value": "PROHIBITED"},{"parameterName": "Restriction Usage","attributeName": "Preferred for Pedestrians","value": "PREFER_LOW"},{"parameterName": "Walking Speed (km/h)","attributeName": "WalkTime","value": 5}],"description": "Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.","impedanceAttributeName": "WalkTime","simplificationToleranceUnits": "esriMeters","uturnAtJunctions": "esriNFSBAllowBacktrack","restrictionAttributeNames": ["Preferred for Pedestrians","Walking"],"useHierarchy": false,"simplificationTolerance": 2,"timeAttributeName": "WalkTime","distanceAttributeName": "Miles","type": "WALK","id": "caFAgoThrvUpkFBW","name": "Walking Time"}

defaultTargetFacilityCount

The number of closest facilities to find per incident. This is useful in situations in which multiple fire engines may be required from different fire stations, such as a fire. You can specify, for example, to find the three nearest fire stations to a fire.

The value for this parameter can be overridden on a per-incident basis by specifying a value for the TargetFacilityCount attribute when specifying the incidents parameter.

travelDirection

Specifies how the travel direction for the closest facility search will be measured.

This parameter can be specified using the following values:

  • esriNATravelDirectionFromFacility —The direction of travel is from facilities to incidents.
  • esriNATravelDirectionToFacility —The direction of travel is from incidents to facilities.

Each option may find different facilities, as the travel time along some streets may vary based on the travel direction and one-way restrictions. For instance, a facility may be a 10-minute drive from the incident while traveling from the incident to the facility, but while traveling from the facility to the incident, it may be a 15-minute drive because of different travel time in that direction.

Fire departments commonly use the esriNATravelDirectionFromFacility value for the parameter since they are concerned with the time it takes to travel from the fire station (facility) to the location of the emergency (incident). A retail store (facility) is more concerned with the time it takes the shoppers (incidents) to reach the store; retail stores commonly use the esriNATravelDirectionToFacility parameter value.

defaultCutoff

The travel time or travel distance value at which to stop searching for facilities for a given incident. For example, while finding the closest hospitals from the site of an accident, a cutoff value of 15 minutes means that the tool will search for the closest hospital within 15 minutes from the incident. If the closest hospital is 17 minutes away, no routes will be returned in the output routes. A cutoff value is especially useful when searching for multiple facilities.

The unit for this parameter is based on the unit of the impedance attribute specified using the impedanceAttributeName parameter or the impedanceAttributeName value of the travel mode if a travel mode is specified . If the impedanceAttributeName parameter is TravelTime , the defaultCutoff value is specified in minutes. Otherwise, the value is specified in miles or kilometers based on whether the impedanceAttributeName parameter is set to Miles or Kilometers , respectively.

The value for the defaultCutoff parameter can be overridden on a per-incident or facility basis by specifying a value for the Cutoff_[Impedance] attribute when specifying the incidents or the facilities parameter values.

timeOfDay

Specify the time and date to depart from or arrive at incidents or facilities. You can also specify a value of now to set the depart or arrive time to the current time.

Specifying a time of day results in more accurate estimations of travel times because the travel times account for the traffic conditions that are applicable for that date and time.

To use traffic in the analysis, set impedanceAttributeName to TravelTime , and assign a timeOfDay value.

The timeOfDay value represents the target start time or arrival time of the routes in the analysis. The time is specified as UNIX time (milliseconds since midnight, January 1, 1970).

If a value of now is passed to the timeOfDay parameter, the travel begins at the current time. This will also override the timeOfDayIsUTC parameter value to be true . When timeOfDay is now and timeOfDayIsUTC is true , the travel will begin or end at input locations at the current time regardless of the time zone of the input locations.

If a time of day is not passed in, 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.

When the service is using ArcGIS StreetMap Premium data, it can support two kinds of traffic: live and typical.

If the timeOfDay value specified is within four hours of the current time, live traffic will be used where available. Live traffic retrieves speeds based on phone probe records, sensors, and other data sources and reflects the current travel speeds and predicts speeds for the near future. If the timeOfDay value specified is more than four hours earlier or later than the current time, or the road does not have live traffic, typical traffic speeds will be used. Typical speeds are based on historical traffic patterns. The travel time data is aggregated in 15-minute intervals per day of week based on multiple years worth of data. Consequently, a road may have a different travel time at Monday at 8:00 a.m., Monday at 8:15 a.m., or Tuesday at 8:00 a.m.. Since the variance is at the day of week and time of day, the travel time is the same on a road for any Monday at 8:00 a.m., regardless of the month or year.

If your goal is to model typical travel conditions and avoid large variances from the average due to live traffic, it is recommended that you use a date from the past to ensure that it doesn't coincide with the 4-hour window from the current time. As an extreme example, you can even use dates from 1990.

ArcGIS Online Directions and Routing Services Coverage shows the countries Esri currently provides traffic data for.

Typical traffic

To ensure the task uses typical traffic in locations where it is available, choose a time and day of the week; then convert the day of the week to one of the following dates from 1990:

  • Monday—1/1/1990
  • Tuesday—1/2/1990
  • Wednesday—1/3/1990
  • Thursday—1/4/1990
  • Friday—1/5/1990
  • Saturday—1/6/1990
  • Sunday—1/7/1990

Set the time and date as UNIX time in milliseconds. For example, to solve for 1:03 p.m. on Thursdays, set the time and date to 1:03 p.m., January 4, 1990, and convert to milliseconds (631458180000 ). Although the dates representing days of the week are from 1990, typical traffic is calculated from recent traffic trends—usually over the last two years worth of data.

All facilities and incidents must be in the same time zone when you are doing any of the following:

  • Specifying a start time and traveling from incident to facility
  • Specifying an end time and traveling from facility to incident
  • Specifying a start time and traveling from facility to incident
  • Specifying an end time and traveling from incident to facility

Live traffic

To use live traffic when and where it is available, choose a time and date and convert to UNIX time.

Esri saves live traffic data for 4 hours and references predictive data extending 4 hours into the future. If the time and date you specify for this parameter is outside the 8-hour time window, or the travel time in the analysis continues past the predictive data window, the task returns to typical traffic speeds.

Examples for timeOfDay

Example 1: 13:03, January 4, 1990. Typical traffic on Thursdays at 1:03 p.m.

Use dark colors for code blocksCopy
1
"timeOfDay": 631458180000

Example 2: 17:00, January 7, 1990. Typical traffic on Sundays at 5:00 p.m.

Use dark colors for code blocksCopy
1
"timeOfDay": 631731600000

Example 3: Specify the now value. The analysis begins at the current time and live traffic speeds are referenced in the analysis.

Use dark colors for code blocksCopy
1
"timeOfDay": now

Example 4: 10:20, March 18, 2015. If the current time is between 6:20 a.m., March 18, 2015, and 2:20 p.m., March 18, 2015, live traffic speeds are referenced in the analysis; otherwise, typical traffic speeds are referenced.

Use dark colors for code blocksCopy
1
"timeOfDay": 1426674000000

timeOfDayIsUTC

Specify the time zone or zones of the timeOfDay parameter.

False (use geographically local time zones)

The timeOfDay value refers to the time zone or zones in which the input points are located. This option causes the analysis to have rolling start times across time zones.

The following image illustrates setting the value to false (geographically local). Setting timeOfDay to 9:00 a.m., January 4, 1990 (631443600000 milliseconds) and timeOfDayIsUTC to false , and submitting a valid request causes the drive times for points in the eastern time zone to start at 9:00 a.m. 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.)

timeOfDayIsUTC set to false

_Input: timeOfDay is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and timeOfDayIsUTC is set to false _

True (use UTC)

The timeOfDay value refers to coordinated universal time (UTC). The start times for all points are simultaneous, regardless of time zones.

The following image illustrates setting the value to true (UTC). Setting timeOfDay to 9:00 a.m., January 4, 1990 (631443600000 milliseconds) and timeOfDayIsUTC to true causes the start time for points in the eastern time zone to be 4:00 a.m. eastern time and 3:00 a.m. central time for those in the central time zone.

timeOfDayIsUTC set to true

_Input: timeOfDay is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and timeOfDayIsUTC is set to true _

timeOfDayUsage

The timeOfDayUsage parameter value represents the arrival or departure time for the routes. This parameter can be specified using the following values:

  • esriNATimeOfDayUseAsStartTime —The service finds the best route considering the timeOfDay parameter value as the departure time from the facility or incident.
  • esriNATimeOfDayUseAsEndTime —The service considers the timeOfDay parameter value as the arrival time at the facility or incident. This value is useful if you want to know what time to depart from a location so that you arrive at the destination at the time specified in timeOfDay .

The parameter value is ignored if the timeOfDay parameter value is none .

useHierarchy

Specify whether hierarchy will be used when finding the shortest paths.

  • true —Use hierarchy when travelling between facilities and incidents. 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 —Do not use hierarchy when travelling between facilities and incidents. When hierarchy is not used, the service considers all the streets and doesn't prefer higher-order streets when finding the route. This is often used when finding short-distance routes within a city.

restrictUTurns

Use this parameter 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. This parameter can have the following values:

Parameter valueDescription

esriNFSBAllowBacktrack

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 permitted

U-turns are permitted at junctions with any number of adjacent streets.

esriNFSBAtDeadEndsAndIntersections

U-turns are prohibited at junctions where exactly two adjacent streets meet.

U-turns permitted only at intersections and dead-ends

U-turns are permitted only at intersections or dead ends.

esriNFSBAtDeadEndsOnly

U-turns are prohibited at all junctions and intersections and are permitted only at dead ends.

U-turns permitted only at dead-ends

U-turns are permitted only at dead ends.

esriNFSBNoBacktrack

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 CurbApproach property to the appropriate value (3).

impedanceAttributeName

Specify the impedance.

Impedance is a value that quantifies travel along the transportation network. Travel distance is an example of impedance; it quantifies the length of walkways and road segments. Similarly, drive time—the typical time it takes to drive a car along a road segment—is an example of impedance. Drive times may vary by type of vehicle—for instance, the time it takes for a truck to travel along a path tends to be longer than a car—so there can be many impedance values representing travel times for different vehicle types. Impedance values may also vary with time; live and typical traffic reference dynamic impedance values. Each walkway and road segment stores at least one impedance value. When performing a network analysis, the impedance values are used to calculate the best results, such as finding the shortest route—the route that minimizes impedance—between two points.

The impedanceAttributeName parameter can be specified using the following values:

  • TravelTime—Historical and live traffic data is used. This option is good for modeling the time it takes automobiles to travel along roads at a specific time of day using live traffic speed data where available. When using TravelTime, you can optionally set the TravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the vehicle is capable of traveling.
  • Minutes—Live traffic data is not used, but historical average speeds for automobiles data is used.
  • TruckTravelTime—Historical and live traffic data is used, but the speed is capped at the posted truck speed limit. This is good for modeling the time it takes for the trucks to travel along roads at a specific time. When using TruckTravelTime, you can optionally set the TruckTravelTime::Vehicle Maximum Speed (km/h) attribute parameter to specify the physical limitation of the speed the truck is capable of traveling.
  • TruckMinutes—Live traffic data is not used, but the smaller of the historical average speeds for automobiles and the posted speed limits for trucks are used.
  • WalkTime—The default is a speed of 5 km/hr on all roads and paths, but this can be configured through the WalkTime::Walking Speed (km/h) attribute parameter.
  • Miles—Length measurements along roads are stored in miles and can be used for performing analysis based on shortest distance.
  • Kilometers—Length measurements along roads are stored in kilometers and can be used for performing analysis based on shortest distance.

accumulateAttributeNames

Use this parameter to specify whether the service will accumulate values other than the value specified for impedanceAttributeName . For example, if impedanceAttributeName is set to TravelTime , the total travel time for the route will be calculated by the service. However, if you also want to calculate the total distance of the route in miles, you can specify Miles as the value for the accumulateAttributeNames parameter.

Specify the parameter value as a comma-separated list of names. The parameter values are the same as the impedanceAttributeName parameter. For example, accumulateAttributeNames=Miles,Kilometers indicates that the total cost of the route will also be calculated in miles and kilometers.

restrictionAttributeNames

Use this parameter to specify the restrictions that will be honored by the service. A restriction represents a driving preference or requirement. In most cases, restrictions cause roads or pathways to be prohibited, but they can also cause them to be avoided or preferred. For instance, using the Avoid Toll Roads restriction will result in a route that will include toll roads only when it is required to travel on toll roads to visit a stop. Use Height Restriction to route around clearances that are lower than the height of the vehicle. If the vehicle is carrying corrosive materials, you can use the Any Hazmat Prohibited restriction to prevent hauling the materials along roads where it is marked as illegal to do so.

This parameter value is specified as a comma-separated list of restriction names. A value of none indicates that no restrictions will be used when finding the shortest paths.

The restrictionAttributeNames parameter can be specified using the following values:

  • Any Hazmat Prohibited—The results will not include roads where transporting any kind of hazardous material is prohibited.
  • Avoid Carpool Roads—The results will avoid roads that are designated exclusively for car pool (high-occupancy) vehicles.
  • Avoid Express Lanes—The results will avoid roads designated as express lanes.
  • Avoid Ferries—The results will avoid ferries.
  • Avoid Gates—The results will avoid roads where there are gates, such as keyed access or guard-controlled entryways.
  • Avoid Limited Access Roads—The results will avoid roads that are limited-access highways.
  • Avoid Private Roads—The results will avoid roads that are not publicly owned and maintained.
  • Avoid Roads Unsuitable for Pedestrians—The results will avoid roads that are unsuitable for pedestrians.
  • Avoid Stairways—The results will avoid all stairways on a pedestrian-suitable route.
  • Avoid Toll Roads—The results will avoid all toll roads for automobiles.
  • Avoid Toll Roads for Trucks—The results will avoid all toll roads for trucks.
  • Avoid Truck Restricted Roads—The results will avoid roads where trucks are not allowed, except when making deliveries.
  • Avoid Unpaved Roads—The results will avoid roads that are not paved (for example, dirt, gravel, and so on).
  • Axle Count Restriction—The results will not include roads where trucks with the specified number of axles are prohibited. The number of axles can be specified using the Number of Axles restriction parameter.
  • Driving a Bus—The results will not include roads where buses are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Driving a Taxi—The results will not include roads where taxis are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Driving a Truck—The results will not include roads where trucks are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Driving an Automobile—The results will not include roads where automobiles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Driving an Emergency Vehicle—The results will not include roads where emergency vehicles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Height Restriction—The results will not include roads where the vehicle height exceeds the maximum allowed height for the road. The vehicle height can be specified using the Vehicle Height (meters) restriction parameter.
  • Kingpin to Rear Axle Length Restriction—The results will not include roads where the vehicle length exceeds the maximum allowed kingpin to rear axle for all trucks on the road. The length between the vehicle kingpin and the rear axle can be specified using the Vehicle Kingpin to Rear Axle Length (meters) restriction parameter.
  • Length Restriction—The results will not include roads where the vehicle length exceeds the maximum allowed length for the road. The vehicle length can be specified using the Vehicle Length (meters) restriction parameter.
  • Preferred for Pedestrians—The results will use preferred routes suitable for pedestrian navigation.
  • Riding a Motorcycle—The results will not include roads where motorcycles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.
  • Roads Under Construction Prohibited—The results will not include roads that are under construction.
  • Semi or Tractor with One or More Trailers Prohibited—The results will not include roads where semis or tractors with one or more trailers are prohibited.
  • Single Axle Vehicles Prohibited—The results will not include roads where vehicles with single axles are prohibited.
  • Tandem Axle Vehicles Prohibited—The results will not include roads where vehicles with tandem axles are prohibited.
  • Through Traffic Prohibited—The results will not include roads where through traffic (nonlocal traffic) is prohibited.
  • Truck with Trailers Restriction—The results will not include roads where trucks with the specified number of trailers on the truck are prohibited. The number of trailers on the truck can be specified using the Number of Trailers on Truck restriction parameter.
  • Use Preferred Hazmat Routes—The results will prefer roads that are designated for transporting hazardous materials.
  • Use Preferred Truck Routes—The results will prefer roads that are designated as truck routes, such as roads that are part of the national network as specified by the National Surface Transportation Assistance Act in the United States, or roads that are designated as truck routes by the state or province, or roads that are preferred by truckers when driving in an area.
  • Walking—The results will not include roads where pedestrians are prohibited.
  • Weight Restriction—The results will not include roads where the vehicle weight exceeds the maximum allowed weight for the road. The vehicle weight can be specified using the Vehicle Weight (kilograms) restriction parameter.
  • Weight per Axle Restriction—The results will not include roads where the vehicle weight per axle exceeds the maximum allowed weight per axle for the road. The vehicle weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.
  • Width Restriction—The results will not include roads where the vehicle width exceeds the maximum allowed width for the road. The vehicle width can be specified using the Vehicle Width (meters) restriction parameter.

The Driving a Delivery Vehicle restriction attribute is no longer available. The service will ignore this restriction since it is invalid. To achieve similar results, use the Driving a Truck restriction attribute along with the Avoid Truck Restricted Roads restriction attribute.

The restrictionAttributeName parameter value is specified as a list of restriction names. A value of null indicates that no restrictions will be used when finding the best route, but only when travelMode is set to null .

attributeParameterValues

Use this parameter to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. If the restriction is meant to avoid or prefer roads, you can further specify the degree to which they are avoided or preferred using this parameter. For example, you can choose to never use toll roads, avoid them as much as possible, or prefer them.

This parameter value is specified as an array of objects each having the following properties:

  • attributeName —The name of the restriction.
  • parameterName —The name of the parameter associated with the restriction. A restriction can have one or more parameterName properties.
  • value —The value for parameterName .

Most attribute parameters are related to the restriction attributes in restrictionAttributeNames . Each restriction has at least one attribute parameter named Restriction Usage , which specifies whether the restriction prohibits, avoids, or prefers travel on the roads associated with the restriction and the degree to which the roads are avoided or preferred. The Restriction Usage parameter can be assigned any of the following string values or their equivalent numeric values in the parentheses:

  • Prohibited (-1 )—Travel on the roads that have the restriction is prohibited.
  • Avoid_High (5 )—It is very unlikely the service will include in the route the roads that are associated with the restriction.
  • Avoid_Medium (2 )—It is unlikely the service will include in the route the roads that are associated with the restriction.
  • Avoid_Low (1.3 )—It is somewhat unlikely the service will include in the route the roads that are associated with the restriction.
  • Prefer_Low (0.8 )—It is somewhat likely the service will include in the route the roads that are associated with the restriction.
  • Prefer_Medium (0.5 )—It is likely the service will include in the route the roads that are associated with the restriction.
  • Prefer_High (0.2 )—It is very likely the service will include in the route the roads that are associated with the restriction.

The following table lists the attribute parameter names and the default parameter values.

Restriction nameRestriction parameter nameRestriction parameter default value

Any Hazmat Prohibited

Restriction Usage

Prohibited

Avoid Carpool Roads

Restriction Usage

Prohibited

Avoid Express Lanes

Restriction Usage

Prohibited

Avoid Ferries

Restriction Usage

Avoid_Medium

Avoid Gates

Restriction Usage

Avoid_Medium

Avoid Limited Access Roads

Restriction Usage

Avoid_Medium

Avoid Private Roads

Restriction Usage

Avoid_Medium

Avoid Roads Unsuitable for Pedestrians

Restriction Usage

Avoid_High

Avoid Stairways

Restriction Usage

Avoid_High

Avoid Toll Roads

Restriction Usage

Avoid_Medium

Avoid Toll Roads for Trucks

Restriction Usage

Avoid_Medium

Avoid Truck Restricted Roads

Restriction Usage

Avoid_High

Avoid Unpaved Roads

Restriction Usage

Avoid_High

Axle Count Restriction

Number of Axles

0

Restriction Usage

Prohibited

Driving a Bus

Restriction Usage

Prohibited

Driving a Taxi

Restriction Usage

Prohibited

Driving a Truck

Restriction Usage

Prohibited

Driving an Automobile

Restriction Usage

Prohibited

Driving an Emergency Vehicle

Restriction Usage

Prohibited

Height Restriction

Restriction Usage

Prohibited

Vehicle Height (meters)

0

Kingpin to Rear Axle Length Restriction

Restriction Usage

Prohibited

Vehicle Kingpin to Rear Axle Length (meters)

0

Length Restriction

Restriction Usage

Prohibited

Vehicle Length (meters)

0

Preferred for Pedestrians

Restriction Usage

Prefer_Low

Riding a Motorcycle

Restriction Usage

Prohibited

Roads Under Construction Prohibited

Restriction Usage

Prohibited

Semi or Tractor with One or More Trailers Prohibited

Restriction Usage

Prohibited

Single Axle Vehicles Prohibited

Restriction Usage

Prohibited

Tandem Axle Vehicles Prohibited

Restriction Usage

Prohibited

Through Traffic Prohibited

Restriction Usage

Avoid_High

Truck with Trailers Restriction

Restriction Usage

Prohibited

Number of Trailers on Truck

0

Use Preferred Hazmat Routes

Restriction Usage

Prefer_Medium

Use Preferred Truck Routes

Restriction Usage

Prefer_High

Walking

Restriction Usage

Prohibited

WalkTime

Walking Speed (km/h)

5

Weight Restriction

Restriction Usage

Prohibited

Vehicle Weight (kilograms)

0

Weight per Axle Restriction

Restriction Usage

Prohibited

Vehicle Weight per Axle (kilograms)

0

Width Restriction

Restriction Usage

Prohibited

Vehicle Width (meters)

0

Syntax example for attributeParameterValues

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
[
    {
        "attributeName": "<attribute1>",
        "parameterName": "<parameter1>",
        "value": "<value1>"
    },
    {
        "attributeName": "<attribute2>",
        "parameterName": "<parameter2>",
        "value": "<value2>"
    }
]

Example for attributeParameterValues

This example shows how to specify the height and weight of the vehicle for use with the height and weight restrictions, respectively, along with a high preference to include the designated truck routes. This results in a route that does not include roads where the clearance under overpasses or through tunnels is less than the vehicle height. The route will also not include roads with load-limited bridges or local roads that prohibit heavy vehicles if the vehicle weight exceeds the maximum permissible weight. However, the route will include as many roads as possible that are designated as preferred truck routes.

The Restriction Usage parameter for Height Restriction and Weight Restriction are not specified, as the default value of Prohibit will be used for these restriction parameters.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
attributeParameterValues=
[
    {
        "attributeName": "Height Restriction",
        "parameterName": "Vehicle Height (meters)",
        "value": 4.12
    },
    {
        "attributeName": "Weight Restriction",
        "parameterName": "Vehicle Weight (kilograms)",
        "value": 36287
    },
    {
        "attributeName": "Use Preferred Truck Routes",
        "parameterName": "Restriction Usage",
        "value": "Prefer_High"
    }
]

barriers

Use this parameter to specify one or more points that will act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. For example, a point barrier can be used to represent a fallen tree along a street or a time delay spent at a railroad crossing.

You can use a simple comma- and semicolon-based syntax if you are passing the point barrier locations using their longitude and latitude values in the WGS84 coordinate system and don't need to pass additional fields for each location.

Simple syntax for barriers

Use dark colors for code blocksCopy
1
barriers=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

Use dark colors for code blocksCopy
1
barriers=-117.1957,34.0564; -117.184,34.0546

You can specify barrier geometries as well as attributes using a more comprehensive JSON structure that references a set of features. The property is optional; however, the JSON structure must specify either the url , features , or layer property:

  • url —Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • features —Specify an array of features.

    Each feature in this array represents a point barrier and contains the following fields:

    • geometry —Specify the input point geometry containing x and y properties along with the spatialReference property. If the spatialReference property is defined for the entire JSON, you don't need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has many features and improves performance. This property is not required if the coordinates are in the default spatial reference, WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See Using spatial references to look up WKID values.

    • attributes —Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • layer —Specify a feature layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:

    • type —Set the type property to layer to indicate that you're specifying the point barriers by referencing a layer.

    • layerName —The name or ID of the data layer in the map service that is being referenced.

    • where (optional)—A WHERE clause for the query filter. Any legal SQL WHERE clause operating on the fields in the layer is allowed.

    • geometry (optional)—The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

      The geometry type is specified using the geometryType property.

    • geometryType (optional)—The type of geometry specified by the geometry property. The supported geometry types are envelope, point, line, and polygon. The default geometry type is esriGeometryEnvelope .

      Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

    • spatialRel (optional)—The spatial relationship to be applied to the input geometry . The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is esriSpatialRelIntersects .

      Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .

Attributes for barriers

When specifying the barriers parameter using JSON structure, you can specify additional information about barriers—such as the barrier type—using attributes. The barriers parameter can be specified with the following attributes:

Name

The name of the barrier.

ObjectID

The object ID of the barrier. ObjectID is a unique identifier for the barrier. If you want to maintain a relationship between the input and output, set preserveObjectID to true . The ObjectID value of the input barrier is included in the output barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of the barriers. If the ObjectID value is not specified, a unique ID is automatically generated in the output.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

BarrierType

Specifies whether the point barrier restricts travel completely or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Restriction)—Prohibits travel through the barrier. The barrier is referred to as a restriction point barrier since it acts as a restriction.

    Two maps demonstrate how a restriction point barrier affects a route analysis.

    The first map shows the shortest path between two stops without any restriction point barriers. The second map has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.

  • 2 (Added Cost)—Traveling through the barrier increases the travel time or distance by the amount specified in the Attr_[Cost] attribute. This barrier type is referred to as an added cost point barrier.

Two maps demonstrate how added cost point barriers affect a route analysis.

The first map shows the shortest path between two stops without any added cost point barrier. For the second map, the travel time from stop 1 to stop 2 is the same whether going around the north end of the block or the south end; however, since crossing railroad tracks incurs a time penalty (modeled with added cost point barriers), the route with only one railroad crossing is chosen. The cost of crossing the barrier is added to the accumulated travel time of the resulting route.

FullEdge

Specifies how the restriction point barriers are applied to the edge elements during the analysis. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (False)—Permits travel on the edge up to the barrier but not through it. This is the default value.
  • 1 (True)—Restricts travel anywhere on the associated edge.

Attr_[Cost]

Indicates how the cost (time or distance) is added when the barrier is traversed. This attribute is applicable only for added cost point barriers. The attribute value must be greater than or equal to zero.

Syntax examples for barriers

Syntax for specifying barriers using JSON structure for features

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ],
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying barriers using a URL to a JSON response

Use dark colors for code blocksCopy
1
2
3
4
{
  "url": "<url>"
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying point barriers using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
  "doNotLocateOnRestrictedElements": true | false
}

Examples for barriers

Example 1: Specify an added cost point barrier using JSON structure

This example shows how to use an added cost point barrier to model a five-minute delay at a railroad crossing. The BarrierType attribute is used to specify that the point barrier is of type added cost and the Attr_TravelTime attribute is used to specify the delay in minutes.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.053461,
        "y": 37.541479
      },
      "attributes": {
        "Name": "Haley St rail road crossing",
        "BarrierType": 2,
        "Attr_TravelTime": 5
      }
    }
  ]
}

Example 2: Specify a restriction point barrier using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

Use dark colors for code blocksCopy
1
2
3
{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/0/query?where=1%3D1&returnGeometry=true&f=json"
}

Example 3: Specify a point barrier using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
{
  "type" : "layer",
  "layerName" : "TrafficAccidents",
  "where" : "SEVERITY > 0"
}

polylineBarriers

Use this parameter to specify one or more lines that prohibit travel anywhere the lines intersect the streets. For example, a parade or protest that blocks traffic across several street segments can be modeled with a line barrier. A line barrier can also quickly fence off several roads from being traversed, thereby channeling possible routes away from undesirable parts of the street network.

Two maps demonstrate how a line barrier affects finding a route between two stops.

The first map displays the shortest path between two stops. The second map shows the shortest path when several streets are blocked by a polyline barrier.

You can specify polyline barrier geometries as well as attributes using a JSON structure that references a set of features. The property is optional; however, the JSON structure must specify either the url , features , or layer property:

  • url —Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • features —Specify an array of features.

    Each feature in this array represents a polyline barrier and contains the following fields:

    • geometry —Specify the input point geometry containing x and y properties along with the spatialReference property. If the spatialReference property is defined for the entire JSON, you don't need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has many features and improves performance. This property is not required if the coordinates are in the default spatial reference, WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See Using spatial references to look up WKID values.

    • attributes —Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • layer —Specify a feature layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:

    • type —Set the type property to layer to indicate that you're specifying the polyline barriers by referencing a layer.

    • layerName —The name or ID of the data layer in the map service that is being referenced.

    • where (optional)—A WHERE clause for the query filter. Any legal SQL WHERE clause operating on the fields in the layer is allowed.

    • geometry (optional)—The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

      The geometry type is specified using the geometryType property.

    • geometryType (optional)—The type of geometry specified by the geometry property. The supported geometry types are envelope, point, line, and polygon. The default geometry type is esriGeometryEnvelope .

      Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

    • spatialRel (optional)—The spatial relationship to be applied to the input geometry . The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is esriSpatialRelIntersects .

      Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .

Attributes for polylineBarriers

When specifying the polylineBarriers parameter using JSON structure, the parameter can be specified with the following attribute:

Name

The name of the barrier.

ObjectID

The object ID of the line barrier. ObjectID is a unique identifier for the line barrier. If you want to maintain a relationship between the input and output, set preserveObjectID to true . The ObjectID value of the input line barrier is included in the output line barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of the line barriers. If the ObjectID value is not specified, a unique ID is automatically generated in the output.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

BarrierType

Specify whether the barrier restricts travel completely or scales time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Restriction)—Prohibits travel through the barrier. The barrier is referred to as a restriction line barrier since it acts as a restriction.
  • 1 (Scaled Cost)—Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_[Cost] attribute.

Attr_[Cost]

This attribute is specific to scaled-cost barriers. It is the factor by which the cost of edges underlying the barrier are multiplied.

Syntax examples for polylineBarriers

Syntax for specifying polyline barriers using JSON structure for features

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>]
          ]
        ],
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "paths": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ],
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying polyline barriers using a URL returning a JSON response

Use dark colors for code blocksCopy
1
2
3
4
{
  "url": "<url>"
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying polyline barriers using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
  "doNotLocateOnRestrictedElements": true | false
}

Examples for polylineBarriers

Example 1: Specify polyline barriers using JSON structure

This example shows how to add two lines as polyline barriers to restrict travel on the streets intersected by the lines. Barrier 1 is a single-part line feature composed of two points. Barrier 2 is a two-part line feature. The first part is composed of three points, and the second part is composed of two points.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [-10804823.397,3873688.372],
            [-10804811.152,3873025.945]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 1"
      }
    },
    {
      "geometry": {
        "paths": [
          [
            [-10804823.397,3873688.372],
            [-10804807.813,3873290.911],
            [-10804811.152,3873025.945]
          ],
          [
            [-10805032.678,3863358.76],
            [-10805001.508,3862829.281]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 2"
      }
    }
  ]
}

Example 2: Specify a polyline barrier using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

Use dark colors for code blocksCopy
1
2
3
{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

Example 3: Specify a polyline barrier using a layer

Use dark colors for code blocksCopy
1
2
3
4
{
  "type" : "layer",
  "layerName" : "PolylineBarrier"
}

polygonBarriers

Use this parameter to specify polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

You can specify polygon barrier geometries as well as attributes using a JSON structure that references a set of features. The property is optional; however, the JSON structure must specify either the url , features , or layer property:

  • url —Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • features —Specify an array of features.

    Each feature in this array represents a polygon barrier and contains the following fields:

    • geometry —Specify the input point geometry containing x and y properties along with the spatialReference property. If the spatialReference property is defined for the entire JSON, you don't need to define this property for each geometry. Doing so reduces the size of the input JSON if the input has many features and improves performance. This property is not required if the coordinates are in the default spatial reference, WGS84. If the coordinates are in a different spatial reference, you must specify the spatial reference's well-known ID (WKID). See Using spatial references to look up WKID values.

    • attributes —Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.

    The JSON structure can include the following property:

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .
  • layer —Specify a feature layer in the map service. Attribute and spatial filters can also be applied on the layer. The JSON structure can include the following properties:

    • type —Set the type property to layer to indicate that you're specifying the polygon barriers by referencing a layer.

    • layerName —The name or ID of the data layer in the map service that is being referenced.

    • where (optional)—A WHERE clause for the query filter. Any legal SQL WHERE clause operating on the fields in the layer is allowed.

    • geometry (optional)—The geometry to apply as the spatial filter. The structure of the geometry is the same as the structure of the JSON geometry objects returned by the ArcGIS REST API.

      The geometry type is specified using the geometryType property.

    • geometryType (optional)—The type of geometry specified by the geometry property. The supported geometry types are envelope, point, line, and polygon. The default geometry type is esriGeometryEnvelope .

      Values: esriGeometryPoint | esriGeometryMultipoint | esriGeometryPolyline | esriGeometryPolygon | esriGeometryEnvelope

    • spatialRel (optional)—The spatial relationship to be applied to the input geometry . The supported spatial relationships include intersects, contains, envelope intersects, within, and so on. The default spatial relationship is esriSpatialRelIntersects .

      Values: esriSpatialRelIntersects | esriSpatialRelContains | esriSpatialRelCrosses | esriSpatialRelEnvelopeIntersects | esriSpatialRelIndexIntersects | esriSpatialRelOverlaps | esriSpatialRelTouches | esriSpatialRelWithin

    • doNotLocateOnRestrictedElements (optional)—Specify whether the restricted network elements will be considered when finding network locations. The default is true .

Attributes for polygonBarriers

When specifying the polygonBarriers parameter using JSON structure, you can specify additional information about barriers—such as the barrier type—using attributes. The polygonBarriers parameter can be specified with the following attributes:

Name

The name of the barrier.

ObjectID

The object ID of the polygon barrier. ObjectID is a unique identifier for the polygon barrier. If you want to maintain a relationship between the input and output, set preserveObjectID to true . The ObjectID value of the input polygon barrier is included in the output polygon barrier (as the ObjectID field) and can be used to join additional information from analysis outputs to the attribute of the polygon barriers. If the ObjectID value is not specified, a unique ID is automatically generated in the output.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

BarrierType

  • 0 (Restriction)—Prohibits traveling through any part of the barrier. The barrier is referred to as a restriction polygon barrier since it prohibits traveling on streets intersected by the barrier. One use of this type of barrier is to model floods covering areas of the street that make traveling on those streets impossible.

    This is the default value.

    Two maps demonstrate how a restriction polygon barrier affects finding a route between two stops.

    The first map depicts the shortest path between two stops. The second map shows a polygon barrier blocking flooded streets, so the shortest path between the same two stops is different.

  • 1 (Scaled Cost)—Scales the time or distance required to travel the underlying streets by a factor specified using Attr_[Cost] . If the streets are partially covered by the barrier, the travel time or distance is apportioned and then scaled. For example, a factor of 0.25 means that travel on underlying streets is expected to be four times faster than normal. A factor of 3.0 means it is expected to take three times longer than normal to travel on underlying streets. This barrier type is referred to as a scaled cost polygon barrier. It can be used to model storms that reduce travel speeds in specific regions, for example.

    Two maps demonstrate how a scaled cost polygon barrier affects finding a route between two stops.

    The first map shows a route that goes through inclement weather without regard for the effect that poor road conditions have on travel time. The second map shows a scaled polygon barrier that doubles the travel time of the roads covered by the storm. The route still passes through the southern tip of the storm since it is quicker to spend more time driving slowly through a small part of the storm rather than driving completely around it. The service uses the modified travel time in calculating the best route, and the modified travel time is reported as the total travel time in the response.

Attr_[Cost]

This is the factor by which the cost of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled cost barriers. The attribute value must be greater than zero.

Syntax examples for polygonBarriers

Syntax for specifying polygon barriers using JSON structure for features

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>],
            [<x11>,<y11>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>],
            [<x21>,<y21>]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "rings": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>],
            [<x11>,<y11>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>],
            [<x21>,<y21>]
          ]
        ]
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ],
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying polygon barriers using a URL returning a JSON response

Use dark colors for code blocksCopy
1
2
3
4
{
  "url": "<url>"
  "doNotLocateOnRestrictedElements": true | false
}

Syntax for specifying polygon barriers using a layer

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
{
  "type" : "layer",
  "layerName" : "<layerName>",
  "where" : "<whereClause>",
  "geometry" : {<geometry>},
  "geometryType" : "<geometryType>",
  "spatialRel" : "<spatialRel>"
  "doNotLocateOnRestrictedElements": true | false
}

Examples for polygonBarriers

Example 1: Specify a polygon barrier using JSON structure

This example shows how to add two polygons as barriers. The first polygon, Flood zone, is a restriction polygon barrier that prohibits travel on the underlying streets. The polygon is a single-part polygon feature composed of four points. The second polygon, Severe weather zone, is a scaled-cost polygon barrier that reduces the travel time on underlying streets to one-third of the original value. The polygon is a two-part polygon feature. Both parts are composed of four points.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [-97.0634,32.8442],
            [-97.0554,32.84],
            [-97.0558,32.8327],
            [-97.0638,32.83],
            [-97.0634,32.8442]
          ]
        ]
      },
      "attributes": {
        "Name": "Flood zone",
        "BarrierType": 0
      }
    },
    {
      "geometry": {
        "rings": [
          [
            [-97.0803,32.8235],
            [-97.0776,32.8277],
            [-97.074,32.8254],
            [-97.0767,32.8227],
            [-97.0803,32.8235]
          ],
          [
            [-97.0871,32.8311],
            [-97.0831,32.8292],
            [-97.0853,32.8259],
            [-97.0892,32.8279],
            [-97.0871,32.8311]
          ]
        ]
      },
      "attributes": {
        "Name": "Severe weather zone",
        "BarrierType": 1,
        "Attr_TravelTime": 3
      }
    }
  ]
}

Example 2: Specify a polygon barrier using a URL

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

Use dark colors for code blocksCopy
1
2
3
{
  "url": "https://machine.domain.com/webadaptor/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

Example 3: Specify a polygon barrier using a layer

Use dark colors for code blocksCopy
1
2
3
4
{
  "type" : "layer",
  "layerName" : "PolygonBarrier"
}

returnDirections

Specify whether the service will generate driving directions for each route.

The default value is false .

  • true —Generate directions. The directions are configured based on the values for the directionsLanguage , directionsOutputType , directionsStyleName , and directionsLengthUnits parameters. The directions are available in the directions property of the JSON response.
  • false —Don't generate directions.

returnCFRoutes

Use this parameter to specify whether the service will return routes.

  • true —Routes are returned. The routes are available in the routes property of the JSON response. The shape of the routes depends on the value for the outputLines parameter.
  • false —Routes are not returned.

directionsLanguage

The language that will be used when generating travel directions.

This parameter applies only when the returnDirections parameter is set to true . The service supports generating directions in the following languages:

  • ar —Arabic
  • bg —Bulgarian
  • bs —Bosnian
  • ca —Catalan
  • cs —Czech
  • da —Danish
  • de —German
  • el —Greek
  • en —English
  • es —Spanish
  • et —Estonian
  • fi —Finnish
  • fr —French
  • he —Hebrew
  • hr —Croatian
  • hu —Hungarian
  • id —Indonesian
  • it —Italian
  • ja —Japanese
  • ko —Korean
  • lt —Lithuanian
  • lv —Latvian
  • nb —Norwegian
  • nl —Dutch
  • pl —Polish
  • pt-BR —Portuguese (Brazil)
  • pt-PT —Portuguese (Portugal)
  • ro —Romanian
  • ru —Russian
  • sk —Slovak
  • sl —Slovenian
  • sr —Serbian
  • sv —Swedish
  • th —Thai
  • tr —Turkish
  • uk —Ukrainian
  • vi —Vietnamese
  • zh-CN —Chinese (China)
  • zh-HK —Chinese (Hong Kong)
  • zh-TW —Chinese (Taiwan)

The service tries to find an exact match for the specified language including any language localization. If an exact match is not found, it tries to match the language family. If a match is still not found, the service returns the directions using the default language of the server's operating system. For example, if the directions language is specified as es-MX (Mexican Spanish), the service will return the directions in Spanish, as it supports the es language code, not es-MX .

directionsOutputType

Define the content and verbosity of the driving directions. This parameter applies only when the returnDirections parameter is set to true . This parameter can be specified using the following values:

  • esriDOTComplete —The directions output includes all directions properties.
  • esriDOTCompleteNoEvents —The directions output includes all directions properties except events.
  • esriDOTInstructionsOnly —The directions output includes text instructions, time, length and ETA. The directions do not include geometry.
  • esriDOTStandard —The directions output includes text instructions, time, length, ETA, and geometry. The directions do not include events, new types of strings (street names, signposts information), maneuver type, bearings, or turn angle.
  • esriDOTSummaryOnly —The directions output contains a summary (time and length). Detailed text instructions and geometry are not included.
  • esriDOTFeatureSets —Setting this value will output directionPoints and directionLines which supersedes the directions output parameter. The direction points set contains point features representing the direction maneuvers such as arriving to or departing from a stop, turning left or right, and other events along the route. This feature set also contains the route's turn-by-turn directions. The direction lines set contains line features for each segment of the route. This feature set can be used to visualize the turn-by-turn directions on a map.

The default value is esriDOTStandard .

directionsStyleName

Specify the name of the formatting style for the directions. This parameter can be specified using the following values:

  • NA Desktop —Generates turn-by-turn directions suitable for printing.
  • NA Navigation —Generates turn-by-turn directions designed for an in-vehicle navigation device.
  • NA Campus —Generates turn-by-turn walking directions designed for pedestrian routes.

The default value is NA Desktop .

This parameter applies only when the returnDirections parameter is set to true .

directionsLengthUnits

Specify the units for displaying travel distance in the driving directions. This parameter applies only when the returnDirections parameter is set to true . This parameter can be specified using the following values:

  • esriNAUFeet
  • esriNAUKilometers
  • esriNAUMeters
  • esriNAUMiles
  • esriNAUNauticalMiles
  • esriNAUYards

The default value is esriNAUMiles .

directionsTimeAttributeName

Set the time-based impedance attribute to display the duration of a maneuver, such as "Go northwest on Alvarado St. for 5 minutes." The units for all the time attributes is minutes.

  • TravelTime —Travel time for a car
  • Minutes —Travel time for a car without using live traffic data
  • TruckTravelTime —Travel time for a truck
  • TruckMinutes —Travel time for a truck without using live traffic data
  • WalkTime —Travel time for a pedestrian

outputLines

Use this parameter to specify the type of route features that are output by the service. This parameter is applicable only if the returnCFRoutes parameter is set to true . The outputLines parameter can have one of the following values:

  • esriNAOutputLineTrueShape —Return the exact shape of the resulting route that is based on the underlying streets.
  • esriNAOutputLineTrueShapeWithMeasure —Return the exact shape of the resulting route that is based on the underlying streets and include route measurements that keep track of the cumulative travel time or travel distance along the route relative to the first stop. When this value is chosen for the outputLines parameter, each point in the route shape will include an m-value along with an x-value and a y-value. The m-value, also known as the measure value, indicates the accumulated travel time or travel distance at that point along the route. The m-values can be used to determine how far you have traveled from the start of the route or the remaining distance or time left to reach the destination. The m-values are in the same units as the impedance attribute.
  • esriNAOutputLineStraight —Return a straight line between the incident and the closest facility.
  • esriNAOutputLineNone —Do not return any shapes for the routes. This value can be useful when you are only interested in determining the total travel time or travel distance of the route. For example, if the application has calculated the route and after some time it will calculate the estimated time of arrival (ETA) to the destination, you can set the returnCFRoutes parameter to true and the outputLines parameter to esriNAOutputLineNone . The routes property of the JSON response will only contain the total travel time that can be used to determine the ETA. Since the route shape is not returned when using the esriNAOutputLineNone value, the response size will be considerably smaller.

returnFacilities

Use this parameter to specify whether facilities will be returned by the service. The possible values for this parameter are true or false . A true value indicates that the facilities used as input will be returned as part of the facilities property in the JSON response. The default value for this parameter is false .

If you specified the facilities parameter value using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, you can set the returnFacilities parameter to true so you can draw the facility locations in the application. You can also set the returnFacilities property to true to determine whether the facilities were successfully located on the street network or had other errors by reviewing the Status property in the JSON response.

returnIncidents

Use this parameter to specify whether incidents will be returned by the service. The possible values for this parameter are true or false . A true value indicates that the incidents used as input will be returned as part of the facilities property in the JSON response. The default value for this parameter is false .

If you specified the incidents parameter value using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, you can set the returnIncidents parameter to true so you can draw the incident locations in the application. You can also set the returnIncidents property to true to determine whether the incidents were successfully located on the street network or had other errors by reviewing the Status property in the JSON response.

returnBarriers

Specify whether barriers will be returned by the service.

  • true —The input point barriers are returned as part of the barriers property in the JSON response.
  • false —Point barriers are not returned. This is the default.

For this parameter to take effect, you must also specify a value for the barriers parameter.

If you specified the barriers parameter value using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, you can set the returnBarriers parameter to true so you can draw the point barrier locations in the application. You can also set the returnBarriers property to true to see where the barriers were located on the street network or, if they weren't located, understand what the problem was by reviewing the Status property in the JSON response.

returnPolylineBarriers

Specify whether polyline barriers will be returned by the service.

  • true —The input polyline barriers are returned as part of the polylineBarriers property in the JSON response.
  • false —Polyline barriers are not returned. This is the default.

For this parameter to take effect, you must also specify a value for the polylineBarriers parameter.

If you specified the polylineBarriers parameter value using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, you can set the returnPolylineBarriers parameter to true so you can draw the polyline barrier locations in the application.

returnPolygonBarriers

Specify whether polygon barriers will be returned by the service.

  • true —The input polygon barriers are returned as part of the polygonBarriers property in the JSON response.
  • false —Polygon barriers are not returned. This is the default.

For this parameter to take effect, you must also specify a value for the polygonBarriers parameter.

If you specified the polygonBarriers parameter value using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, you can set the returnPolygonBarriers parameter to true so you can draw the polygon barrier locations in the application.

returnTraversedEdges

Specify whether traversed edges will be returned by the service.

  • true —The traversed edges are returned as part of the JSON response.
  • false —The traversed edges are not returned.

When this parameter is set to true , the traversed edges are available in the traversedEdges property of the JSON response.

The default value is false

returnTraversedJunctions

Specify whether traversed junctions will be returned by the service.

  • true —The traversed junctions are returned as part of the JSON response.
  • false —The traversed junctions are not returned.

When this parameter is set to true , the traversed junctions are available in the traversedJunctions property of the JSON response.

The default value is false

returnTraversedTurns

Specify whether traversed turns will be returned by the service.

  • true —The traversed turns are returned as part of the JSON response.
  • false —The traversed turns are not returned.

When this parameter is set to true , the traversed turns are available in the traversedTurns property of the JSON response.

The default value is false

returnZ

Include z-values for the returned geometries if supported by the underlying network. The default value is false .

  • true —The output geometries will have a z-value.
  • false (default)—No x-value is returned.

ignoreInvalidLocations

Specify whether invalid input locations will be ignored when finding the best solution. An input point is deemed invalid by the service if it is not within the maximum snap tolerance of any traversable street.

  • true —Invalid points are ignored.
  • false —Any invalid point in the request will cause the service to return a failure.

The default value is true .

outSR

Use this parameter to specify the spatial reference of the geometries, such as line or point features, returned by the service.

The parameter value can be specified as a well-known ID (WKID) for the spatial reference. See Using spatial references to look up WKID values.

Many of the basemaps provided by ArcGIS Online are in the Web Mercator spatial reference (WKID 102100). Specifying outSR=102100 returns the geometries in the Web Mercator spatial reference, which can be drawn on top of the basemaps.

outputGeometryPrecision

Use this parameter to specify the simplification level for the route geometry returned by the service.

Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The simplification distance you specify is the maximum allowable offset that the simplified line can deviate from the original line. Simplifying a line reduces the number of vertices that are part of the route geometry. This reduces the overall response size and also improves the performance for drawing the route shapes in the applications.

The units are specified using the outputGeometryPrecisionUnits parameter.

outputGeometryPrecisionUnits

Use this parameter to specify the units for the outputGeometryPrecision parameter value.

Specify the value as one of the following:

  • esriCentimeters
  • esriDecimalDegrees
  • esriDecimeters
  • esriFeet
  • esriInches
  • esriKilometers
  • esriMeters
  • esriMiles
  • esriMillimeters
  • esriNauticalMiles
  • esriPoints
  • esriYards

geometryPrecision

Use this parameter to specify the number of decimal places that will be used in the response geometries returned by the solve operation. This applies to x- and y-values only (not m- or z-values).

Use dark colors for code blocksCopy
1
geometryPrecision = 3

geometryPrecisionZ

Use this parameter to specify the number of decimal places that will be used in the response geometries returned by the solve operation. This applies to z-values only (not x-, y-, or m-values).

Use dark colors for code blocksCopy
1
geometryPrecisionZ = 3

geometryPrecisionM

Use this parameter to specify the number of decimal places that will be used in the response geometries returned by the solve operation. This applies to m-values only (not x-, y-, or z-values).

Use dark colors for code blocksCopy
1
geometryPrecisionM = 3

overrides

preserveObjectID

Use this parameter to specify whether the object IDs specified for input locations such as facilities, incidents, or barriers will be preserved when the input locations are returned as output. This can be useful if you want to associate additional attributes with the output locations after the solve operation is successful and need a common key field to do the join.

For example, the input incidents are specified as the following JSON representation of a feature set:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.4079,
        "y": 37.78356
      },
      "attributes": {
        "ObjectID": 10,
        "Name": "Fire Incident 1"
      }
    },
    {
      "geometry": {
        "x": -122.404,
        "y": 37.782
      },
      "attributes": {
        "ObjectID": 20,
        "Name": "Crime Incident 45"
      }
    }
  ]
}

The input facilities are specified as the following JSON representation of a feature set:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": -122.4079,
        "y": 37.78356
      },
      "attributes": {
        "ObjectID": 30,
        "Name": "Fire Station 34"
      }
    },
    {
      "geometry": {
        "x": -122.404,
        "y": 37.782
      },
      "attributes": {
        "ObjectID": 40,
        "Name": "Fire Station 29"
      }
    }
  ]
}

If you solve a closest facility and specify preserveObjectID=false , the output incidents will have object IDs 1, 2, and the output facilities will have object IDs 1, 2, even though the input incidents have object IDs 10, 20, and the input facilities have object IDs 30, 40. However, if preserveObjectID=true , the output incidents and facilities will preserve the object IDs from the inputs.

locateSettings

Use this parameter to specify settings that affect how inputs are located, such as the maximum search distance to use when locating the inputs on the network or the network sources being used for locating. To restrict locating on a portion of the source, you can specify a where clause for a source.

Learn more about locating inputs

The parameter value is specified as a JSON object. The JSON object allows you to specify a locator JSON for all input feature in the analysis, or you can specify an override for a particular input. The override allows you to have different settings for each analysis input. For example, you can disallow stops to locate on highway ramps and allow point barriers to locate on highway ramps.

The locator JSON object has the following properties:

  • tolerance and toleranceUnits —Allows you to control the maximum search distance when locating inputs. If no valid network location is found within this distance, the input features will be considered unlocated. A small search tolerance decreases the likelihood of locating on the wrong street but increases the likelihood of not finding any valid network location. The toleranceUnits parameter value can be specified as one of the following values:

    • esriCentimeters
    • esriDecimalDegrees
    • esriDecimeters
    • esriFeet
    • esriInches
    • esriIntFeet
    • esriIntInches
    • esriIntMiles
    • esriIntNauticalMiles
    • esriIntYards
    • esriKilometers
    • esriMeters
    • esriMiles
    • esriMillimeters
    • esriNauticalMiles
    • esriYards
  • sources —Allows you to control which network source can be used for locating. For example, you can configure the analysis to locate inputs on streets but not on sidewalks. The list of possible sources on which to locate is specific to the network dataset this service references. Only the sources that are present in the sources array are used for locating. You can specify a where clause on each source you specified in the sources array to further restrict locating on that source matching certain characteristics using an SQL expression. For example, you can configure the analysis to locate inputs only on street features matching certain road classes such as avoiding highway ramps. Sources is specified as an array of objects, each having the following properties:

    • name —Name of the network source feature class that can be used for locating inputs.
    • where —An SQL expression on the network source feature class.
  • allowAutoRelocate —Allows you to control whether inputs with existing network location fields can be automatically relocated when solving to ensure valid, routable location fields for the analysis. If the value is true , points located on restricted network elements and points affected by barriers will be relocated to the closest routable location. If the value is false , network location fields will be used as is even if the points are unreachable, and this may cause the solve to fail. Even if the value is false , inputs with no location fields or incomplete location fields will be located during the solve operation.

The parameter value is specified as a JSON object. The JSON object allows you to specify a locator JSON for all input feature in the analysis, or you can specify an override for a particular input. The override allows you to have different settings for each analysis input. For example, you can disallow stops to locate on highway ramps and allow point barriers to locate on highway ramps. When specifying the locateSettings JSON, you must provide all the properties including tolerance , toleranceUnits , sources , and allowAutoRelocate in the default locator JSON object. The where clause for each source is optional. If you need to provide a different locator JSON for a particular input class, you must include the overrides property for that input. The property name must match the input parameter name. The locator JSON for a particular input doesn't need to include all the properties; you only need to include the properties that are different from the default locator JSON properties.

Syntax for locateSettings

Syntax for specifying locateSettings using JSON structure

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  "default": {
    "tolerance": <value>,
    "toleranceUnits": "<unit>",
    "allowAutoRelocate": true | false,
    "sources": [
      {
        "name": "<sourceName>",
        "where": "<whereClause>"
      }
    ]
  },
  "overrides": {
    "incidents": {
      "tolerance": <value>,
      "toleranceUnits": "<unit>",
      "allowAutoRelocate": true | false,
      "sources": [
        {
          "name": "<sourceName>",
          "where": "<whereClause>"
        }
      ]
    },
    "facilities": {
      "tolerance": <value>,
      "toleranceUnits": "<unit>",
      "allowAutoRelocate": true | false,
      "sources": [
        {
          "name": "<sourceName>",
          "where": "<whereClause>"
        }
      ]
    },
    "barriers": {
      "tolerance": <value>,
      "toleranceUnits": "<unit>",
      "allowAutoRelocate": true | false,
      "sources": [
        {
          "name": "<sourceName>",
          "where": "<whereClause>"
        }
      ]
    },
    "polylineBarriers": {
      "allowAutoRelocate": true | false,
      "sources": [
        {
          "name": "<sourceName>",
          "where": "<whereClause>"
        }
      ]
    },
    "polygonBarriers": {
      "allowAutoRelocate": true | false,
      "sources": [
        {
          "name": "<sourceName>",
          "where": "<whereClause>"
        }
      ]
    }
  }
}

Examples for locateSettings

Example 1: Specify default locate settings using JSON structure

This example shows how to specify locate settings so inputs are only located within 500 meters of the specified location. A small search tolerance like this can be valuable if you are solving using a walking travel mode and don't want inputs to be located farther than 500 meters from the original point location.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
{
  "default": {
    "tolerance": 500,
    "toleranceUnits": "esriMeters",
    "allowAutoRelocate": true,
    "sources": [
      {
        "name": "Routing_Streets"
      }
    ]
  }
}

Example 2: Specify default locate settings and locate settings overrides for some inputs using JSON structure

This example shows how to specify locate settings to prevent incidents and facilities from locating on highway ramps. The default locate settings allow locating on the Routing_Streets source. For incidents and facilities, the overrides option is used to specify a where clause for the Routing_Streets source to prevent locating on highway ramps (a ROAD_CLASS field value of 3). With this locateSettings JSON, incidents and facilities cannot locate on highway ramps, but barriers can because they use the default locate settings, which do not include a where clause.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{
  "default": {
    "tolerance": 20,
    "toleranceUnits": "esriKilometers",
    "allowAutoRelocate": true,
    "sources": [
      {
        "name": "Routing_Streets"
      }
    ]
  },
  "overrides": {
    "incidents": {
      "sources": [
        {
          "name": "Routing_Streets",
          "where": "ROAD_CLASS <> 3"
        }
      ]
    },
    "facilities": {
      "sources": [
        {
          "name": "Routing_Streets",
          "where": "ROAD_CLASS <> 3"
        }
      ]
    }
  }
}

Example 3: Specify default locate settings and locate settings overrides using JSON structure so different inputs are located using different sources

This example shows how to specify default locate settings to locate inputs on the Routing_Streets source feature class while allowing barriers to only locate on the system junctions feature class (Routing_ND_Junctions).

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{
  "default": {
    "tolerance": 20,
    "toleranceUnits": "esriKilometers",
    "allowAutoRelocate": true,
    "sources": [
      {
        "name": "Routing_Streets"
      }
    ]
  },
  "overrides": {
    "barriers": {
      "sources": [
        {
          "name": "Routing_ND_Junctions"
        }
      ]
    }
  }
}

returnEmptyResults

Specify whether the service will return empty results instead of the error property when the request fails.

  • true —The JSON response doesn't contain the error property when the request fails. All errors are returned in the messages property. The response JSON may contain an empty feature set or empty result for the properties you requested.
  • false —The JSON response only contains the error property when the request fails.

The default value is false .

Typically when a request fails, the service will return a JSON response that contains the error property. In some cases, you might want to set returnEmptyResults to true so it always returns properties you requested instead of returning an error response to help handle the response in a more consistent way.

Even if the request fails, when you set returnEmptyResults = true , returnFacilities = true , and returnIncidents = true , you can return facilities and incidents to investigate why some of them failed to locate.

Output parameters

Upon a successful solver operation, the service returns the best route and travel directions between the incident and the chosen facility and the status indicating whether the analysis was successful using the output parameters described below.

routes

This provides access to the resulting route or routes between the facilities and the incidents.

The data type supports the following fields:

Field nameDescription

ObjectID

The system-managed ID field.

FacilityRank

The rank of the facility among all facilities found for the associated incident; the closest facility has a rank of 1.

FacilityID

The unique ID of the facility the route visits.

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the closest facility route is based on the names of the associated facility and incident.

The facility name is first if the value for the travelDirection property on the analysis object is set to esriNATravelDirectionFromFacility . For example, Facility 5 - Incident 3 indicates that the route travels from Facility 5 to Incident 3.

If esriNATravelDirectionToFacility is specified as the value for the travelDirection property, the incident name is first, for example, Incident 3 — Facility 5 .

IncidentCurbApproach

The side of the vehicle the incident is on when arriving at or departing from the incident. A value of 1 means the right side of the vehicle; a value of 2 indicates the left side.

FacilityCurbApproach

The side of the vehicle the facility is on when arriving at or departing from the facility. A value of 1 means the right side of vehicle; a value of 2 indicates the left side.

IncidentID

The unique ID of the incident the route visits.

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

StartTime

The start time of the route, reported in the time zone in which the first stop is located.

EndTime

The end time of the route, reported in the time zone in which the last stop is located.

StartTimeUTC

The start time of the route in coordinated universal time (UTC).

EndTimeUTC

The end time of the route in coordinated universal time (UTC).

Total_[Cost]

(for instance Total_Minutes , where Minutes is the travel cost)

The total distance, time, or other travel cost from the first stop to the last stop. The total travel cost and the Attr_[Cost] value of the visited stops are included in this value.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

facilities

This provides access to the output facilities from a closest facility analysis.

These data types support the following fields. In addition to these fields, the data types also include all the fields from the input feature class used as facilities for the analysis.

Field nameDescription

ObjectID

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the facility. The values for this field are copied from the Name field on the input facilities.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

The direction a vehicle may arrive at and depart from the facility. The values for this field are copied from the CurbApproach field on the input facilities.

Status

Indicates the status of the point with respect to its location on the network and the outcome of the analysis. The possible values are the following:

  • 0 (OK)—The point was located on the network.
  • 1 (Not Located)—The point was not located on the network and consequently was not included in the analysis.
  • 2 (Network element not located)—The network element identified by the point's network location fields can't be found. This can occur when a network element where the point should be was deleted, and the network location was not recalculated.
  • 3 (Element not traversable)—The network element that the point is located on is not traversable. This can occur when the element is restricted by a restriction attribute.
  • 4 (Invalid Field Values)—Field values fall outside a range or coded-value domain. For example, a negative number exists where positive numbers are required.
  • 5 (Not Reached)—The point can't be reached by the solver. The point may be on a separate, disconnected area of the network from the other inputs, or barriers or restrictions prevent travel to or from the point.
  • 6 (Time window violation)—The point could not be reached within the designated time windows. This status only applies to network analysis types that support time windows.
  • 7 (Not located on closest)—The closest network location to the point is not traversable because of a restriction or barrier, so the point has been located on the closest traversable network feature instead.

SnapX

The x-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapY

The y-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapZ

The z-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset. The SnapZ field is 0 if the network is two dimensional.

DistanceToNetworkInMeters

The distance in meters between the point's geographic location and the position where it was located on the network.

Attr_[Cost]

(For instance, Attr_TravelMinutes , when TravelMinutes is the travel cost)

This field stores an extra cost for the network location.

For example, to find the three closest fire stations to a fire incident using TravelTime as the impedance, Attr_TravelTime can store the turnout time for the facility. Turnout time is how long it takes a crew to put on the appropriate protective equipment and exit the fire station.

Cutoff_[Cost]

(For instance, Cutoff_TravelMinutes , when TravelMinutes is the travel cost)

While searching for the closest incident from a facility, a cutoff value for the impedance can be used. Any incident beyond the cutoff value will not be searched.

If the Cutoff_[Cost] value is not set for a facility, the analysis will use the defaultCutoff value. If the defaultCutoff value is not set on the service, the closest incident will be found, regardless of how far it may be.

incidents

This provides access to the locations used as starting or ending points in a closest facility analysis.

The data type supports the following fields:

Field NameDescription

ObjectID

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the incident. The values for this field are copied from the Name field on input incidents.

TargetFacilityCount

The number of facilities that need to be found for the given incident. The values for this field are copied from the TargetFacilityCount field on the input incident.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

The direction a vehicle may arrive at and depart from the incident. The values for this field are copied from the CurbApproach field on the input incident.

Status

Indicates the status of the point with respect to its location on the network and the outcome of the analysis. The possible values are the following:

  • 0 (OK)—The point was located on the network.
  • 1 (Not Located)—The point was not located on the network and consequently was not included in the analysis.
  • 2 (Network element not located)—The network element identified by the point's network location fields can't be found. This can occur when a network element where the point should be was deleted, and the network location was not recalculated.
  • 3 (Element not traversable)—The network element that the point is located on is not traversable. This can occur when the element is restricted by a restriction attribute.
  • 4 (Invalid Field Values)—Field values fall outside a range or coded-value domain. For example, a negative number exists where positive numbers are required.
  • 5 (Not Reached)—The point can't be reached by the solver. The point may be on a separate, disconnected area of the network from the other inputs, or barriers or restrictions prevent travel to or from the point.
  • 6 (Time window violation)—The point could not be reached within the designated time windows. This status only applies to network analysis types that support time windows.
  • 7 (Not located on closest)—The closest network location to the point is not traversable because of a restriction or barrier, so the point has been located on the closest traversable network feature instead.

SnapX

The x-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapY

The y-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset.

SnapZ

The z-coordinate of the position on the network dataset where the point was located, in the coordinate system of the network dataset. The SnapZ field is 0 if the network is two dimensional.

DistanceToNetworkInMeters

The distance in meters between the point's geographic location and the position where it was located on the network.

Attr_[Cost]

(For instance, Attr_TravelMinutes , when TravelMinutes is the travel cost)

This field stores an extra cost for the network location.

For example, to find the three closest fire stations to a fire incident using TravelTime as the impedance, Attr_TravelTime can store the amount of time spent at the fire incident. This can be the time it takes the firefighters to hook up their equipment and begin fighting the fire.

Cutoff_[Cost]

(For instance, Cutoff_TravelMinutes , when TravelMinutes is the travel cost)

This cutoff value indicates the farthest network distance to search for a facility. Any facility farther from the incident than the cutoff value will not be searched or included in the results.

If the Cutoff_[Cost] value is not set for an incident, the analysis will use the defaultCutoff value. If the defaultCutoff value is not set on the service, the closest facility will be found, regardless of how far it may be.

barriers

This provides access to points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets.

Field nameDescription

ObjectID

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the barrier.

SourceID

The numeric identifier of the network dataset source feature class on which the input point is located.

SourceOID

The ObjectID of the feature in the source on which the input point is located.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. This field is null if the network location references a junction.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. This field is limited to a domain of two values: Right Side (1) and Left Side (2).

CurbApproach

The direction of traffic that is affected by the barrier. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Either side of vehicle): The barrier affects travel over the edge in both directions.
  • 1 (Right side of vehicle): Vehicles are only affected if the barrier is on their right side during the approach. Vehicles that traverse the same edge but approach the barrier on their left side are not affected by the barrier.
  • 2 (Left side of vehicle): Vehicles are only affected if the barrier is on their left side during the approach. Vehicles that traverse the same edge but approach the barrier on their right side are not affected by the barrier.

Status

Indicates the status of the point with respect to its location on the network and the outcome of the analysis. The possible values are the following:

  • 0 (OK)—The point was located on the network.
  • 1 (Not Located)—The point was not located on the network and consequently was not included in the analysis.
  • 2 (Network element not located)—The network element identified by the point's network location fields can't be found. This can occur when a network element where the point should be was deleted, and the network location was not recalculated.
  • 3 (Element not traversable)—The network element that the point is located on is not traversable. This can occur when the element is restricted by a restriction attribute.
  • 4 (Invalid Field Values)—Field values fall outside a range or coded-value domain. For example, a negative number exists where positive numbers are required.
  • 5 (Not Reached)—The point can't be reached by the solver. The point may be on a separate, disconnected area of the network from the other inputs, or barriers or restrictions prevent travel to or from the point.
  • 6 (Time window violation)—The point could not be reached within the designated time windows. This status only applies to network analysis types that support time windows.
  • 7 (Not located on closest)—The closest network location to the point is not traversable because of a restriction or barrier, so the point has been located on the closest traversable network feature instead.

FullEdge

Point barriers are applied to the edge elements during the analysis. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (False): Permits travel on the edge up to the barrier, but not through it. This is the default value.
  • 1 (True): Restricts travel anywhere on the associated edge.

BarrierType

Specify if the point barrier restricts travel completely or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Restriction)-Prohibits travel through the barrier. The barrier is referred to as a restriction point barrier since it acts as a restriction.
  • 2 (Added Cost)- Traveling through the barrier increases the travel time or distance by the amount specified in the Attr_[Cost] property value

Attr_[Cost]

(for instance Attr_TravelTime , where TravelTime is the travel cost)

This property is specific to added-cost barriers and is limited to values that are greater than or equal to zero. It indicates how much cost is added when the barrier is traversed.

polylineBarriers

This provides access to one or more lines that prohibit travel anywhere the lines intersect the streets.

Field nameDescription

ObjectID

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the barrier.

BarrierType

Specify if the barrier restricts travel completely or scales time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Restriction)-Prohibits travel through the barrier. The barrier is referred to as a restriction line barrier since it acts as a restriction.
  • 1 (Scaled Cost)-Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_[Cost] attribute.

Attr_[Cost]

(for instance Attr_TraveTime , where TravelTime is the travel cost)

This property is specific to scaled-cost barriers. It is the factor by which the cost of edges underlying the barrier are multiplied.

polygonBarriers

This provides access to polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

Field nameDescription

ObjectID

If you specify preserveObjectID=false , the value for this field will be a system-generated ID. If preserveObjectID=True , the value for this field will be the ObjectID of your associated input.

Name

The name of the barrier.

BarrierType

Specify if the barrier restricts travel completely or scales time or distance when it is crossed. The value for this attribute is specified as one of the following integers (use the numeric code, not the name in parentheses):

  • 0 (Restriction)— Prohibits traveling through any part of the barrier. The barrier is referred to as restriction polygon barrier since it prohibits traveling on streets intersected by the barrier.
  • 1 (Scaled Cost)—Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_[Cost] attribute.

Attr_[Cost]

(for instance Attr_TravelTime , where TravelTime is the travel cost)

This property is specific to scaled-cost barriers. It is the factor by which the cost of edges underlying the barrier are multiplied.

traversedEdges

This parameter provides access to the edges that are traversed while solving a network analysis layer.

Field nameDescription

ObjectID

The system-managed ID field.

SourceID

The numeric identifier of the feature class the traversal element is referencing.

SourceOID

The object ID of the traversed source feature.

EID

This field indicates the element ID (EID) of the traversed network edge. An EID uniquely describes a network element. The EID of a network element is independent of the object ID of the feature. One feature can be stored as many different elements in the network.

FromPosition

Specifies where the output line feature begins in reference to the digitized direction of the underlying source feature.

  • A value of 0 (zero) indicates the line begins at the from point of the underlying source feature.
  • A value of 1 indicates the line begins at the to point of the source feature.
  • A value between 0 and 1 indicates the line begins at a point along the underlying source feature. For example, a value of 0.25 means the line begins 25 percent along the digitized direction of the underlying source feature.

ToPosition

Specifies where the output line feature ends in reference to the digitized direction of the underlying source feature.

  • A value of 0 (zero) indicates the line ends at the from point of the underlying source feature.
  • A value of 1 indicates the line ends at the to point of the source feature.
  • A value between 0 and 1 indicates the line ends at a point along the underlying source feature. For example, a value of 0.25 means the line ends 25 percent along the digitized direction of the underlying source feature.

FromJunctionID

The reference to the object ID of the junction in the traversedJunctions record set that is coincident with the start of the edge.

ToJunctionID

The reference to the object ID of the junction in the traversedJunctions record set that is coincident with the end of the edge.

RouteID

The object ID of the route in the output routes record set.

Attr_[Cost]

(for example, Attr_TravelTime when TravelTime is the travel cost)

The cost of the underlying edge. The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Cumul_[Cost]

The cumulative cost of the underlying network elements from the beginning of the route to the end of the edge represented by the line feature.

The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Attr_[Restriction]

Specifies whether the traversed edge used the restriction attribute referred to in this field's name.

  • 0—The traversed edge didn't use the restriction.
  • 1—The traversed edge used the restriction.

traversedJunctions

This parameter provides access to the junctions that are traversed while solving a network analysis layer.

Field nameDescription

ObjectID

The system-managed ID field.

SourceID

The numeric identifier of the feature class the traversal element is referencing.

SourceOID

The object ID of the traversed source feature.

EID

The element ID (EID) of the traversed network element. An EID uniquely describes a network element. The EID of a network element is independent of the object ID of the feature. One feature may be stored as many different elements in the network.

EID is -1 if the current record doesn't represent a junction. For example, it is -1 if the record represents a stop on a route.

RouteID

The object ID of the route in the output routes record set.

Attr_[Cost]

(for example, Attr_TravelTime when TravelTime is the travel cost)

The cost of the underlying junction. The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Cumul_[Cost]

The cumulative cost of the underlying network elements from the beginning of the route through the location of the current point feature.

The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Attr_[Restriction]

Specifies whether the traversed junction used the restriction attribute referred to in this field's name.

  • 0—The traversed junction didn't use the restriction.
  • 1—The traversed junction used the restriction.

traversedTurns

This parameter provides access to the turns that are traversed while solving a network analysis layer.

Field nameDescription

ObjectID

The system-managed ID field.

SourceID

The numeric identifier of the feature class the traversal element is referencing.

SourceOID

The object ID of the traversed source feature.

EID

The element ID (EID) of the traversed network element. An EID uniquely describes a network element. The EID of a network element is independent of the object ID of the feature. One feature may be stored as many different elements in the network.

EID is -1 if the record represents a traversed global turn.

FromEdgeID

The object ID of the edge in the traversedEdges record set that is coincident with the turn.

ToEdgeID

The object ID of the edge in the traversedEdges record set that is coincident with the end of the turn.

RouteID

The object ID of the route in the output routes record set.

Attr_[Cost]

(for example, Attr_TravelTime when TravelTime is the travel cost)

The cost of the underlying turn. The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Cumul_[Cost]

The cumulative cost of the underlying network elements from the beginning of the route through the location of the current turn.

The units of this field are the same as the units of the cost attribute referred to in the field name.

This field will be populated if the [Cost] part of this field is used as an impedance attribute or accumulated attributes.

Attr_[Restriction]

Specifies whether the traversed turn used the restriction attribute referred to in this field's name.

  • 0—The traversed turn didn't use the restriction.
  • 1—The traversed turn used the restriction.

directions

This provides access to the turn-by-turn directions for each resulting route.

The data type supports the following fields:

Field nameDescription

RouteName

The name of the route to which the driving action applies. This value is the same as the Name field of the output routes.

ArriveTime

The time of day to initiate the given driving action. If the route spans multiple days, the date and time of day are displayed.

Type

The type of maneuver that the directions feature represents or the type of the directions text. To determine whether Type refers to a maneuver type or a directions string type, review the SubItemType field value.

Type can be used, for example, to assign an icon for direction text based on the maneuver type, or it can use a formatting style based on the directions string type when displaying the driving directions in the application.

The Type value is an integer from the Maneuver Types or Directions String Types lists below.

Maneuver Types

  • 0: Unknown
  • 1: Arrive at Stop
  • 2: Go straight
  • 3: Bear left
  • 4: Bear right
  • 5: Turn left
  • 6: Turn right
  • 7: Make sharp left
  • 8: Make sharp right
  • 9: Make U-turn
  • 10: Take ferry
  • 11: Take roundabout
  • 12: Merge to highway
  • 13: Exit highway
  • 14: Go on another highway
  • 15: At fork keep center
  • 16: At fork keep left
  • 17: At fork keep right
  • 18: Depart stop
  • 19: Trip planning item
  • 20: End of ferry
  • 21: Ramp right
  • 22: Ramp left
  • 23: Turn left and immediately turn right
  • 24: Turn right and immediately turn left
  • 25: Turn right and immediately turn right
  • 26: Turn left and immediately turn left
  • 27: Pedestrian ramp
  • 28: Elevator
  • 29: Escalator
  • 30: Stairs
  • 31: Door passage

Directions String Types

  • 0: General directions string type
  • 1: Depart directions string type
  • 2: Arrive directions string type
  • 3: Length directions string type
  • 4: Time directions string type
  • 5: Time summary directions string type
  • 6: Time Window directions string type
  • 7: Violation Time directions string type
  • 8: Wait Time directions string type
  • 9: Service Time directions string type
  • 10: Estimated Arrival Time directions string type
  • 11: Cumulative Length directions string type
  • 12: Street name directions string type
  • 13: Alternate street name directions string type
  • 14: Sign branch information directions string type
  • 15: Sign toward information directions string type
  • 16: Cross street name directions string type
  • 17: Sign exit number directions string type

SubItemType

Specifies whether the Type field refers to an integer from the Directions String Types table or the Maneuver Types table.

  • If the SubItemType value is 1, the Type field refers to the values from the Maneuver Types table.
  • If the SubItemType value is 2, the Type field refers to the values from the Directions String Types table.
  • If the SubItemType value is 3, the Type field refers to the values from the Directions String Types table.

Text

A text description of the travel directions.

ElaspsedTime

The time elapsed in minutes from when the current driving direction starts until the next one starts, or until the route ends for the last driving direction.

DriveDistance

The distance from where the current driving direction occurs to where the next one occurs, or to where the route ends for the last driving direction.

The value is in the units specified by the directionsDistanceUnits property of the analysis object.

This value is zero for driving directions that occur at the same location where the next one begins. For example, the DriveDistance value is 0 for the directions text at the start of the route.

directionPoints

Specifies the output turn-by-turn directions for the routes calculated in the analysis, represented as point locations along the routes where specific direction events or maneuvers occur.

Field nameDescription

RouteID

The ObjectID value of the output Routes feature with which this direction point is associated.

Sequence

The sequence of the direction points for the route, starting with 1.

DirectionPointType

The type of direction event or maneuver described by the point, designated by one of the values below.

  • Header (1)
  • Arrive (50)
  • Depart (51)
  • Straight (52)
  • On Ferry (100)
  • Off Ferry (101)
  • Central Fork (102)
  • Roundabout (103)
  • U-Turn (104)
  • Door (150)
  • Stairs (151)
  • Elevator (152)
  • Escalator (153)
  • Pedestrian Ramp (154)
  • Left Fork (200)
  • Left Ramp (201)
  • Clockwise Roundabout (202)
  • Left-handed U-turn (203)
  • Bear left (204)
  • Left Turn (205)
  • Sharp Left (206)
  • Left Turn and immediate Left Turn (207)
  • Left Turn and immediate Right Turn (208)
  • Right Fork (300)
  • Right Ramp (301)
  • Counter-Clockwise Roundabout (302)
  • Right-handed U-turn (303)
  • Bear right (304)
  • Right Turn (305)
  • Sharp Right (306)
  • Right Turn and immediate Left Turn (307)
  • Right Turn and immediate Right Turn (308)
  • Up Elevator (400)
  • Up Escalator (401)
  • Up Stairs (402)
  • Down Elevator (500)
  • Down Escalator (501)
  • Down stairs (502)
  • General Event (1000)
  • Landmark (1001)
  • Time Zone Change (1002)
  • Traffic Event (1003)
  • Scaled Cost Barrier Event (1004)
  • Boundary Crossing (1005)
  • Restriction Violation (1006)
  • Lane (1007)

FacilityID

The object ID of the facility with which this direction point is associated, if any. If the point does not represent a visit to a facility, the value is null.

IncidentID

The object ID of the incident with which this direction point is associated, if any. If the point does not represent a visit to an incident, the value is null.

DisplayText

The directions text to display in the consuming application.

ArrivalTime

The time the direction event occurs. in coordinated universal time (UTC).

ArrivalUTCOffset

The difference in minutes between the local time at the maneuver location and UTC time shown in the ArrivalTime field.

Name

The name of the direction point.

ExitName

The highway exit name that appears in the directions instruction.

AlternateName

The alternate source name that appears in the directions instruction.

IntersectingName

The name of the intersecting or cross street that appears in the directions instruction.

BranchName

The signpost branch name that appears in the directions instruction.

TowardName

The signpost toward destination name that appears in the directions instruction.

Level

The building level at which this direction event occurs. This value corresponds to the Level property defined in the network dataset used for the analysis.

ShortVoiceInstruction

The short text to use as voice guidance text in the consuming application.

VoiceInstruction

The additional text, including expanded abbreviations and plurals, to use as voice guidance text in the consuming application.

Azimuth

The bearing in degrees of the vehicle departing this point. Zero indicates north.

directionLines

Specifies the output route lines calculated in the analysis sliced to represent each route segment between DirectionPoints events or maneuver locations.

Field NameDescription

DirectionPointID

The ObjectID value of the feature in the DirectionPoints table with which this line is associated.

RouteID

The ObjectID value of the output Routes feature with which this direction line is associated.

DirectionLineType

The type of direction situation described by this line, designated by one of the following values:

  • Unknown (0)
  • Segment (1)
  • Maneuver Segment (2)
  • Restriction Violation (3)
  • Scaled Cost Barrier (4)
  • Heavy Traffic (5)
  • Slow Traffic (6)
  • Moderate Traffic (7)

Meters

The length of the line segment measured in meters.

Minutes

The travel time along the line segment in minutes.

FromLevel

The building level at which this direction event begins. This value corresponds to the Level property defined in the network dataset used for the analysis.

ToLevel

The building level at which this direction event ends. This value corresponds to the Level property defined in the network dataset used for the analysis.

Example usage

You can make a request to the synchronous Closest Facility service using the following form:

Use dark colors for code blocksCopy
1
https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility/solveClosestFacility?<parameters>

The Closest Facility service supports synchronous and asynchronous modes.

The request URL and the parameter names supported by the service when using the asynchronous mode are different and described in Closest Facility service with asynchronous execution.

Find closest fire stations

This example shows how to find the two fire stations that can provide the quickest response to a fire at a given incident location within three minutes. You will also generate routes and driving directions for the firefighters.

Specify the four fire stations in the area as the facilities parameter values. Use the JSON structure to specify the facilities parameter, as you want to specify the name of the fire station that can be used by the service when generating driving directions for the routes from the fire stations.

Specify the longitude and latitude value for the fire location as the incidents parameter value.

Since you need to find the two closest fire stations, specify 2 as the value for the defaultTargetFacilityCount parameter. To model the fire engines traveling from the stations to the fire (incident), specify esriNATravelDirectionFromFacility as the value for the travelDirection parameter. You need to search for fire stations that are within three minutes of the fire, so specify 3 as the value for the defaultCutoff parameter. Any fire stations outside the cutoff time are ignored by the service.

Because you need to generate driving directions and report the distance information in the directions in miles, specify the value for the returnDirections parameter as true and the directionsLengthUnits parameter as esriNAUMiles . To get the route geometries, specify the value for the returnCFRoutes parameter as true . Specify 102100 as the value for the outSR parameter so that the output routes are returned in the Web Mercator spatial reference and can be displayed on top of an ArcGIS Online and ArcGIS Enterprise basemap.

Request URL

Use dark colors for code blocksCopy
1
https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility/solveClosestFacility?incidents=-122.4496,37.7467&facilities={"spatialReference":{"wkid":4326},"features":[{"attributes":{"Name":"Station 11"},"geometry":{"x":-122.4267,"y":37.7486}},{"attributes":{"Name":"Station 20"},"geometry":{"x":-122.4561,"y":37.7513}},{"attributes":{"Name":"Station 24"},"geometry":{"x":-122.4409,"y":37.7533}},{"attributes":{"Name":"Station 39"},"geometry":{"x":-122.4578,"y":37.7407}}]}&defaultTargetFacilityCount=2&travelDirection=esriNATravelDirectionFromFacility&defaultCutoff=3&returnCFRoutes=true&returnDirections=true&directionsLengthUnits=esriNAUMiles&outSR=102100&token=<yourToken
Use dark colors for code blocksCopy
1
2
https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility/solveClosestFacility?incidents=-122.4496,37.7467&facilities=%7B%22spatialReference%22:%7B%22wkid%22:4326%7D,%22features%22:%5B%7B%22attributes%22:%7B%22Name%22:%22Station%2011%22%7D,%22geometry%22:%7B%22x%22:-122.4267,%22y%22:37.7486%7D%7D,%7B%22attributes%22:%7B%22Name%22:%22Station%2020%22%7D,%22geometry%22:%7B%22x%22:-122.4561,%22y%22:37.7513%7D%7D,%7B%22attributes%22:%7B%22Name%22:%22Station%2024%22%7D,%22geometry%22:%7B%22x%22:-122.4409,%22y%22:37.7533%7D%7D,%7B%22attributes%22:%7B%22Name%22:%22Station%2039%22%7D,%22geometry%22:%7B%22x%22:-122.4578,%22y%22:37.7407%7D%7D%5D%7D&defaultTargetFacilityCount=2&travelDirection=esriNATravelDirectionFromFacility&defaultCutoff=3&returnCFRoutes=true&returnDirections=true&directionsLength
Units=esriNAUMiles&outSR=102100&token=<yourToken>

JSON Response example

The response contains two route features representing the best route to travel from the two closest fire stations to the incident. The response includes the routes and directions properties because the returnCFRoutes and returnDirections parameters are set to true in the request.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{
  "messages": [],
  "routes": {
    "fieldAliases": {
      "ObjectID": "ObjectID",
      "FacilityID": "FacilityID",
      "FacilityRank": "FacilityRank",
      "Name": "Name",
      "IncidentCurbApproach": "IncidentCurbApproach",
      "FacilityCurbApproach": "FacilityCurbApproach",
      "IncidentID": "IncidentID",
      "Total_TravelTime": "Total_TravelTime",
      "Total_Kilometers": "Total_Kilometers",
      "Total_Miles": "Total_Miles",
      "Shape_Length": "Shape_Length"
    },
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 102100,
      "latestWkid": 3857
    },
    "features": [
      {
        "attributes": {
          "ObjectID": 1,
          "FacilityID": 4,
          "FacilityRank": 1,
          "Name": "Station 39 - Location 1",
          "IncidentCurbApproach": 2,
          "FacilityCurbApproach": 1,
          "IncidentID": 1,
          "Total_TravelTime": 1.7600910249204684,
          "Total_Kilometers": 1.0394628115064781,
          "Total_Miles": 0.6458922464721514,
          "Shape_Length": 1309.3896042400702
        },
        "geometry": {
          "paths": [
            [
              [-13631945.0834,4542876.163199998],
              [-13631904.317499999,4542899.317500003]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "FacilityID": 2,
          "FacilityRank": 2,
          "Name": "Station 20 - Location 1",
          "IncidentCurbApproach": 1,
          "FacilityCurbApproach": 1,
          "IncidentID": 1,
          "Total_TravelTime": 1.898575185300166,
          "Total_Kilometers": 0.9460863750832559,
          "Total_Miles": 0.5878708188449802,
          "Shape_Length": 1229.0645653105717
        },
        "geometry": {
          "paths": [
            [
              [-13631749.8412,4544361.9076000005],
              [-13631561.4534,4544343.7250000015]
            ]
          ]
        }
      }
    ]
  },
  "directions": [
    {
      "routeId": 1,
      "routeName": "Station 39 - Location 1",
      "summary": {
        "totalLength": 0.6458978652647239,
        "totalTime": 1.7600910260807723,
        "totalDriveTime": 1.7600910249204682,
        "envelope": {
          "xmin": -13631945.083355796,
          "ymin": 4542859.901880716,
          "xmax": -13631013.761512483,
          "ymax": 4543705.678939983,
          "spatialReference": {
            "wkid": 102100,
            "latestWkid": 3857
          }
        }
      },
      "features": [
        {
          "attributes": {
            "length": 0,
            "time": 0,
            "text": "Start at Station 39",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTDepart"
          },
          "compressedGeometry": "+1-d00e8+4akcs+0+0"
        },
        {
          "attributes": {
            "length": 0.5233336473178214,
            "time": 1.4396464250141916,
            "text": "Go northeast on PORTOLA DR toward REX AVE",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTStraight"
          },
          "compressedGeometry": "+1-d00e8+4akcs+19+n+40+2p+16+12+l+12+22+45+1j+21+1t+22+29+20+51+3n+1m+u+2r+16"
        },
        {
          "attributes": {
            "length": 0.1137367543451464,
            "time": 0.29078273135879606,
            "text": "Turn left on TWIN PEAKS BLVD",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTTurnLeft"
          },
          "compressedGeometry": "+1-cvvln+4al2j-7+19+3+c+9+9+1o+8+i+9+23+1b"
        },
        {
          "attributes": {
            "length": 0.008827463601756125,
            "time": 0.02966186854748069,
            "text": "Make sharp left on PANORAMA DR",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTSharpLeft"
          },
          "compressedGeometry": "+1-cvvh5+4al6d-c+d"
        },
        {
          "attributes": {
            "length": 0,
            "time": 0,
            "text": "Finish at Location 1",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTStop"
          },
          "compressedGeometry": "+1-cvvhh+4al6q+0+0"
        }
      ]
    },
    {
      "routeId": 2,
      "routeName": "Station 20 - Location 1",
      "summary": {
        "totalLength": 0.5878759328933506,
        "totalTime": 1.8985751853324473,
        "totalDriveTime": 1.898575185300166,
        "envelope": {
          "xmin": -13631750.69648736,
          "ymin": 4543704.557076369,
          "xmax": -13631026.43439348,
          "ymax": 4544361.9075978,
          "spatialReference": {
            "wkid": 102100,
            "latestWkid": 3857
          }
        }
      },
      "features": [
        {
          "attributes": {
            "length": 0,
            "time": 0,
            "text": "Start at Station 20",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTDepart"
          },
          "compressedGeometry": "+1-d0085+4alra+0+0"
        },
        {
          "attributes": {
            "length": 0.21782291983305227,
            "time": 0.6974671774325343,
            "text": "Go east on OLYMPIA WAY toward DELLBROOK AVE",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTStraight"
          },
          "compressedGeometry": "+1-d0085+4alra+37-4+2m-e+3g-a+4a+6"
        },
        {
          "attributes": {
            "length": 0.3700530130602983,
            "time": 1.2011080078676315,
            "text": "Turn right on PANORAMA DR",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTTurnRight"
          },
          "compressedGeometry": "+1-cvvqe+4alqk+6-c6+a-t+4e-5s+h-7+2k+0+q-k"
        },
        {
          "attributes": {
            "length": 0,
            "time": 0,
            "text": "Finish at Location 1",
            "ETA": -2209161600000,
            "maneuverType": "esriDMTStop"
          },
          "compressedGeometry": "+1-cvvhh+4al6q+0+0"
        }
      ]
    }
  ]
}

JSON Response syntax

The JSON response from the closest facility service is based on the following syntax. The actual properties returned in the response depend on the request parameters. For example, the routes property is returned only if the returnCFRoutes parameter is set to true . If a request fails, the JSON response only contains the error property. The examples in the subsequent section illustrate the response returned with specific request parameters.

JSON Response syntax for a successful request

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
{
  "routes": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polyline1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polyline2>}
      }
    ]
  },
  "facilities": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "incidents": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "barriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "polylineBarriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polyline1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polyline2>}
      }
    ]
  },
  "polygonBarriers": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polygon1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polygon2>}
      }
    ]
  },
  "directions": [
    {
      "routeId": <routeId1>,
      "routeName": "<routeName>",
      "summary": {
        "totalLength": <totalLength>,
        "totalTime": <totalTime>,
        "totalDriveTime": <totalDriveTime>,
        "envelope": {<envelope>}
      },
      "features": [
        {
          "attributes": {
            "length": <length1>,
            "time": <time1>,
            "text": "<text1>",
            "ETA": <ETA>,
            "maneuverType": "<maneuverType1>"
          },
          "compressedGeometry": "<compressedGeometry1>"
        },
        {
          "attributes": {
            "length": <length2>,
            "time": <time2>,
            "text": "<text2>",
            "maneuverType": "<maneuverType2>"
          },
          "compressedGeometry": "<compressedGeometry2>"
        }
      ]
    },
    {
      "routeId": <routeId2>,
      "routeName": "<routeName>",
      "summary": {
        "totalLength": <totalLength>,
        "totalTime": <totalTime>,
        "totalDriveTime": <totalDriveTime>,
        "envelope": {<envelope>}
      },
      "features": [
        {
          "attributes": {
            "length": <length1>,
            "time": <time1>,
            "text": "<text1>",
            "ETA": <ETA>,
            "maneuverType": "<maneuverType1>"
          },
          "compressedGeometry": "<compressedGeometry1>"
        },
        {
          "attributes": {
            "length": <length2>,
            "time": <time2>,
            "text": "<text2>",
            "maneuverType": "<maneuverType2>"
          },
          "compressedGeometry": "<compressedGeometry2>"
        }
      ]
    }
  ],
  "traversedEdges": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<polyline1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<polyline2>}
      }
    ]
  },
  "traversedJunctions": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {<point1>}
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {<point2>}
      }
    ]
  },
  "traversedTurns": {
    "spatialReference": {<spatialReference>},
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        }
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        }
      }
    ]
  },
  "messages": [
    {
      "type": <type1>,
      "description": "<description1>"
    },
    {
      "type": <type2>,
      "description": "<description2>"
    }
  ]
}

JSON Response syntax for a failed request

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
{
  "error": {
    "code": <code>,
    "message": "<message>",
    "details": ["<details>"]
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.