Skip To Content ArcGIS for Developers Sign In Dashboard

Closest Facility service with synchronous execution

  • URL:https://<nalayer-url>/solveClosestFacility
  • Version Introduced:10.0

Description

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

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

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 all 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. Additionally, you can specify an impedance cutoff beyond which the service should not search for a facility. For instance, you can set up a closest facility service to search for hospitals within 15 minutes' 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.

Updates at 10.8

The preserveObjectID parameter allows you to specify whether the object ids from the input locations should be preserved when the input locations are returned as output.

Updates at 10.5

The overrides parameter allows you 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

Set 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.2.1

The timeOfDayIsUTC parameter allows you to specify whether timeOfDay is in UTC or the time zone of the facilities or incidents. By using timeOfDayIsUTC, you can have all routes start or end 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 a new returnZ parameter. If returnZ=true and the Closest Facility solver is running against 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 or m.
  • CompressedGeometryCompressedGeometry is capable of containing m- and z-values. How to decompress m- and z-values.
  • Optional url property to specify input facilities, incidents, barriers, polylineBarriers, or polygonBarriers. 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 format is that locations can be passed directly from a service endpoint as input to the NA operation, bypassing the client as intermediate storage.
  • TimeOfDay, 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)

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

Syntax:

facilities

(Required)

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

Syntax:

returnCFRoutes

(Required)

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

Values: true | false

token

(Required)

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

f

(Required)

Specify the response format. The default value is html.

Values: html | json| pjson

travelMode

(Optional)

Choose the mode of transportation for the analysis.

Value: JSON object

defaultTargetFacilityCount

(Optional)

Specify the number of closest facilities to find per incident.

travelDirection

(Optional)

Specify whether you want to search for the closest facility as measured from the incident to the facility or from the facility to the incident. The default value is esriNATravelDirectionToFacility.

Values: esriNATravelDirectionToFacility | esriNATravelDirectionFromFacility

defaultCutoff

(Optional)

Specify the travel time or travel distance value at which to stop searching for facilities for a given incident. The default value is null.

timeOfDay

(Optional)

Specify whether travel times should consider traffic conditions.

timeOfDayIsUTC

(Optional)

Specify the time zone or zones of the timeOfDay parameter. The default value is false.

Values: true | false

timeOfDayUsage

(Optional)

Specify whether the timeOfDay parameter value represents the arrival or departure time for the routes. The default value is esriNATimeOfDayUseAsStartTime.

Values: esriNATimeOfDayUseAsStartTime | esriNATimeOfDayUseAsEndTime

useHierarchy

(Optional)

Specify whether hierarchy should be used when finding the shortest paths. The default value is true.

Values: true | false

restrictUTurns

(Optional)

Restrict or permit the route from making U-turns at junctions. The default value is esriNFSBAtDeadEndsAndIntersections.

Values: esriNFSBAtDeadEndsAndIntersections | esriNFSBAllowBacktrack | esriNFSBAtDeadEndsOnly | esriNFSBNoBacktrack

impedanceAttributeName

(Optional)

Specify the impedance. The default value is TravelTime

Values: TravelTime | TruckTravelTime | WalkTime | Miles | Kilometers

accumulateAttributeNames

(Optional)

Specify whether the service should accumulate values other than the value specified for impedanceAttributeName. The default values are demonstrated in the example below:

accumulateAttributeNames=Miles,Kilometers

Values: Miles | Kilometers | WalkTime | TravelTime | TruckTravelTime

restrictionAttributeNames

(Optional)

Specify which restrictions should be honored by the service. The default values are demonstrated in the example below:

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)

Specify 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)

Specify one or more lines that prohibit travel anywhere the lines intersect the streets.

Syntax:

polygonBarriers

(Optional)

Specify 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 should generate driving directions for each route. The default value is false.

Values: true | false

directionsLanguage

(Optional)

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

directionsOutputType

(Optional)

Define 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

directionsLengthUnits

(Optional)

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

Values: esriNAUMiles | esriNAUCentimeters | esriNAUDecimalDegrees | esriNAUDecimeters | esriNAUFeet | esriNAUInches | esriNAUKilometers | esriNAUMeters | esriNAUMillimeters | esriNAUNauticalMiles | esriNAUPoints | esriNAUYards

directionsTimeAttributeName

(Optional)

Specify the time-based impedance attribute to display the duration of a maneuver. The default value is TravelTime.

Values: TravelTime | TruckTravelTime | WalkTime

outputLines

(Optional)

Specify the type of route features that are output by the service. The default value is esriNAOutputLineTrueShape.

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

ignoreInvalidLocations

(Optional)

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

Values: true | false

outSR

(Optional)

Specify the spatial reference of the geometries.

outputGeometryPrecision

(Optional)

Specify by how much you want to simplify the route geometry. The default value is 10. For more information on accepted values, see the outputGeometryPrecision section below. The units for this parameter are set using the outputGeometryPrecisionUnits.

outputGeometryPrecisionUnits

(Optional)

Specify the units for the value specified for the outputGeometryPrecision parameter. The default value is esriMeters.

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

overrides

(Optional)

Specify additional settings that can influence the behavior of the solver.

preserveObjectID

(Optional)

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

Values: true | 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 need to specify only incident point geometries in the default spatial reference WGS84, such as the longitude and latitude values.

Simple syntax for incidents

incidents=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

incidents=-117.1957,34.0564; -117.184,34.0546

You can specify incident geometries as well as attributes using a more comprehensive JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.
  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.

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

  • geometry—Specifies the incident geometry as a point containing x and y properties along with a spatialReference property. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for incidents

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

  • Name—The name of the incident. This name is used when generating driving directions. It is common to pass the actual name or street address for the incident as a value for Name attribute. If a value is not specified, an autogenerated name such as Location 1 or Location 2 is used for each incident.
  • CurbApproach—Specifies the direction a vehicle may arrive at and depart from the incident. 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 come across when using 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 your 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 in which 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 property was designed to work with both kinds 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 side of the road. What may change with national driving standards is your decision to approach from the right or left side. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, you would choose Right side of vehicle in the United States but 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_TravelTime—Specifies the amount of time for cars, in minutes, that will be added to the total travel time of the route between the incident and the closest facility. The attribute value can be used to model the time spent at the incident. For example, if you are finding the three closest fire stations from a fire incident, the attribute can store the amount of time spent at the fire incident. This could be the time it takes for firefighters to hook up their equipment and begin fighting the fire.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the incident requires no service time. The default value is 0.

  • Attr_TruckTravelTime—Specifies the amount of time for trucks, in minutes, that will be added to the total travel time of the route between the incident and the closest facility. The attribute value can be used to model the time spent at the incident.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the incident requires no service time. The default value is 0.

  • Attr_WalkTime—Specifies the amount of time for pedestrians, in minutes, that will be added to the total travel time of the route between the incident and the closest facility. The attribute value can be used to model the time spent at the incident.

    The value for this attribute is included in the total travel time for the route and is also displayed in walking directions as service time. A zero or null value indicates that the incident requires no service time. The default value is 0.

  • Attr_Miles—Specifies the distance in miles that will be added to the total distance of the route between the incident and the closest facility. Generally, the locations of the incidents are not exactly on the streets but are set back somewhat from the road. This attribute value can be used to model the distance between the actual incident location and its location on the street if it is important to include that distance in the total travel distance. The default value is 0.
  • Attr_Kilometers—Specifies the distance in kilometers that will added to the total distance of the route between the incident and the closest facility. Generally, the locations of the incidents are not exactly on the streets but are set back somewhat from the road. This attribute value can be used to model the distance between the actual incident location and its location on the street if it is important to include that distance in the total travel distance. The default value is 0.
  • Cutoff_TravelTime—Specify the travel time for cars, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_TravelTime is not set for an incident, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_TravelTime attribute allows the ability to overwrite the defaultCutoff value on a per incident basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_TruckTravelTime—Specify the travel time for trucks, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_TruckTravelTime is not set for an incident, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_TruckTravelTime attribute allows the ability to overwrite the defaultCutoff value on a per incident basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_WalkTime—Specify the travel time for pedestrians, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_WalkTime is not set for an incident, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_WalkTime attribute allows the ability to overwrite the defaultCutoff value on a per incident basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_Miles—Specify the travel distance in miles at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_Miles is not set for an incident, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_Miles attribute allows the ability to overwrite the defaultCutoff value on a per incident basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_Kilometers—Specify the travel distance in kilometers at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_Kilometers is not set for an incident, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_Kilometers attribute allows the ability to overwrite the defaultCutoff value on a per incident basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • 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 as the defaultTargetFacilityCount parameter. The value for the TargetFacilityCount attribute allows the ability to overwrite the defaultTargetFacilityCount value 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.

  • Bearing: Specify the direction the vehicle or person is moving in. Bearing is measured clockwise from true north and must be in degrees. Typically, values are between 0 and 360; however, negative values are interpreted by subtracting them from 360 degrees.

  • BearingTol: Short for bearing tolerance, this field specifies the maximum acceptable difference between the heading of a vehicle and a tangent line from the point on a street where Network Analyst attempts to locate the vehicle. The bearing tolerance is used to determine whether the direction in which a vehicle is moving generally aligns with the underlying road. If they align within the given tolerance, the vehicle is located on that edge; if not, the next nearest eligible edge is evaluated.

Syntax examples for incidents

Syntax for specifying incidents using JSON structure for features

{
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>,
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>,
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

Syntax for specifying incidents using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for incidents

Example one: Specifying incident geometries and attributes using JSON structure

The example also shows how to specify the Name attribute for each incident and specify a service time for each incident using the Attr_TraveTime attribute. The geometries for incidents are in the default spatial reference, WGS84, and therefore the spatialReference property is not required within the geometry property.

{
  "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 two: Specifying incident geometries in the Web Mercator spatial reference using JSON structure

The example also shows how to specify the Name attribute for each incident and specify the distance in miles between the actual incident location and its location on the street using the Attr_Miles attribute. The incident geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Therefore, the spatialReference property is required within the geometry property.

{
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001,
        "spatialReference": {
          "wkid": 102100
        }
      },
      "attributes": {
        "Name": "123 Main St",
        "Attr_Miles": 0.29
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002,
        "spatialReference": {
          "wkid": 102100
        }
      },
      "attributes": {
        "Name": "845 Mulberry St",
        "Attr_Miles" : 0.31
      }
    }
  ]
}

Example three: Specifying 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.

{
  "url": "https://machine.domin.com/webadaptor/rest/services/Network/USA/MapServer/1/query?where=1%3D1&outFields=Name,RouteName&f=json"
}

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 need to specify only facility point geometries in the default spatial reference WGS84, such as the longitude and latitude values.

Simple syntax for facilities

facilities=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

facilities=-117.1957,34.0564; -117.184,34.0546

You can specify facility geometries as well as attributes using a more comprehensive JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.
  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.

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

  • geometry—Specifies the facility geometry as a point containing x and y properties along with a spatialReference property. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for facilities

When specifying the stops using 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. This name is used when generating driving directions. It is common to pass the actual name or street address for the facility as a value for the Name attribute. If a value is not specified, an autogenerated name, such as Location 1 or Location 2, is used for each facility.
  • CurbApproach—Specifies the direction a vehicle may 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 the CurbApproach attribute values that you may have come across when using 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 your 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 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 in which 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 property was designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider a facility 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 side of the road. What may change with national driving standards is your decision to approach from the right or left side. For example, if you want to arrive at a facility and not have a lane of traffic between the vehicle and the facility, you would choose Right side of vehicle in the United States but 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_TravelTime—Specifies the amount of time for cars, in minutes, that will be added to the total travel time of the route between the incident and the closest facility. The attribute value can be used to specify the turnout time for the facility. For example, when finding the three closest fire stations from a fire incident, this attribute can be used to store the time it takes a crew to don the appropriate protective equipment and exit the fire station.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the facility requires no service time. The default value is 0.

  • Attr_TruckTravelTime—Specifies the amount of time for trucks, in minutes, that will be added to the total travel time of the route between the incident and the closest facility.

    The value for this attribute is included in the total travel time for the route and is also displayed in driving directions as service time. A zero or null value indicates that the facility requires no service time. The default value is 0.

  • Attr_WalkTime—Specifies the amount of time for pedestrians, in minutes, that will be added to the total travel time of the route between the incident and the closest facility.

    The value for this attribute is included in the total travel time for the route and is also displayed in walking directions as service time. A zero or null value indicates that the facility requires no service time. The default value is 0.

  • Attr_Miles—Specifies the distance in miles that will be added to the total distance of the route between the incident and the closest facility. Generally, the locations of the facilities are not exactly on the streets but are set back somewhat from the road. This attribute value can be used to model the distance between the actual facility location and its location on the street if it is important to include that distance in the total travel distance. The default value is 0.
  • Attr_Kilometers—Specifies the distance in kilometers that will be added to the total distance of the route between the incident and the closest facility. Generally, the locations of the facilities are not exactly on the streets but are set back somewhat from the road. This attribute value can be used to model the distance between the actual facility location and its location on the street if it is important to include that distance in the total travel distance. The default value is 0.
  • Cutoff_TravelTime—Specify the travel time for cars, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_TravelTime is not set for a facility, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_TravelTime attribute allows the ability to overwrite the defaultCutoff value on a per facility basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_TruckTravelTime—Specify the travel time for trucks, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_TruckTravelTime is not set for a facility, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_TruckTravelTime attribute allows the ability to overwrite the defaultCutoff value on a per facility basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_WalkTime—Specify the travel time for trucks, in minutes, at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_WalkTime is not set for a facility, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_WalkTime attribute allows the ability to overwrite the defaultCutoff value on a per facility basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_Miles—Specify the travel distance in miles at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_Miles is not set for a facility, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_Miles attribute allows the ability to overwrite the defaultCutoff value on a per facility basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Cutoff_Kilometers—Specify the travel distance in kilometers at which to stop searching for facilities for a given incident. Any incident beyond the cutoff value will not be searched.

    If Cutoff_Kilometers is not set for a facility, the service will use the value specified as the defaultCutoff parameter. The value for the Cutoff_Kilometers attribute allows the ability to overwrite the defaultCutoff value on a per facility basis. The default value for this attribute is null, which indicates to not use any cutoff.

  • Bearing: Specify the direction the vehicle or person is moving in. Bearing is measured clockwise from true north and must be in degrees. Typically, values are between 0 and 360; however, negative values are interpreted by subtracting them from 360 degrees.

  • BearingTol: Short for bearing tolerance, this field specifies the maximum acceptable difference between the heading of a vehicle and a tangent line from the point on a street where Network Analyst attempts to locate the vehicle. The bearing tolerance is used to determine whether the direction in which a vehicle is moving generally aligns with the underlying road. If they align within the given tolerance, the vehicle is located on that edge; if not, the next nearest eligible edge is evaluated.

Syntax for facilities

Syntax for specifying facilities using JSON structure for features

{
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>,
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>,
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

Syntax for specifying facilities using a URL returning a JSON response

{
  "url": "<url>"
}

Examples for facilities

Example one: Specifying facility geometries and attributes using JSON structure

The example also shows how to specify the Name attribute and a service time for each facility using the Attr_TraveTime attribute. The geometries for facilities are in the default spatial reference, WGS84, and therefore the spatialReference property is not required within the geometry property.

{
  "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 two: Specifying facility geometries in the Web Mercator spatial reference using JSON structure

The 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. The facility geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Therefore, the spatialReference property is required within the geometry property.

{
  "features": [
    {
      "geometry": {
        "x": -13635398.9398,
        "y": 4544699.034400001,
        "spatialReference": {
          "wkid": 102100
        }
      },
      "attributes": {
        "Name": "Store 45",
        "Attr_Miles": 0.29
      }
    },
    {
      "geometry": {
        "x": -13632733.3441,
        "y": 4547651.028300002,
        "spatialReference": {
          "wkid": 102100
        }
      },
      "attributes": {
        "Name": "Store 67",
        "Attr_Miles" : 0.31
      }
    }
  ]
}

Example three: Specifying 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.

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

returnCFRoutes

Use this parameter to specify if the service should return routes.

  • true—Routes are generated. 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 generated.

Caution:

The default value for the returnCFRoutes parameter is false. To get the best routes between the incident and the closest facilities, this parameter should be specified as true. If you also want the service to return the point features representing the closest facilities from the incidents, you should specify the returnFacilities parameter as true.

Tip:

You may not want to return routes if your application has to display only the driving directions between the stops. It is sufficient in this case to set the returnDirections parameter to true; returning routes will not provide any additional information and will increase the overall response size.

token

Use this parameter to specify a token that provides the identity of a user that has the permissions to access the service. The accessing services page provides more information on how such an access token can be obtained.

Example (replace <yourToken> with a valid token):
token=<yourToken>

f

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

Optional parameters

travelMode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Online and ArcGIS Enterprise and can be configured by the administrator of your organization to better reflect your 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, execute the retrieveTravelModes operation.

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

https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/retrieveTravelModes?f=json&token=<yourToken>

Note:

See Implementing App Login for ArcGIS Online or Acquire ArcGIS tokens for ArcGIS Enterprise to learn how to generate a token.

Below is the response as returned by the retrieveTravelModes operation.

Note:

Because the response is quite verbose, the elements in the response are abbreviated for clarity.

{
  "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 above JSON , to pass Walking Time as the travel mode, use the following JSON as the value for the travelMode parameter:

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"}

Caution:

When the travelMode parameter is set, you are choosing a travel mode configured in your organization, and the service automatically overrides the values of other parameters with values that model the chosen travel mode. The following parameters are overridden: impedanceAttributeName, attributeParameterValues, restrictUturns, useHierarchy, restrictionAttributeNames, outputGeometryPrecision, outputGeometryPrecisionUnits, and directionsTimeAttributeName.

If you don't set the travelMode parameter, the service honors the default or user-defined values for the parameters that would otherwise be overridden, so you can create your own travel mode.

defaultTargetFacilityCount

The service can be used to find multiple closest facilities from an incident. Use this parameter to specify the number of closest facilities to find per incident. This is useful in situations, such as a fire, where multiple fire engines may be required from different fire stations. The service can find, for example, the three nearest fire stations to a fire.

The value for the defaultTargetFacilityCount parameter can be overwritten on a per incident basis by specifying a value for the TargetFacilityCount attribute when specifying the incidents parameter.

travelDirection

Use this parameter to specify whether you want to search for the closest facility as measured from the incident to the facility or from the facility to the incident. The parameter can be specified using the following values:

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

Using one of the parameter values can 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 journey 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; therefore, stores commonly use the esriNATravelDirectionToFacility parameter value.

The default value for this parameter is esriNATravelDirectionToFacility.

defaultCutoff

Use this parameter to specify the travel time or travel distance value at which to stop searching for facilities for a given incident. For instance, while finding the closest hospitals from the site of an accident, a cutoff value of 15 minutes would mean that the service would 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 units for this parameter are based on the value of the impedanceAttributeName parameter. If the impedanceAttributeName parameter is TravelTime, the defaultCutoff is specified in minutes. Otherwise, the value is specified in miles or kilometers based on whether the impedanceAttributeName is set to Miles or Kilometers, respectively. The default value for this parameter is null, which indicates to not use any cutoff.

The value for the defaultCutoff parameter can be overwritten on a per incident or facility basis by specifying a value for the Cutoff_TravelTime, Cutoff_Miles, or Cutoff_Kilometers attributes when specifying the incidents or the facilities parameter.

timeOfDay

Specify whether travel times should consider traffic conditions. To use traffic in the analysis, set impedanceAttributeName to TravelTime, and assign a value to timeOfDay.

The timeOfDay value indicates the target start time of the routes in the analysis. If timeOfDayUsage is set to esriNATimeOfDayUseAsEndTime, the value represents when the routes should arrive at their nearby locations. The time is specified as Unix time (milliseconds since midnight, January 1, 1970). The time zone for timeOfDay can be UTC or the time zone or zones in which the points in facilities or incidents are located.

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.

Note:

Traffic is supported only with the driving time impedance or travel mode. It's not supported with trucking.

The service supports two kinds of traffic: typical and live. Typical traffic references travel speeds that are made up of historical averages for each five-minute interval spanning a week. Live traffic retrieves speeds from a traffic feed that processes phone probe records, sensors, and other data sources to record actual travel speeds and predict speeds for the near future.

The Data Coverage page shows the countries for which Esri currently provides traffic data.

Typical traffic

To ensure the task uses typical traffic in locations where it is available, choose a time and day of the week, and 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., 4 January 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 several months.

Note:

The default value is null, which means the effect of changing traffic isn't included in the analysis. This parameter is ignored when impedanceAttributeName is set to distance units.

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

Examples for timeOfDay

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

"timeOfDay": 631458180000

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

"timeOfDay":  631731600000

Example three: 8:00, 22 October 2014. If the current time is between 8:00 p.m., 21 Oct. 2014, and 8:00 p.m., 22 Oct. 2014, live traffic speeds are referenced in the analysis; otherwise, typical traffic speeds are referenced.

"timeOfDay": 1413964800000

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

"timeOfDay": 1426674000000

timeOfDayIsUTC

Specify the time zone or zones of the timeOfDay parameter. There are two options: false (default) and true.

If false (use geographically local time zones), the timeOfDay value refers to the time zone in which the input facilities or incidents are located. If the travelDirection and timeOfDayUsage parameters indicate a departure or arrival time at the facilities, timeOfDay refers to the time zone of the facilities. Likewise, if the two parameters indicate a departure or arrival time at the incidents, timeOfDay refers to the time zone of incidents.

The following is an illustration of setting the value to false (using a geographically local time zone):

  1. Setting timeOfDay to 9:00 a.m., 4 January 1990 (631443600000 milliseconds) timeOfDayIsUTC to false
  2. Submitting a valid request causes the drive times for points in the eastern time zone to start at 9:00 a.m. (2:00 p.m. UTC).

If true (use UTC), the timeOfDay value refers to coordinated universal time (UTC). The following is an illustration of setting the value to true (using UTC):

  1. Setting timeOfDay to 9:00 a.m., 4 January 1990 (631443600000 milliseconds)
  2. Setting timeOfDayIsUTC to true
  3. Submitting a valid request causes the drive times for points in the eastern time zone to start at 4:00 a.m. eastern time (9:00 a.m. UTC)
Note:

This parameter is ignored when impedanceAttributeName is set to distance units.

All incidents and facilities must be in the same time zone when you are doing 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

timeOfDayUsage

Use this parameter to specify whether the timeOfDay parameter value represents the arrival or departure time for the routes. The parameter can be specified using the following values:

  • esriNATimeOfDayUseAsStartTime—When this value is specified, the service finds the best route considering the timeOfDay parameter value as the departure time from the facility or incident.
  • esriNATimeOfDayUseAsEndTime—When this value is specified, 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 default value for this parameter is esriNATimeOfDayUseAsStartTime. The parameter value is ignored if the timeOfDay parameter value is none.

useHierarchy

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

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

  • true (default)—Use hierarchy when measuring between points. When hierarchy is used, the tool 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 tool can determine the best route from a relatively smaller subset of streets.

  • false—Do not use hierarchy when measuring between stops. If hierarchy is not used, the tool 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.

Caution:

The service automatically reverts to using hierarchy if the straight-line distance between the stops is greater than 50 miles (80.46 kilometers), even if you have specified to find the route without using hierarchy.

restrictUTurns

Use this parameter to restrict or permit the route from making U-turns at junctions.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

In order to understand the available parameter values, consider for a moment that 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. The parameter can have the following values:

Parameter valuesDescription

esriNFSBAllowBacktrack (default)

U-turns are permitted everywhere. Allowing U-turns implies that the vehicle can turn around at a junction and double back on the same street.

U-turns are allowed
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 allowed 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 allowed only at dead-ends
U-turns are permitted only at dead ends.

esriNFSBNoBacktrack

U-turns are prohibited at all junctions, intersections, and dead-ends. Note that even when this parameter value is chosen, a route can still make U-turns at stops. If you wish to prohibit U-turns at a stop, you can set its CurbApproach property to the appropriate value (3).

impedanceAttributeName

Specify the impedance.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

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 historical 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 impedance parameter can be specified using the following values:

  • TravelTime (default)—Models travel times for a car. These travel times can be dynamic, fluctuating according to traffic flows, in areas where traffic data is available.
  • TruckTravelTime—Models travel times for a truck. These travel times are static for each road and don't fluctuate with traffic.
  • WalkTime—Models travel times for a pedestrian. The default walking speed is 5 kilometers per hour (3.1 miles per hour), but you can change that speed through the attributeParameterValues parameter by setting Walking Speed (km/h) to a different value.
  • Miles—Specifies that the travel distance between the stops should be minimized. The total distance between the stops is calculated in miles.
  • Kilometers—Specifies that the travel distance between the stops should be minimized. The total distance between the stops is calculated in kilometers.

accumulateAttributeNames

Use this parameter to specify whether the service should accumulate values other than the value specified for impedanceAttributeName. For example, if your 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.

The parameter value should be specified 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 should also be calculated in miles and kilometers. This is also the default value for this parameter.

Note:

The values specified for the accumulateAttributeNames parameter are purely for reference. The service always uses impedanceAttributeName to find the best routes.

restrictionAttributeNames

Use this parameter to specify which restrictions should 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 an Avoid Toll Roads restriction will result in a route that will include toll roads only when it is absolutely required to travel on toll roads in order to visit a stop. Height Restriction makes it possible to route around any clearances that are lower than the height of your vehicle. If you are carrying corrosive materials on your vehicle, using the Any Hazmat Prohibited restriction prevents hauling the materials along roads where it is marked as illegal to do so.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value is specified as a comma-separated list of restriction names. A value of none indicates that no restrictions should be used when finding shortest paths. The default value for this parameter is demonstrated in the example below:

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
Note:

Some restrictions are supported only in certain countries. If you specify restriction names that are not available in the country where your input points are located, the service ignores the invalid restrictions and returns warning messages indicating the names for the restrictions that were not considered when performing the analysis.

Note:

Sometimes you need to specify an additional value, the restriction attribute parameter, on a restriction to get the intended results. This value needs to be associated with the restriction name and a restriction parameter using attributeParameterValues.

The service supports the restriction names listed in the following table:

Restriction NameDescription

Any Hazmat Prohibited

The result will exclude roads where transporting any kind of hazardous material is prohibited.

Avoid Carpool Roads

The result will avoid roads designated exclusively for carpool (high-occupancy) vehicles.

Avoid Express Lanes

The result will avoid roads designated as express lanes.

Avoid Ferries

The result will avoid ferries.

Avoid Gates

The result will avoid roads where there are gates, such as keyed-access or guard-controlled entryways.

Avoid Limited Access Roads

The result will avoid roads designated as limited-access highways.

Avoid Private Roads

The result will avoid roads that are not publicly owned and maintained.

Avoid Roads Unsuitable for Pedestrians

The result will avoid roads that are unsuitable for pedestrians.

Avoid Stairways

The result will avoid all stairways on a pedestrian suitable route.

Avoid Toll Roads

The result will avoid toll roads.

Avoid Toll Roads for Trucks

The result will avoid all toll roads for trucks

Avoid Truck Restricted Roads

The result will avoid roads where trucks are not allowed except when making deliveries.

Avoid Unpaved Roads

The result will avoid roads that are not paved (for example, dirt, gravel, etc.).

Axle Count Restriction

The result 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 result will exclude roads where buses are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving a Taxi

The result will exclude roads where taxis are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving a Truck

The result will exclude roads where trucks are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving an Automobile

The result will exclude roads where automobiles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Driving an Emergency Vehicle

The result will exclude roads where emergency vehicles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Height Restriction

The result will exclude 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 result will exclude roads where the vehicle kingpin-to-rear-axle length exceeds the maximum allowed for the road. The vehicle's 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 result will exclude 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 result prefers paths designated for pedestrians.

Riding a Motorcycle

The result will exclude roads where motorcycles are prohibited. Using this restriction also ensures the route will honor one-way streets.

Roads Under Construction Prohibited

The result will exclude roads that are under construction.

Semi or Tractor with One or More Trailers Prohibited

The result will exclude roads where semis or tractors with one or more trailers are prohibited.

Single Axle Vehicles Prohibited

The result will exclude roads where vehicles with single axles are prohibited.

Tandem Axle Vehicles Prohibited

The result will exclude roads where vehicles with tandem axles are prohibited.

Through Traffic Prohibited

The result will exclude roads where through traffic (non-local) is prohibited.

Truck with Trailers Restriction

The result will exclude 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 result will prefer roads designated for transporting any kind of hazardous materials.

Use Preferred Truck Routes

The result will prefer roads designated as truck routes, such as the 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 or roads in an area that are generally more suitable for trucks.

Walking

The result will exclude roads where pedestrians are prohibited.

Weight Restriction

The result will exclude 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 result will exclude roads where the vehicle's weight per axle exceeds the maximum allowed for the road. The vehicle's weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

Width Restriction

The result will roads where the vehicle width exceeds the maximum allowed for the road. The vehicle width can be specified using the Vehicle Width(meters) restriction parameter.

Legacy:

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 should be used when finding the best route, but only when travelMode is set to null. The default value for this parameter is demonstrated in the example below:

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

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.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The 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 listed within the parentheses:

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

Note:

The restrictionAttributeNames parameter is associated with attributeParameterValues. The restriction attribute's parameter value is specified as part of attributeParameterValues. Each restriction has at least one parameter named Restriction Usage, which specifies whether travel on roads that have the restriction is prohibitied, should be avoided, or should be preferred. For the latter two options, it also specifies the degree to which the roads are avoided or preferred.

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

Tip:

If you wish to use the default value for a restriction parameter, the restriction name, restriction parameter name, and restriction parameter value do not have to be specified as part of the attributeParameterValues.

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

Syntax for specifying attributeParameterValues
[
    {
        "attributeName": "<attribute1>",
        "parameterName": "<parameter1>",
        "value": "<value1>"
    },
    {
        "attributeName": "<attribute2>",
        "parameterName": "<parameter2>",
        "value": "<value2>"
    }
]

Syntax for specifying attributeParameterValues
[
    {
        "attributeName": "<attribute1>",
        "parameterName": "<parameter1>",
        "value": "<value1>"
    },
    {
        "attributeName": "<attribute2>",
        "parameterName": "<parameter2>",
        "value": "<value2>"
    }
]

Example for attributeParameterValues

Example: Specifying the vehicle height and weight and a high preference to use designated truck routes

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 any roads where the clearance under overpasses or through tunnels is less than the vehicle height. The route will also not include any 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.

Note that the Restriction Usage parameter for the Height Restriction and the Weight Restriction are not specified as we want to use the default value of Prohibit for these restriction parameters.

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"
    }
]

Example: Specifying the vehicle height and weight and a high preference to use designated truck routes

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 any roads where the clearance under overpasses or through tunnels is less than the vehicle height. The route will also not include any 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.

Note that the Restriction Usage parameter for the Height Restriction and the Weight Restriction are not specified as we want to use the default value of Prohibit for these restriction parameters.

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 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 at a railroad crossing.

The barriers parameter can be specified using a simple comma- and semicolon-based syntax if you need to specify only point barrier geometries as longitude and latitude values in the default spatial reference (WGS84).

Simple syntax for barriers

barriers=x1,y1; x2, y2; ...; xn, yn

Example using simple syntax

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 represents a set of features. The JSON structure can include the following properties:

  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.

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

  • geometry—Specifies the barrier geometry as a point containing x and y properties along with a spatialReference property. The spatialReference property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

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.
  • BarrierType—Specifies whether the point barrier prohibits travel or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers:
    • 0—Prohibits traversing through the barrier. The barrier is referred to as a restriction point barrier since it acts as a restriction. This is the default value.
      Two maps demonstrate how a restriction point barrier affects a route analysis.
      The map on the left shows the shortest path between two stops without any restriction point barriers. The map on the right has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.
    • 2—Traveling through the barrier increases the travel time or distance by the amount specified as the value for the Attr_TravelTime, Attr_Miles, or Attr_Kilometers attributes. 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 map on the left shows the shortest path between two stops without any added cost point barrier. For the map on the right, the travel time from stop one to stop two would be 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.
      Note:

      There is no point barrier type with a value of 1 for the BarrierType attribute.

  • FullEdge—This attribute is applicable only for restriction point barriers. The value for this attribute is specified as one of the following integers:
    • 0—Permits travel on the edge up to the barrier, but not through it. This is the default value.
    • 1—Restricts travel anywhere on the underlying street.
  • Attr_TravelTime—Indicates how much travel time in minutes 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.
  • Attr_Miles—Indicates how much distance in miles is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero.
  • Attr_Kilometers—Indicates how much distance in kilometers is added when the barrier is traversed. This attribute is applicable only for added-cost 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

{
  "features": [
    {
      "geometry": {
        "x": <x>,
        "y": <y>
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "x": <x>,
        "y": <y>,
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

Syntax for specifying barriers using a URL to a JSON response

{
  "url": "<url>"
}

Examples for barriers

Example one: Specifying 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. The barrier geometry is in the default spatial reference, WGS84, and therefore the spatialReference property is not required within the geometry property.

{
  "features": [
    {
      "geometry": {
        "x": 37.541479,
        "y": -122.053461
      },
      "attributes": {
        "Name": "Haley St rail road crossing",
        "BarrrierType": 2,
        "Attr_TravelTime": 5
      }
    }
  ]
}

Example two: Specifying 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.

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

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 map on the left displays the shortest path between two stops. The map on the right 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 represents a set of features. The JSON structure can include the following properties:

  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.

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

  • geometry—Specifies the barrier geometry. The structure is based on an ArcGIS REST polyline object. A polyline contains an array of paths and a spatialReference. Each path is represented as an array of points, and each point in the path is represented as an array of numbers containing x- and y-coordinate values at index 0 and 1, respectively. The spatialReference property is not required if the coordinate values are in the default spatial reference, WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for polylineBarriers

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

  • Name—The name of the polyline barrier.

Syntax examples for polylineBarriers

Syntax for specifying polyline barriers using JSON structure for features

{
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>]
          ]
        ],
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "paths": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>]
          ]
        ],
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

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

{
  "url": "<url>"
}

Examples for polylineBarriers

Example one: Specifying polyline barriers using JSON structure

The 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 made up of two points. Barrier 2 is a two-part line feature. The first part is made up of three points, and the second part is made up of two points. The barrier geometries are in the Web Mercator spatial reference and not in the default, WGS84 spatial reference. Therefore, the spatialReference property is required within the geometry property.

{
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [-10804823.397,3873688.372],
            [-10804811.152,3873025.945]
          ]
        ],
        "spatialReference": {
          "wkid": 102100
        }
      },
      "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]
          ]
        ],
        "spatialReference": {
          "wkid": 102100
        }
      },
      "attributes": {
        "Name": "Barrier 2"
      }
    }
  ]
}

Example two: Specifying 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.

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

polygonBarriers

Use this parameter to specify polygons that either prohibit 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 represents a set of features. The JSON structure can include the following properties:

  • features—Specify an array of features. This property is optional. However, either the features or url property must be specified.
  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either the features or url property must be specified.

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

  • geometry—Specifies the barrier geometry. The structure is based on an ArcGIS REST polygon object. A polygon contains an array of rings and a spatialReference. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers containing x- and y-coordinate values at index 0 and 1, respectively. The spatialReference property is not required if the coordinate values are in the default spatial reference, WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. You can find the WKID for your spatial reference depending on whether the coordinates are represented in a geographic coordinate system or a projected coordinate system.
  • attributes—Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

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.
  • BarrierType—Specifies whether the barrier prohibits travel or scales the time or distance for traveling through it. The value for this attribute is specified as one of the following integers:
    • 0—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 left side depicts the shortest path between two stops. On the right, a polygon barrier blocks flooded streets, so the shortest path between the same two stops is different.
    • 1—Scales the time or distance required to travel the underlying streets by a factor specified using the Attr_TravelTime, Attr_Miles, or Attr_Kilometers attributes. 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 would mean that travel on underlying streets is expected to be four times faster than normal. A factor of 3.0 would mean 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 might be used to model storms that reduce travel speeds in specific regions.
      Two maps demonstrate how a scaled cost polygon barrier affects finding a route between two stops.
      The map on the left shows a route that goes through inclement weather without regard for the effect that poor road conditions have on travel time. On the right, a scaled polygon barrier doubles the travel time of the roads covered by the storm. Notice 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; furthermore, the modified travel time is reported as the total travel time in the response.
  • Attr_TravelTime—This is the factor by which the travel time of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify this attribute if the impedanceAttributeName request parameter has the value TravelTime. The attribute value must be greater than zero.
  • Attr_Miles—This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify a value for this attribute if the impedanceAttributeName request parameter has the value Miles. The attribute value must be greater than zero.
  • Attr_Kilometers—This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. You should specify a value for this attribute if the impedanceAttributeName request parameter has the value Kilometers. The attribute value must be greater than zero.

Syntax examples for polygonBarriers

Syntax for specifying polygon barriers using JSON structure for features

{
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>],
            [<x11>,<y11>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>],
            [<x21>,<y21>]
          ]
        ],
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value11>,
        "<field2>": <value12>
      }
    },
    {
      "geometry": {
        "rings": [
          [
            [<x11>,<y11>],
            [<x12>,<y12>],
            [<x11>,<y11>]
          ],
          [
            [<x21>,<y21>],
            [<x22>,<y22>],
            [<x21>,<y21>]
          ]
        ],
        "spatialReference": {
          "wkid": <wkid>,
          "latestWkid": <wkid>
        }
      },
      "attributes": {
        "<field1>": <value21>,
        "<field2>": <value22>
      }
    }
  ]
}

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

{
  "url": "<url>"
}

Examples for polygonBarriers

Example one: Specifying polygon barrier using JSON structure

The example shows how to add two polygons as barriers. The first polygon, named Flood zone, is a restriction polygon barrier that prohibits travel on the underlying streets. The polygon is a single-part polygon feature made up of four points. The second polygon, named 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 made up of four points.

The barrier geometries are in the default spatial reference, WGS84. Therefore, the spatialReference property is not required within the geometry property.

{
  "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 two: Specifying 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.

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

returnDirections

Specify whether the service should 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.

directionsLanguage

Specify the language that should be used when generating driving directions. This parameter applies only when the returnDirections parameter is set to true. The service supports generating directions in the following languages:

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

The value for the parameter is specified using the language code. For example, directionsLanguage=zh-CN will result in driving directions to be generated in simplified Chinese.

The tool first 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 tool returns the directions using the default language, English. For example, if the directions language is specified as es-MX (Mexican Spanish), the tool will return the directions in Spanish as it supports es language code and not es-MX.

Caution:

If a language supports localization, such as Brazilian Portuguese (pt-BR) and European Portuguese (pt-PT), you should specify the language family and the localization. If you only specify the language family, the tool will not match the language family and instead return directions in the default language, English. For example, if the directions language is specified as pt, the tool will return the directions in English since it cannot decide if the directions should be returned in pt-BR or pt-PT.

directionsOutputType

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

  • esriDOTComplete—Directions output that includes all directions properties.
  • esriDOTCompleteNoEvents—Directions output that includes all directions properties except events.
  • esriDOTInstructionsOnly—Directions output that includes text instructions, time, length and ETA. Does not include geometry.
  • esriDOTStandard (default)—Directions output that includes all the text instructions, geometry, time, length, ETA. Does not include events, new types of strings (street names, signposts info), Maneuver type, Bearings and Turn angle.
  • esriDOTSummaryOnly—Directions output that contains only summary (time and length). Detailed text instructions and geometry are not provided.
  • esriDOTFeatureSets—Directions output that includes two feature sets; direction points and direction lines. Direction points contains a set of point features representing the direction maneuvers such as arriving to or departing from a stop, turning left or right, and other events along your route. This feature set contains the route's turn-by-turn directions. Direction lines contains a set of line features for each segment of the route. This feature set can be used to visualize the turn-by-turn directions on a map.

directionsStyleName

Specify the name of the formatting style for the directions. This parameter applies only when the returnDirections parameter is set to true. The parameter can be specified using the following values:

  • NA Desktop (default)—Generates turn-by-turn directions suitable for printing.
  • NA Navigation—Generates turn-by-turn directions designed for an in-vehicle navigation device.

directionsLengthUnits

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

  • esriNAUCentimeters
  • esriNAUDecimalDegrees
  • esriNAUDecimeters
  • esriNAUFeet
  • esriNAUInches
  • esriNAUKilometers
  • esriNAUMeters
  • esriNAUMiles (default)
  • esriNAUMillimeters
  • esriNAUNauticalMiles
  • esriNAUPoints
  • esriNAUYards

directionsTimeAttributeName

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

  • TravelTime (default)—Travel times for a car
  • TruckTravelTime—Travel times for a truck
  • WalkTime—Travel times 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. This is the default value.

  • 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 that make up the route shape will include an M value along with X and Y values. 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 store travel time if the impedanceAttributeName is set to TravelTime and store the travel distance if the impedanceAttributeName is set to Kilometers or Miles.

  • 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 in cases where you are only interested in determining the total travel time or travel distance of the route. For example, if your application has already calculated the route and after some time your application needs to only calculate the expected 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.

Tip:

When the outputLines parameter is set to esriNAOutputLineTrueShape or esriNAOutputLineTrueShapeWith Measure, the generalization of the route shape can be further controlled using the appropriate values for the outputGeometryPrecision and the outputGeometryPrecisionUnits parameters.

Note:

No matter which value you choose for the outputLines parameter, the best route is always determined by minimizing the travel time or the travel distance, never using the Euclidean distance (or as the crow flies distance) between the stops. This means that only the route shapes are different, not the underlying streets that are searched when finding the route.

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 have specified the facilities parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning facilities can allow you to draw the facility locations in your application. You may also want to set the returnFacilities property to true to determine whether the facilities were successfully located on the street network or had some other errors by checking 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 have specified the incidents parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning incidents can allow you to draw the incident locations in your application. You may also want to set the returnIncidents property to true to determine whether the incidents were successfully located on the street network or had some other errors by checking 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 (default)—Point barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the barriers parameter.

If you have specified the barriers parameter using a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set, returning barriers can allow you to draw the point barrier locations in your application. You may also want to set the returnBarriers property to true to see where the barriers were located on the street network or, if they weren't located at all, understand what the problem was by checking 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 (default)—Polyline barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polylineBarriers parameter.

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

returnPolygonBarriers

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 (default)—Polyline barriers are not returned.

Setting this parameter has no effect if you don't also specify a value for the polylineBarriers parameter.

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

ignoreInvalidLocations

Specify whether invalid input locations should be ignored when finding the best solution. An input point is deemed invalid by the service if there are no streets within 12.42 miles (20 kilometers) of the stop location.

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

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. If env:outSR is not specified, the geometries are returned in the default spatial reference, WGS84. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.

Many of the basemaps provided by ArcGIS Online are in the Web Mercator spatial reference (WKID 102100). Specifying env: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 by how much you want to simplify the route geometry returned by the service.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

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 default value for this parameter is 10. The units are specified with the outputGeometryPrecisionUnits parameter.

outputGeometryPrecisionUnits

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

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when you pass in travelMode.

The parameter value should be specified as one of the following values:

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

overrides

Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

The value for this parameter must be specified in JavaScript Object Notation (JSON). The values can be either a number, a Boolean, or a string.

{
  "overrideSetting1" : "value1", 
  "overrideSetting2" : "value2"
}

The default value for this parameter is no value, which indicates to not override any solver settings.

Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting Esri Technical Support.

preserveObjectID

Use this parameter to specify if the Object IDs specified for input locations such as stops, facilities or incidents should 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, if your input stops are specified as the following JSON representation of a feature set.

{
  "features": [
    {
      "geometry": {
        "x": -122.473948,
        "y": 37.7436
      },
      "attributes": {
        "ObjectID": 40,
        "Name": "Depot"
      }
    },
    {
      "geometry": {
        "x": -122.439613,
        "y": 37.746144
      },
      "attributes": {
        "ObjectID": 20,
        "Name": "Store 1"
      }
    },
    {
      "geometry": {
        "x": -122.488254,
        "y": 37.754092
      },
      "attributes": {
        "ObjectID": 30,
        "Name": "Store 2"
      }
    },
    {
      "geometry": {
        "x": -122.44915,
        "y": 37.731837
      },
      "attributes": {
        "ObjectID": 10,
        "Name": "Store 3"
      }
    }
  ]
}

If you solve a route and specify preserveObjectID=false, the output stops will have object ids, 1, 2, 3, and 4 even though the input stops have object ids 10, 20, 30, and 40. However if preserveObjectID=true, the output stops will have same object ids as inputs 10, 20, 30, and 40.

Caution:

The order in which the output locations are returned varies based on other parameters specified for the solve operation and should not be relied upon to correlate the output locations with input locations. Preserving object ID is the best way to achieve this correlation. If the identifier for your input location can not be passed as ObjectID, for example, the identifier is non-numeric, you can pass the identifier as the Name field and then use the Name field on output locations to correlate the input and output locations.

Caution:

When preserveObjectID=true, the object ID values must be 1 or greater, must be specified for every feature, and must be unique.

Caution:

The order in which the output locations are returned varies based on other parameters specified for the solve operation and should not be relied upon to correlate the output locations with input locations. Preserving object ID is the best way to achieve this correlation. If the identifier for your input location can not be passed as ObjectID, for example, the identifier is non-numeric, you can pass the identifier as the Name field and then use the Name field on output locations to correlate the input and output locations.

Caution:

When preserveObjectID=true, the object ID values must be 1 or greater, must be specified for every feature, and must be unique.

Output parameters

Upon successful execution, 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 following output parameters:

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. The values for this field are copied from the ID field on the input facilities.

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 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 instance, Incident 3 — Facility 5.

IncidentCurbApproach

Describes 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

Describes 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. The values for this field are copied from the ID field on input incidents .

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 cumulative cost of the route between the facility and the incident. This field is generated for the impedance attribute and any accumulated attributes.

facilities

The 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

The system-managed ID field.

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 source feature class containing the source feature on which the network is located.

SourceOID

The numeric identifier of the source feature in the source feature class.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. For example, a value of 0.47 indicates that the point is positioned 47 percent from the start of the source line feature.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. The field can have one of the two possible values. A value of 1 indicates that the point is on the right side of the line feature, and a value of 2 indicates that the point is on the left side of the line feature.

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 how the facility was evaluated in the analysis. The possible values are the following:

  • 0 (OK)—The facility was successfully located on the transportation network and analyzed.
  • 1 (Not Located)—The facility was not included in the analysis since a traversable road was not found within the maximum search distance from the facility.
  • 3 (Elements not traversable)—The network element that the facility is on is not traversable. This can occur when the network 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 may exist where positive numbers are required.
  • 5 (Not Reached)—The facility couldn't be reached due to constraints; for example, a curb approach is set so that a vehicle must travel in the wrong direction on a one-way street to reach the facility.
  • 7 (Not located on closest)—The closest network location to the facility is not traversable because of a restriction or barrier, so the facility has been located on the closest traversable network feature instead.

SnapX

The x-coordinate value for the computed network location.

SnapY

The y-coordinate value for the computed network location.

SnapZ

The z-coordinate value for the computed network location.

The field has a nonzero value only when the input network dataset supports connectivity based on z-coordinate values of the network sources.

DistanceToNetworkInMeters

The distance, in meters, between the location of the point feature and its computed network location.

Attr_[Cost]

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

This property 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, where 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] is not set, 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:

FieldDescription
ObjectID

The system-managed ID field.

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 source feature class containing the source feature on which the network is located.

SourceOID

The numeric identifier of the source feature in the source feature class.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. For example, a value of 0.47 indicates that the point is positioned 47 percent from the start of the source line feature.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. The field can have one of the two possible values. A value of 1 indicates that the point is on the right side of the line feature, and a value of 2 indicates that the point is on the left side of the line feature.

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 how the incident was evaluated in the analysis. The possible values are the following:

SnapX

The x-coordinate value for the computed network location.

SnapY

The y-coordinate value for the computed network location.

SnapZ

The z-coordinate value for the computed network location.

The field has a nonzero value only when the input network dataset supports connectivity based on z-coordinate values of the network sources.

DistanceToNetworkInMeters

The distance, in meters, between the location of the point feature and its computed network location.

Attr_[Cost]

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

This property 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 could be the time it takes for the firefighters to hook up their equipment and begin fighting the fire.

Cutoff_[Cost]

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

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

If the Cutoff_[Cost] is not set for a facility, the closest incident 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 as false, the value for this field will be system generated ID. If preserveObjectID is specified as 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 source feature class containing the source feature on which the network is located.

SourceOID

The numeric identifier of the source feature in the source feature class.

PosAlong

The position along the digitized direction of the source line feature. This value is stored as a ratio. For example, a value of 0.47 indicates that the point is positioned 47 percent from the start of the source line feature.

SideOfEdge

The side of the edge in relation to the digitized direction of the line feature. The field can have one of the two possible values. A value of 1 indicates that the point is on the right side of the line feature, and a value of 2 indicates that the point is on the left side of the line feature.

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 how the facility was evaluated in the analysis. The possible values are the following:

  • 0 (OK)—The facility was successfully located on the transportation network and analyzed.
  • 1 (Not Located)—The facility was not included in the analysis since a traversable road was not found within the maximum search distance from the facility.
  • 3 (Elements not traversable)—The network element that the facility is on is not traversable. This can occur when the network 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 may exist where positive numbers are required.
  • 5 (Not Reached)—The facility couldn't be reached due to constraints; for example, a curb approach is set so that a vehicle must travel in the wrong direction on a one-way street to reach the facility.
  • 7 (Not located on closest)—The closest network location to the facility is not traversable because of a restriction or barrier, so the facility 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.

Attr_[Cost]

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

Indicates how much travel time 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 as false, the value for this field will be system generated ID. If preserveObjectID is specified as 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 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 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 as false, the value for this field will be system generated ID. If preserveObjectID is specified as 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 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 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.

Example usage

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

https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/solveClosestFacility?<parameters>

The Closest Facility service supports synchronous and asynchronous execution modes. Asynchronous and synchronous modes define how the application interacts with the service and gets the result. When using the synchronous execution mode, the application must wait for the request to finish and get the results. This execution mode is well suited for requests that complete quickly (under 10 seconds). When using the asynchronous execution mode, the client must periodically check whether the service has finished execution and, once completed, get the result. While the service is executing, the application is available to do other things. This execution mode is well suited for requests that take a long time to complete because it allows users to continue to interact with the application while the results are generated.

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

Finding 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. 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. The geometries are in the default spatial reference, WGS84. Therefore, the spatialReference property is not specified.

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

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 within the directions in miles, specify the returnDirections parameter as true and the directionsLengthUnits parameter as esriNAUMiles. To get the route geometries, specify 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

https://machine.domain.com/webadaptor/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/solveClosestFacility?incidents=-122.4496,37.7467&facilities={"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

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.

Note:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
  "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 successful request

{
  "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>"
          }
        ]
      }
    ],
    "messages": [
      {
        "type": <type1>,
        "description": <description1>
      },
      {
        "type": <type1>,
        "description": <description1>
      }
    ]
  ]
}

JSON Response syntax for failed request

{
  "error": {
    "code": <code>,
    "message": "<message>",
    "details": ["<details>"]
  }
}

Usage limits

The table below lists the limits that apply to this service.

Limit valueLimit description

12.42 miles (20 kilometers)

Maximum snap tolerance:

(If the distance between an input point and its nearest traversable street is greater than the distance specified here, the point is excluded from the analysis.)

10 minutes (600 seconds)

Maximum time a client can use the synchronous closest facility service: