Skip To Content
ArcGIS Developer
Dashboard

Job request

Description

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

Request parameters

ParameterDescription
incidents

(Required)

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

Syntax:

facilities

(Required)

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

Syntax:

token

(Required)

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

f

(Required)

Specifies the response format.

The default response value is html.

Values: html | json | pjson

travel_mode

(Optional)

Specifies the mode of transportation for the analysis.

Value: JSON object

measurement_units

(Optional)

Specifies the units to be used to report the total travel time or travel distance for the output routes.

The default value is Minutes.

Values: Minutes | Meters | Kilometers | Feet | Yards | Miles | NauticalMiles | Seconds | Hours | Days

analysis_region

(Optional)

Specifies the region in which to perform the analysis.

number_of_facilities_to_find

(Optional)

Specifies the number of closest facilities to find per incident. You can specify the value in this parameter as in the example below:

number_of_facilities_to_find=1

The default value is 1.

cutoff

(Optional)

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

The default value is null.

travel_direction

(Optional)

Specifies whether 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 Incident To Facility.

Values: Incident To Facility | Facility to Incident

use_hierarchy

(Optional)

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

The default value is true.

Values: true | false

time_of_day

(Optional)

Specify the time and date to depart from or arrive at incidents or facilities.

time_zone_for_time_of_day

(Optional)

Specifies the time zone of the time_of_day parameter.

The default value is Geographically Local.

Values: Geographically Local | UTC

time_of_day_usage

(Optional)

Specifies whether thetime_of_day parameter value represents the arrival or departure time for the routes.

The default value is Start Time.

Values: Start Time | End Time

uturn_at_junctions

(Optional)

Specifies whether to restrict or allow the analysis to make U-turns at junctions.

The default value is Allowed only at Intersections and Dead Ends.

Values: Allowed only at Intersections and Dead Ends | Allowed | Allowed only at Dead Ends | Not Allowed

point_barriers

(Optional)

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

line_barriers

(Optional)

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

Syntax:

polygon_barriers

(Optional)

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

Syntax:

restrictions

(Optional)

Specifies which restrictions should be honored by the service. To learn about the accepted values for this parameter, see the restrictions section below.

attribute_parameter_values

(Optional)

Specifies additional values required by an attribute or restriction, such as whether the restriction prohibits, avoids, or prefers travel on restricted roads. To learn about the accepted values for this parameter, see the attribute_parameter_values section below.

route_shape

(Optional)

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

The default value is True Shape.

Values: True Shape | True Shape with Measures | Straight Line | None

route_line_simplification_tolerance

(Optional)

Specifies by how much to simplify the route geometry returned by the service. You can specify the value in this parameter as in the example below.


route_line_simplification_tolerance={"distance": 10,"units": "esriMeters"}
populate_directions

(Optional)

Specifies whether the service should generate driving directions for each route.

The default value is false.

Values: true | false

directions_language

(Optional)

Specifies the language that should be used when generating driving directions. This parameter applies only when the populate_directions parameter is set to true. To learn about the accepted values for this parameter, see the directions_language.

The default value is en.

directions_distance_units

(Optional)

Specifies the units for displaying travel distance in the driving directions. This parameter applies only when the populate_directions parameter is set to true.

The default value is Miles.

Values: Miles | Kilometers | Meters | Feet | Yards | NauticalMiles

directions_style_name

(Optional)

Specifies the name of the formatting style for the directions. This parameter applies only when the populate_directions parameter is set to true.

The default value is NA Desktop.

Values: NA Desktop | NA Navigation | NA Campus

impedance

(Optional)

Specifies the impedance.

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

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

save_route_data

(Optional)

Specifies whether the service will create a .zip file that contains a file geodatabase holding the inputs and outputs of the analysis in a format that can be used to share route layers with your portal.

The default value is false.

Values: true | false

save_output_network_analysis_layer

(Optional)

Specifies whether the service will save the analysis settings as a network analysis layer file.

The default value is false.

Values: true | false

overrides

(Optional)

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


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

time_impedance

(Optional)

Specifies the time-based impedance.

The default value is TravelTime.

Values: TravelTime | Minutes | TruckTravelTime | TruckMinutes | WalkTime

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

distance_impedance

(Optional)

Specifies the distance-based impedance.

The default value is Kilometers.

Values: Miles | Kilometers

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

output_format

(Optional)

Specifies the format in which the output features are created.

The default value is Feature Set.

Values: Feature Set | JSON File | GeoJSON File

env:outSR

(Optional)

Specifies the spatial reference of the geometries.

ignore_network_location_fields

(Optional)

Specifies whether the network location fields will be considered when locating inputs such as stops or facilities on the network.

The default value is false.

Values: true | false

ignore_invalid_locations

(Optional)

Specify whether invalid input locations will be ignored.

The default value is true.

Values: true | false

locate_settings

(Optional)

Specify settings that affect how inputs are located.

Value: JSON object

accumulate_attributes

(Optional)

A list of cost attributes to be accumulated during analysis. These accumulated attributes are for reference only; the solver only uses the cost attribute used by the designated travel mode when solving the analysis.

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.

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

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

  • features—Specify an array of features.

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

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

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

Attributes for incidents

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

  • Name

    The name of the incident. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output routes and directions.

  • ID

    A unique identifier for the incident. The identifier is included in the output routes (as the IncidentID field) and can help join additional information from the output routes, such as the total travel time or total distance, to attributes from your incidents or vice versa. If the ID isn't specified, the service automatically generates a unique identifier for each incident.

  • AdditionalTime

    The amount of time spent at the incident, which is added to the total time of the route. The default value is 0.

    The units for this attribute value are specified by the measurement_units parameter. The attribute value is included in the analysis only when the measurement units are time based.

    If you are finding the closest fire stations to fire incidents to estimate response times, for example, the AdditionalTime attribute can store the amount of time it takes firefighters to hook up their equipment at the location of the incident before they can begin fighting the fire.

  • AdditionalDistance

    The extra distance traveled at the incident, which is added to the total distance of the route. The default value is 0.

    The units for this attribute value are specified by the measurement_units parameter. The attribute value is included in the analysis only when the measurement units are distance based.

    Generally, the location of an incident, such as a home, isn't exactly on the street; it is set back somewhat from the road. This attribute value can be used to model the distance between the incident location and its location on the street if it is important to include that distance in the total travel distance.

  • AdditionalCost

    The extra cost spent at the incident, which is added to the total cost of the route. The default value is 0.

    This attribute value should be used when the travel mode for the analysis uses an impedance attribute that is neither time based nor distance based The units for the attribute values are interpreted to be in unknown units.

  • TargetFacilityCount

    The number of facilities that need to be found for the given incident. This field allows you to specify a different number of facilities to find for each incident. For example, using this field you can find the three closest facilities from one incident and the two closest facilities from another incident.

  • Cutoff

    The impedance value at which to stop searching for facilities from a given incident. This attribute allows you to specify a different cutoff value for each incident. For example, using this attribute you can search for facilities within five minutes travel time from one incident and search for facilities within eight minutes travel time from another incident.

  • CurbApproach

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

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

    SettingCoded valueDescription

    Either side of vehicle

    0

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

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    Right side of vehicle

    1

    When the vehicle approaches and departs the incident, the incident must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the right side.

    Right side of vehicle
    The allowed arrival and departure combination for the Right side of vehicle curb approach is shown.

    Left side of vehicle

    2

    When the vehicle approaches and departs the incident, the incident must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the left side.

    Left side of vehicle
    The allowed arrival and departure combination for the Left side of vehicle curb approach is shown.

    No U-Turn

    3

    When the vehicle approaches the incident, the incident can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived. A U-turn is prohibited.

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

    The CurbApproach attribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, choose 1 (Right side of vehicle) in the United States and 2 (Left side of vehicle) in the United Kingdom.

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

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

    Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

    Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass, for example. Bearing also helps the tool determine on which side of the street the point is.

    Learn more about bearing and bearing tolerance

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the Bearing field value is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when Network Analyst attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

    Learn more about bearing and bearing tolerance

  • NavLatency

    This field is only used in the solve process if the Bearing and BearingTol fields also have values; however, entering a NavLatency field value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much cost is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

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

Syntax examples for incidents

Syntax for specifying incidents using a JSON structure for features


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

Syntax for specifying incidents using a URL returning a JSON response


{
  "url": "<url>"
}

Examples for incidents

Example 1: Specifying incidents in the spatial reference of the network dataset, WGS84, using a JSON structure. The example shows how to specify some attributes for the incidents.


{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "y": 51.5254,
        "x": -0.1891
      },
      "attributes": {
        "Name": "Incident 1",
        "ID": "C100045", 
        "AdditionalTime": 5,
        "CurbApproach": 0
      }
    },
    {
      "geometry": {
        "y": 51.5353,
        "x": -0.1744
      },
      "attributes": {
        "Name": "Incident 2",
        "ID": "F100086",
        "AdditionalTime": 10,
        "CurbApproach": 0
      }
    }
  ]
}

Example 2: Specifying incidents in the Web Mercator spatial reference using a JSON structure


{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -5192521.476,
        "x": -2698533.989
      },
      "attributes": {
        "Name": "123 Main St", 
        "ID": "200156",
        "AdditionalDistance": 300
      }
    },
    {
      "geometry": {
        "y": -5191915.261,
        "x": -2697821.094
      },
      "attributes": {
        "Name": "845 Cypress Ave",
        "ID": "300242",
        "AdditionalDistance": 250
      }
    }
  ]
}

Example 3: 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.domain.com/webadaptor/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&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.

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

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

  • features—Specify an array of features.

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

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

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

Attributes for facilities

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

  • Name

    The name of the facility. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output routes and directions.

  • ID

    A unique identifier for the facility. The identifier is included in the output routes and the output closest facilities as FacilityID fields. The FacilityID field can be used to join additional information from the output routes, such as the total travel time or total distance, to attributes from your facilities. If the ID isn't specified, the service automatically generates a unique identifier for each facility.

  • AdditionalTime

    The amount of time spent at the facility, which is added to the total time of the route. The default value is 0.

    The units for this attribute value are specified by the measurement_units parameter. The attribute value is included in the analysis only when the measurement units are time based.

    If you are finding the closest fire stations to fire incidents, for example, AdditionalTime can store the time it takes a crew to don the appropriate protective equipment and exit the fire station.

  • AdditionalDistance

    The extra distance traveled at the facility, which is added to the total distance of the route. The default value is 0.

    The units for this attribute value are specified by the measurement_units parameter. The attribute value is included in the analysis only when the measurement units are distance based.

    Generally, the location of a facility, such as a fire station, isn't exactly on the street; it is set back somewhat from the road. AdditionalDistance can model the distance between the facility location and its location on the street if it is important to include that distance in the total travel distance.

  • AdditionalCost

    The extra cost spent at the facility, which is added to the total cost of the route. The default value is 0.

    This attribute value should be used when the travel mode for the analysis uses an impedance attribute that is neither time based nor distance based The units for the attribute values are interpreted to be in unknown units.

  • CutOff

    The impedance value at which to stop searching for incidents from a given facility. This attribute allows you to specify a different cutoff value for each facility. For example, using this attribute you can search for incidents within five minutes of travel time from one facility and search for incidents within eight minutes of travel time from another 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 CurbApproach attribute values that you may have seen when using the ArcGIS Network Analyst extension software.

    SettingCoded valueDescription

    Either side of vehicle

    0

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

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    Right side of vehicle

    1

    When the vehicle approaches and departs the facility, the facility must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the right-hand side.

    Right side of vehicle
    The allowed arrival and departure combination for the Right side of vehicle curb approach is shown.

    Left side of vehicle

    2

    When the vehicle approaches and departs the facility, the facility must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles such as buses that must arrive with the bus stop on the left side.

    Left side of vehicle
    The allowed arrival and departure combination for the Left side of vehicle curb approach is shown.

    No U-Turn

    3

    When the vehicle approaches the facility, the facility can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived. A U-turn is prohibited.

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

    The CurbApproach attribute is designed to work with both types of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an incident on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach an incident from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at an incident and not have a lane of traffic between the vehicle and the incident, choose 1 (Right side of vehicle) in the United States and 2 (Left side of vehicle) in the United Kingdom.

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

  • Bearing

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

    Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

    Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass, for example. Bearing also helps the tool determine on which side of the street the point is.

    Learn more about bearing and bearing tolerance

  • BearingTol

    The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the Bearing field value is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when Network Analyst attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

    Learn more about bearing and bearing tolerance

  • NavLatency

    This field is only used in the solve process if the Bearing and BearingTol fields also have values; however, entering a NavLatency field value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much cost is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

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

Syntax examples for facilities

Syntax for specifying facilities using a JSON structure for features


{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "features": [
    {
      "geometry": {
        "x": <x1>,
        "y": <y1>
      },
      "attributes": {
        "<field1>": <value1_1>,
        "<field2>": <value1_2>
      }
    },
    {
      "geometry": {
        "x": <x2>,
        "y": <y2>
      },
      "attributes": {
        "<field1>": <value2_1>,
        "<field2>": <value2_2>
      }
    }
  ] 
}

Syntax for specifying facilities with custom attributes using a JSON structure for features


{
  "spatialReference": {
    "wkid": <wkid>,
    "latestWkid": <wkid>
  },
  "fields": [
    {
      "name": <name1>,
      "type": <esriFieldType>,
      "alias": <alias1>,
      "length": <length>
    },
    {
      "name": <name2>,
      "type": <esriFieldType>,
      "alias": <alias2>,
      "length": <length>
    }
  ],
  "features": [
    {
      "geometry": {
        "x": <x1>,
        "y": <y1>
      },
      "attributes": {
        "<field1>": <value1_1>,
        "<field2>": <value1_2>
      }
    },
    {
      "geometry": {
        "x": <x2>,
        "y": <y2>
      },
      "attributes": {
        "<field1>": <value2_1>,
        "<field2>": <value2_2>
      }
    }
  ] 
}

Syntax for specifying facilities using a URL returning a JSON response


{
  "url": "<url>"
}

Examples for facilities

Example 1: Specifying facilities in the spatial reference of the network dataset, WGS84, using JSON structure. The example shows how to specify some attributes for the facilities.


{ 
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "y": 51.5254,
        "x": -0.1891
      },
      "attributes": {
        "Name": "Facility 1",
        "ID": "F100045", 
        "AdditionalTime": 5,
        "CurbApproach": 0
      }
    },
    {
      "geometry": {
        "y": 51.5353,
        "x": -0.1744
      },
      "attributes": {
        "Name": "Facility 2",
        "ID": "F100086",
        "AdditionalTime": 10,
        "CurbApproach": 0
      }
    }
  ]
}

Example 2: Specifying facilities in the Web Mercator spatial reference using a JSON structure


{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -5192521.476,
        "x": -2698533.989
      },
      "attributes": {
        "Name": "123 Main St", 
        "ID": "200156",
        "AdditionalDistance": 300
      }
    },
    {
      "geometry": {
        "y": -5191915.261,
        "x": -2697821.094
      },
      "attributes": {
        "Name": "845 Cypress Ave",
        "ID": "300242",
        "AdditionalDistance": 250
      }
    }
  ]
}

Example 3: Specifying facilities with a custom field using JSON structure

In this example, the facilities include a custom field, PhoneNumber; therefore, the field schema must be defined in the fields attribute. The schema of default fields must also be defined whenever a custom field is present, so the schema of the Name field is also defined. The values for the fields are specified in the features attribute. The output closest facilities will include the custom field.


{
  "spatialReference": {
    "wkid": 4326
  },
  "fields": [
    {
      "name": "Name",
      "type": "esriFieldTypeString",
      "alias": "Name",
      "length": 128
    },
    {
      "name": "PhoneNumber",
      "type": "esriFieldTypeString",
      "alias": "PhoneNumber",
      "length": 12
    }
  ],
  "features": [
    {
      "geometry": {
        "x": -122.455962,
        "y": 37.751316
      },
      "attributes": {
        "Name": "Bank 9",
        "PhoneNumber": "999-999-9999"
      }
    },
    {
      "geometry": {
        "x": -122.440825,
        "y": 37.753199
      },
      "attributes": {
        "Name": "Bank 8",
        "PhoneNumber": "888-888-8888"
      }
    },
    {
      "geometry": {
        "x": -122.457844,
        "y": 37.740713
      },
      "attributes": {
        "Name": "Bank 7",
        "PhoneNumber": "777-777-7777"
      }
    }
  ]
}

Example 4: 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/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

token

Use this parameter to specify a token that provides the identity of a user that has the permissions to access the service. The security and authentication page provides more information about how an access token can be obtained.

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

f

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

Optional parameters

travel_mode

Choose the mode of transportation for the analysis.

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

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

You must specify the JSON object containing the settings for a travel mode supported by your organization. To get a list of supported travel modes, execute the GetTravelModes tool from the Utilities service.

The value for the travel_mode parameter should be a JSON object representing travel mode settings. When you use the GetTravelModes tool from the Utilities service, you get a string representing the travel mode JSON. You need to convert this string to a valid JSON object using your API and then pass the JSON object as the value for the travel_mode parameter.

For example, below is a string representing the Walking Time travel mode as returned by the GetTravelModes tool.

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

The above value should be converted to a valid JSON object and passed as the value for the travel_mode parameter.

travel_mode={"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"}

The default value,Custom, allows you to configure your own travel mode. When you pass in Custom, you can set values for the following parameters: impedance, time_impedance, distance_impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values. You can choose Custom and set the custom travel mode parameters listed above, for example, to model a pedestrian with a fast walking speed or a truck with a given height, weight, and cargo of certain hazardous materials. You can try out different settings to get desired analysis results. Once you have identified the analysis settings, you should work with your organization's administrator and save these settings as part of new or existing travel mode so that everyone in your organization can rerun the analysis with the same settings.

The default values of the custom travel mode parameters model traveling by car. If you specify the travel mode as Custom or do not provide a value for the travel_mode parameter, the analysis will be similar to using the default Driving Time travel mode.

Caution:

When the travel_mode parameter is not set to Custom, this means you are choosing a travel mode configured by 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: impedance, time_impedance, distance_impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values.

measurement_units

Use this parameter to specify the units that should be used to report the total travel time or travel distance for the output routes. The service finds the closest facility based on the travel time or the travel distance along the streets, depending on whether the units you specify as the value for this parameter are time- or distance-based.

  • Meters
  • Kilometers
  • Feet
  • Yards
  • Miles
  • NauticalMiles
  • Seconds
  • Minutes
  • Hours
  • Days

The default value is Minutes.

number_of_facilities_to_find

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

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

The service can find up to 100 facilities from each incident.

cutoff

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

When the travel_direction parameter is set to Facility to Incident, the cutoff can be overridden on a per-facility basis using the Cutoff field in the input facilities. When the travel_direction parameter is set to Incident to Facility, the cutoff can be overridden on a per-incident basis using the Cutoff field in the input incidents.

The units for this parameter are specified by the measurement_units parameter. The default value for this parameter is null, which indicates not to use any cutoff.

travel_direction

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

  • Facility to Incident—Direction of travel is from facilities to incidents.
  • Incident to Facility—Direction of travel is from incidents to facilities.

Using one of the parameter values can find different facilities because the travel time along some streets may vary based on traffic 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 traffic is slower in that direction. If you're setting a value for time_of_day, traffic may also cause the Facility to Incident and Incident to Facility options to return different results.

Fire departments commonly use the Facility to Incident value for the parameter since they're 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 Incident to Facility parameter value.

use_hierarchy

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

The default value for this parameter is true.

Caution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Driving, so unless you set travel_mode to a different value, this parameter value will be overridden.

  • true—Use hierarchy when travelling between facilities and incidents. When hierarchy is used, the service prefers higher-order streets (such as freeways) to lower-order streets (such as local roads) and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes to faraway locations, because drivers on long-distance trips tend to prefer traveling on freeways where stops, intersections, and turns can be avoided. Using hierarchy is computationally faster, especially for long-distance routes, since the service can determine the best route from a relatively smaller subset of streets.

  • false—Do not use hierarchy when travelling between facilities and incidents. When hierarchy is not used, the service considers all the streets and doesn't prefer higher-order streets when finding the route. This is often used when finding short-distance routes within a city.

time_of_day

Specify the time and date to depart from or arrive at incidents or facilities.

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

To use traffic in the analysis, choose a time-based unit for impedance and assign a value to time_Of_day.

The time_Of_day value represents the target start time or arrive time of the routes in the analysis. If time_of_day_usage is set to End Time, 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).

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.

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

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

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

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

Typical traffic

To ensure the task uses typical traffic in locations where it is available, choose a time and day of the week, 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., January 4, 1990; and convert to milliseconds (631458180000). Although the dates representing days of the week are from 1990, typical traffic is calculated from recent traffic trends—usually over the last two years worth of data.

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

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

Live traffic

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

Note:
You need to have a Live Traffic extension and configure your Street Map Premium network dataset to access live traffic.

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

Examples for time_of_day

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

"time_Of_day": 631458180000

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

"time_Of_day": 631731600000

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

"time_Of_day": 1426674000000

time_zone_for_time_Of_Day

Specify the time zone or zones of the time_Of_day parameter. There are two options: Geographically Local and UTC.

The default value is Geographically Local

Geographically Local

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

Illustration of setting the value to Geographically Local—Setting time_of_day to 9:00 a.m., January 4, 1990 (631443600000 milliseconds); time_zone_for_time_Of_Day to Geographically Local; and submitting a valid request causes the drive times for points in the eastern time zone to start at 9:00 a.m. eastern Time and 9:00 a.m. central time for points in the central time zone. (The start times are offset by an hour in real or UTC time.)

Time zone for time of day parameter is set to geographically local
Input: time_Of_day is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and time_zone_for_time_Of_day is set to Geographically Local

UTC

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

Illustration of setting the value to time_Of_day—Setting time_Of_day to 9:00 a.m., January 4, 1990 (631443600000 milliseconds) and the value to UTC, the start times for points in the eastern time zone is 4:00 a.m. Eastern Time and 3:00 a.m. central time for those in the central time zone.

Time zone for time of day parameter is set to UTC
Input: time_Of_day is 9:00 a.m., January 4, 1990 (631443600000 milliseconds), and time_zone_for_time_Of_day is set to UTC

time_of_day_usage

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

  • Start Time—When this value is specified, the service finds the best route considering the time_of_day parameter value as the departure time from the facility or incident.
  • End Time—When this value is specified, the service considers the time_of_day 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 you arrive at the destination at the time specified in time_of_day.

The default value for this parameter is Start Time. The parameter value is ignored if the time_of_day parameter has a null value.

uturn_at_junctions

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 travel_mode is set to any other value than Custom. The default value for travel_mode is Driving, so unless you set travel_mode to a different value, this parameter value will be overridden.

To understand the available parameter values, a junction is a point where only two streets intersect each other. If three or more streets intersect at a point, it is called as an intersection. A cul-de-sac is a dead-end. This parameter can have the following values:

Parameter ValueDescription

Allowed

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

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

Allowed only at Intersections and Dead Ends

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

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

Allowed only at Dead Ends

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

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

Not Allowed

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

The default value for this parameter is Allowed only at Intersections and Dead Ends.

point_barriers

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

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

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

  • features—Specify an array of features.

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

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

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

Attributes for point_barriers

When specifying point barriers, you can set properties for each, such as its name or barrier type, using the following attributes:

Name

The name of the barrier.

BarrierType

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

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

    Two maps demonstrate how a restriction point barrier affects a route analysis.
    The first map shows the shortest path between two stops without any restriction point barriers. The second map has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.

  • 2 (Added Cost)—Traveling through the barrier increases the travel time or distance by the amount specified in the Additional_[Cost] 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.

Additional_Time

The added travel time when the barrier is traversed. This field is applicable only for added-cost barriers and when the measurement_units parameter is time-based

This field value must be greater than or equal to zero, and its units are the same as those specified in the measurement_units parameter.

Additional_Distance

The added distance when the barrier is traversed. This field is applicable only for added-cost barriers and when the measurement_units parameter is distance-based

The field value must be greater than or equal to zero, and its units are the same as those specified in the measurement_units parameter.

AdditionalCost

The added cost when the barrier is traversed. This field is applicable only for added-cost barriers when the impedance attribute is neither time-based nor distance-based.

FullEdge

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

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

CurbApproach

Specifies 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.

Because junctions are points and don't have a side, barriers on junctions affect all vehicles regardless of the curb approach.

The CurbApproach attribute works with both types 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 half of the road. What may change with national driving standards is your decision to approach a facility from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, to arrive at a facility and not have a lane of traffic between the vehicle and the facility, choose 1 (Right side of vehicle) in the United States and 2 (Left side of vehicle) in the United Kingdom.

Bearing

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

Bearing data is usually sent automatically from a mobile device equipped with a GPS receiver. Try to include bearing data if you are loading an input location that is moving, such as a pedestrian or a vehicle.

Using this field tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass, for example. Bearing also helps the tool determine on which side of the street the point is.

Learn more about bearing and bearing tolerance

BearingTol

The bearing tolerance value creates a range of acceptable bearing values when locating moving points on an edge using the Bearing field. If the Bearing field value is within the range of acceptable values that are generated from the bearing tolerance on an edge, the point can be added as a network location there; otherwise, the closest point on the next-nearest edge is evaluated.

The units are in degrees, and the default value is 30. Values must be greater than 0 and less than 180. A value of 30 means that when Network Analyst attempts to add a network location on an edge, a range of acceptable bearing values is generated 15 degrees to either side of the edge (left and right) and in both digitized directions of the edge.

Learn more about bearing and bearing tolerance

NavLatency

This field is only used in the solve process if the Bearing and BearingTol fields also have values; however, entering a NavLatency field value is optional, even when values are present in Bearing and BearingTol. NavLatency indicates how much cost is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device.

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

Syntax examples for point_barriers

Syntax for specifying point_barriers using a JSON structure for features


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

Syntax for specifying point_barriers using a URL returning a JSON response


{
  "url": "<url>"
}

Examples for point_barriers

Example 1: 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 the point barrier is added-cost, and the Additional_Time attribute is used to specify the added delay in minutes.


{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "x": 37.541479,
        "y": -122.053461
      },
      "attributes": {
        "Name": "Haley St railroad crossing",
        "BarrierType": 2,
        "Additional_Time": 5
      }
    }
  ]
}

Example 2: Specifying restriction point barriers in the Web Mercator spatial reference using a JSON structure

This example shows how to use a restriction point barrier to model a road that's blocked by a fallen tree. The barrier's geometry is in the Web Mercator spatial reference and not in the spatial reference of the network dataset.


{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "y": -13635398.9398,
        "x": 4544699.034400001
      },
      "attributes": {
        "Name": "Fallen tree at 123 Main St", 
        "BarrierType": 0
      }
    }
  ]
}

Example 3: Specifying point barriers 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/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

line_barriers

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

Two maps demonstrate how a line barrier affects finding a route between two stops.
The first map displays the shortest path between two stops. The second map shows the shortest path when several streets are blocked by a polyline barrier.

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

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

  • features—Specify an array of features.

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

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

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

Attributes for line_barriers

When specifying the line barriers, you can set name and barrier type properties for each using the following attributes:

  • Name

    The name of the barrier.

Syntax examples for line_barriers

Syntax for specifying line barriers using a JSON structure for features


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

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


{
  "url": "<url>"
}

Examples for line_barriers

Example 1: Specifying line barriers using a JSON structure

The example shows how to add two lines as line 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 whose first part is made up of three points and whose second part is made up of two points.


{
  "spatialReference": {
    "wkid": 102100
  },
  "features": [
    {
      "geometry": {
        "paths": [
          [
            [-10804823.397,3873688.372],
            [-10804811.152,3873025.945]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 1"
      }
    },
    {
      "geometry": {
        "paths": [
          [
            [-10804823.397,3873688.372],
            [-10804807.813 3873290.911],
            [-10804811.152,3873025.945]
          ],
          [
            [-10805032.678,3863358.76],
            [-10805001.508,3862829.281]
          ]
        ]
      },
      "attributes": {
        "Name": "Barrier 2"
      }
    }
  ]
}

Example 2: Specifying line barriers using 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"
}

polygon_barriers

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

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

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

  • features—Specify an array of features.

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

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

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

Attributes for polygon_barriers

When specifying the polygon barriers, you can set properties for each, such as its name or barrier type, using the following attributes:

  • Name

    The name of the barrier.

  • BarrierType

    Specifies whether the barrier restricts travel completely or scales the cost (such as time or distance) for traveling through it. The field value 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 a restriction polygon barrier since it prohibits traveling on streets intersected by the barrier. One use of this type of barrier is to model floods covering areas of the street that make traveling on those streets impossible.

      This is the default value.

      Two maps demonstrate how a restriction polygon barrier affects finding a route between two stops.
      The first map depicts the shortest path between two stops. The second map shows a polygon barrier blocking flooded streets, so the shortest path between the same two stops is different.

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

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

  • ScaledTimeFactor

    This is the factor by which the travel time of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers and when the measurement_units parameter is time-based.

  • ScaledDistanceFactor

    This is the factor by which the distance of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers and when the measurement_units parameter is distance-based.

  • ScaledCostFactor

    This is the factor by which the cost of the streets intersected by the barrier is multiplied. The field value must be greater than zero.

    This field is applicable only for scaled-cost barriers when the impedance is neither time-based nor distance-based .

Syntax examples for polygon_barriers

Syntax for specifying polygon barriers using a JSON structure for features


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

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


{
  "url": "<url>"
}

Examples for polygon_barriers

Example 1: Specifying polygon barriers using a 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 increases 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.


{
  "spatialReference": {
    "wkid": 4326
  },
  "features": [
    {
      "geometry": {
        "rings": [
          [
            [-97.0634,32.8442],
            [-97.0554,32.84],
            [-97.0558,32.8327],
            [-97.0638,32.83],
            [-97.0634,32.8442]
          ]
        ]
      },
      "attributes": {
        "Name": "Flood zone",
        "BarrierType": 0
      }
    },
    {
      "geometry": {
        "rings": [
          [
            
            [-97.0803,32.8235],
            [-97.0776,32.8277],
            [-97.074,32.8254],
            [-97.0767,32.8227],
            [-97.0803,32.8235]
          ],
          [
            [-97.0871,32.8311],
            [-97.0831,32.8292],
            [-97.0853,32.8259],
            [-97.0892,32.8279],
            [-97.0871,32.8311]
            
          ]
        ]
      },
      "attributes": {
        "Name": "Severe weather zone",
        "BarrierType": 1,
        "ScaledTimeFactor": 3
      }
    }
  ]
}

Example 2: 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"
}

restrictions

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

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 travel_mode.

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

The service supports the following restriction names:

  • Any Hazmat Prohibited—The results will not include roads where transporting any kind of hazardous material is prohibited.

  • Avoid Carpool Roads—The results will avoid roads that are designated exclusively for car pool (high-occupancy) vehicles.

  • Avoid Express Lanes—The results will avoid roads designated as express lanes.

  • Avoid Ferries—The results will avoid ferries.

  • Avoid Gates—The results will avoid roads where there are gates, such as keyed access or guard-controlled entryways.

  • Avoid Limited Access Roads—The results will avoid roads that are limited-access highways.

  • Avoid Private Roads—The results will avoid roads that are not publicly owned and maintained.

  • Avoid Roads Unsuitable for Pedestrians—The results will avoid roads that are unsuitable for pedestrians.

  • Avoid Stairways—The results will avoid all stairways on a pedestrian-suitable route.

  • Avoid Toll Roads—The results will avoid all toll roads for automobiles.

  • Avoid Toll Roads for Trucks—The results will avoid all toll roads for trucks.

  • Avoid Truck Restricted Roads—The results will avoid roads where trucks are not allowed, except when making deliveries.

  • Avoid Unpaved Roads—The results will avoid roads that are not paved (for example, dirt, gravel, and so on).

  • Axle Count Restriction—The results will not include roads where trucks with the specified number of axles are prohibited. The number of axles can be specified using the Number of Axles restriction parameter.

  • Driving a Bus—The results will not include roads where buses are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving a Taxi—The results will not include roads where taxis are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving a Truck—The results will not include roads where trucks are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving an Automobile—The results will not include roads where automobiles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Driving an Emergency Vehicle—The results will not include roads where emergency vehicles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Height Restriction—The results will not include roads where the vehicle height exceeds the maximum allowed height for the road. The vehicle height can be specified using the Vehicle Height (meters) restriction parameter.

  • Kingpin to Rear Axle Length Restriction—The results will not include roads where the vehicle length exceeds the maximum allowed kingpin to rear axle for all trucks on the road. The length between the vehicle kingpin and the rear axle can be specified using the Vehicle Kingpin to Rear Axle Length (meters) restriction parameter.

  • Length Restriction—The results will not include roads where the vehicle length exceeds the maximum allowed length for the road. The vehicle length can be specified using the Vehicle Length (meters) restriction parameter.

  • Preferred for Pedestrians—The results will use preferred routes suitable for pedestrian navigation.

  • Riding a Motorcycle—The results will not include roads where motorcycles are prohibited. Using this restriction will also ensure that the results will honor one-way streets.

  • Roads Under Construction Prohibited—The results will not include roads that are under construction.

  • Semi or Tractor with One or More Trailers Prohibited—The results will not include roads where semis or tractors with one or more trailers are prohibited.

  • Single Axle Vehicles Prohibited—The results will not include roads where vehicles with single axles are prohibited.

  • Tandem Axle Vehicles Prohibited—The results will not include roads where vehicles with tandem axles are prohibited.

  • Through Traffic Prohibited—The results will not include roads where through traffic (nonlocal traffic) is prohibited.

  • Truck with Trailers Restriction—The results will not include roads where trucks with the specified number of trailers on the truck are prohibited. The number of trailers on the truck can be specified using the Number of Trailers on Truck restriction parameter.

  • Use Preferred Hazmat Routes—The results will prefer roads that are designated for transporting hazardous materials.

  • Use Preferred Truck Routes—The results will prefer roads that are designated as truck routes, such as roads that are part of the national network as specified by the National Surface Transportation Assistance Act in the United States, or roads that are designated as truck routes by the state or province, or roads that are preferred by truckers when driving in an area.

  • Walking—The results will not include roads where pedestrians are prohibited.

  • Weight Restriction—The results will not include roads where the vehicle weight exceeds the maximum allowed weight for the road. The vehicle weight can be specified using the Vehicle Weight (kilograms) restriction parameter.

  • Weight per Axle Restriction—The results will not include roads where the vehicle weight per axle exceeds the maximum allowed weight per axle for the road. The vehicle weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

  • Width Restriction—The results will not include roads where the vehicle width exceeds the maximum allowed width for the road. The vehicle width can be specified using the Vehicle Width (meters) restriction parameter.

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

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 restrictions 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 travel_mode is set to Custom.

Example for restrictions

restrictions=[Driving a Truck, Height Restriction, Length Restriction]

attribute_parameter_values

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

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 travel_mode parameter.

You can specify attribute_parameter_values parameter using JSON structure that represents a set of features. The JSON structure can include the following properties:

  • features—Specify an array of features.

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

      It is recommended that you explicitly specify the spatialReference value, and specify it for the entire JSON rather than each individual geometry.

    • attributes—Specify each attribute as a key-value pair in which the key is the name of a given field, and the value is the attribute value for the corresponding field.
  • url—Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set.

Each feature in the features array represents an attribute parameter and contains the following fields:

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

The JSON structure for the attribute_parameter_values parameter does not have a geometry property.

Attributes for attribute_parameter_values

The attribute_parameter_values parameter can be specified with the following attributes:

  • AttributeName—The name of the restriction.
  • ParameterName—The name of the parameter associated with the restriction. A restriction can have one or more ParameterName values based on its intended use, which implies you may need multiple attribute_parameter_values parameters for a single attribute name.
  • ParameterValue—The value for the ParameterName that is used by the service when evaluating the restriction.

Note:

In most cases, the attribute_parameter_values parameter is dependent on the restrictions parameter. The ParameterValue specified as part of attribute_parameter_values is applicable only if the restriction name is specified as the value for the restrictions parameter.

When specifying the attribute_parameter_values parameter, each restriction (listed as AttributeName) has a ParameterName value, Restriction Usage, that 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 ParameterName 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 prohibited.
  • Avoid_High (5)—It is very unlikely the service will include in the route the roads that are associated with the restriction.
  • Avoid_Medium (2)—It is unlikely the service will include in the route the roads that are associated with the restriction.
  • Avoid_Low (1.3)—It is somewhat unlikely the service will include in the route the roads that are associated with the restriction.
  • Prefer_Low (0.8)—It is somewhat likely the service will include in the route the roads that are associated with the restriction.
  • Prefer_Medium(0.5)—It is likely the service will include in the route the roads that are associated with the restriction.
  • Prefer_High (0.2)—It is very likely the service will include in the route the roads that are associated with the restriction.

The following table lists the restriction names and the default restriction parameter values for all the restrictions. The default value for the attribute_parameter_values parameter is the JSON structure containing all the rows from the below table.

Tip:

If you want to use the default value for any restriction, AttributeName, ParameterName, and ParameterValue do not have to be specified as part of the attribute_parameter_values parameter.

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

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

Syntax example for attribute_parameter_values

Syntax for specifying attribute_parameter_values
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>,
                "<field3>": <value13>

            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>,
                "<field3>": <value13>
            }
        }
    ] 
}

Examples for attribute_parameter_values

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 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 results 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 ParameterName for the Height Restriction and the Weight Restriction restrictions are not specified since we want to use the default value of PROHIBITED for these restriction parameters.

attribute_parameter_values=
{
    "features": [
        {
            "attributes": {
                "AttributeName": "Height Restriction",
                "ParameterName": "Vehicle Height (meters)",
                "ParameterValue": 4.12
            }
        },
        {
            "attributes": {
                "AttributeName": "Weight Restriction",
                "ParameterName": "Vehicle Weight (kilograms)",
                "ParameterValue": 36287
            }
        },
        {
            "attributes": {
                "AttributeName": "Use Preferred Truck Routes",
                "ParameterName": "Restriction Usage",
                "ParameterValue": "PREFER_HIGH"
            }
        }
    ]
}

route_shape

Use this parameter to specify the type of route features that are output by the service. The parameter can be specified using one of the following values:

  • True Shape—Return the exact shape of the resulting route that is based on the underlying streets. Since this option creates the most detailed geometry for the output routes, choosing it tends to make the process run longer and create larger output files.
  • True Shape with Measures—Return the exact shape of the resulting route that is based on the underlying streets. Additionally, construct measures so the shape may be used in linear referencing. The measurements increase from the first stop and record the cumulative travel time or travel distance in the units specified by the measurement_units parameter.
  • Straight Line—Return a straight line between the route start and end.
  • None—Do not return any route shapes. This value can be useful in cases where you want to optimize performance and are only interested in determining the route's total travel time or travel distance, but not the route paths.

The default value is True Shape.

When the route_shape parameter is set to True Shape, or True Shape with Measure, the generalization of the route shape can be further controlled using the appropriate value for the route_ line_simplification_tolerance parameter.

No matter which value you choose for the route_shape parameter, the best route is always determined by minimizing the travel time or the travel distance, never using the straight-line distance between stops. This means that only the route shapes are different, not the underlying streets that are searched when finding the route.

Tip:

Specifying True Shape or True Shape with Measures creates the most detailed geometry for the output routes. So choosing these options tends to increase the response time for the request and also create larger responses. So use these options only when the exact route shape is required.

route_line_simplification_tolerance

Use this parameter to specify by how much you want to simplify the route geometry returned by the service.

Caution:

The value for this parameter, regardless of whether you rely on the default or explicitly set a value, is used in the analysis only when the travel_mode parameter is set to Custom.

This parameter is relevant only when route_shape is set to True Shape or True Shape with Measures because the other route_shape options cannot be simplified further.

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 applications.

The parameter is specified as a JSON structure that includes the following properties:

  • distance—The simplification distance value.
  • units—The units for the simplification distance value. The property value should be specified as one of the following values: esriCentimeters, esriDecimalDegrees, esriDecimeters, esriFeet, esriInches, esriKilometers, esriMeters, esriMiles, esriMillimeters, esriNauticalMiles, esriPoints, and esriYards.

The default value for the route_line_simplification_tolerance parameter is 10 meters.

Syntax example for route_line_simplification_tolerance

Syntax for specifying route_line_simplification_tolerance
 {
    "distance": <value>,
    "units": "<unit>"
}

Example for route_line_simplification_tolerance

Example: Specifying route_line_simplification_tolerance of 10 meters
 {
    "distance": 10,
    "units": "esriMeters"
}

populate_directions

Use this parameter to specify whether the service should generate driving directions for each route.

  • true—Generate directions. The directions are configured based on the values for the directions_language, directions_style_name, and directions_distance_units parameters.

  • false—Don't generate directions. The service returns an empty value for the features property within the output_directions output parameter.

directions_language

The language that will be used when generating travel directions.

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

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

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

Caution:

If a language supports localization, such as Brazilian Portuguese (pt-BR) and European Portuguese (pt-PT), specify the language family and the localization. If you only specify the language family, the service will not match the language family and will return directions in the default language of the server's operating system. For example, if the directions language is specified as pt, the service will return the directions in the default language of the server's operating system since it cannot determine whether the directions should be returned in pt-BR or pt-PT.

directions_distance_units

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

  • Miles
  • Kilometers
  • Meters
  • Feet
  • Yards
  • NauticalMiles

The default value is Miles.

directions_style_name

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

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

The default value is NA Desktop.

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

impedance

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 travel_mode.

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

The impedance parameter can be specified using the following values:

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

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

If you choose a time-based impedance, such as TravelTime, TruckTravelTime, Minutes, TruckMinutes, or WalkTime, the measurement_units parameter must be set to a time-based value; if you choose a distance-based impedance such as Miles, Kilometers, the measurement_units must be distance-based.

Legacy:

Drive Time, Truck Time, Walk Time, and Travel Distance impedance values are no longer supported and will be removed in a future release.

analysis_region

This parameter is ignored by the service and specifying a value does not have any effect on the analysis.

save_route_data

Use this parameter to specify whether the service should create a zip file that contains a file geodatabase holding the inputs and outputs of the analysis in a format that can be used to share route layers with your portal.

  • true—Saves route data. The route data zip file can be downloaded from the URL provided as part of the output_route_data parameter.
  • false—Don't save route data.

The default value is false.

save_output_network_analysis_layer

Use this parameter to specify if the service should save the analysis settings as a network analysis layer file. You cannot directly work with this file even when you open the file in an ArcGIS Desktop application like ArcGIS Pro. It is meant to be sent to Esri Technical Support in order to diagnose the quality of results returned from the service.

  • true—Saves network analysis layer file. The file can be downloaded from the URL provided as part of the output_network_analysis_layer parameter.
  • false—Don't save network analysis layer file.

The default value is false.

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 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 that no solver settings will be overridden.

Only use the advanced override settings 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.

time_impedance

The time-based impedance value represents the travel time along road segments or on other parts of the transportation network.

  • Minutes
  • TravelTime
  • WalkTime
  • TruckMinutes
  • TruckTravelTime

Note:
If the impedance for the travel mode, as specified using the impedance parameter, is time based, the values for the time_impedance and impedance parameters must be identical. Otherwise, the service will return an error.
Note:

This parameter is used for defining a custom travel mode. The value of this parameter is ignored if the travel_mode parameter is not set to Custom.

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

distance_impedance

The distance-based impedance value represents the travel distance along road segments or on other parts of the transportation network.

  • Miles
  • Kilometers

Note:
If the impedance for the travel mode, as specified using the impedance parameter, is distance based, the values for the distance_impedance and impedance parameters must be identical. Otherwise, the service will return an error.
Note:

This parameter is used for defining a custom travel mode. The value of this parameter is ignored if the travel_mode parameter is not set to Custom.

Note:

These value are specific to the services published with the ArcGIS StreetMap Premium data. The values will be different if you are using other data for the analysis.

output_format

Specifies the format in which the output features will be returned.

  • Feature Set—The output features will be returned as feature classes and tables. This is the default.
  • JSON File—The output features will be returned as a compressed file containing the JSON representation of the outputs. When this option is specified, the output is a single file (with a .zip extension) that contains one or more JSON files (with a .json extension) for each of the outputs created by the service.
  • GeoJSON File—The output features will be returned as a compressed file containing the GeoJSON representation of the outputs. When this option is specified, the output is a single file (with a .zip extension) that contains one or more GeoJSON files (with a .geojson extension) for each of the outputs created by the service.

Tip:

Specifying file based output format, such asJSON File, is useful when you are calling the service using the REST endpoint of the service. In such cases, returning all the outputs as a single file allows you to download large results that can be generated by the service. For example, if you are working with GenerateOriginDestinationCostMatrix service and you generate a travel matrix with 1,000,000 records, returning such a large output as a Feature Set can cause the service to fail since the service will try to send the entire output in a single attempt. With a file based output, the service sends the output in multiple chunks reducing the possibility of timeouts when returning the outputs.

env:outSR

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

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

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

ignore_network_location_fields

Specifies whether the network location fields will be considered when locating inputs such as stops or facilities on the network.

  • true—Network location fields will not be considered when locating the inputs on the network. Instead, the inputs will always be located by performing a spatial search.
  • false—Network location fields will be considered when locating the inputs on the network.

The default value is false.

ignore_invalid_locations

Specifies whether invalid input locations will be ignored.

  • true

    Network locations that are unlocated will be ignored and the analysis will run using valid network locations only. The analysis will also continue if locations are on nontraversable elements or have other errors. This is useful if you know the network locations are not all correct, but you want to run the analysis with the network locations that are valid. This is the default.

  • false

    Invalid locations will not be ignored. Do not run the analysis if there are invalid locations. Correct the invalid locations and rerun the analysis.

locate_settings

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

Learn more about locating inputs

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

Note:

The default value for this parameter can be obtained from the service resource JSON. Append ?token=<yourToken>&f=pjson to the service URL to access the service resource JSON.

The locator JSON object has the following properties:

  • tolerance and toleranceUnits—Allows you to control the maximum search distance when locating inputs. If no valid network location is found within this distance, the input features will be considered unlocated. A small search tolerance decreases the likelihood of locating on the wrong street but increases the likelihood of not finding any valid network location. The toleranceUnits parameter value can be specified as one of the following values:
    • esriCentimeters
    • esriDecimalDegrees
    • esriDecimeters
    • esriFeet
    • esriInches
    • esriIntFeet
    • esriIntInches
    • esriIntMiles
    • esriIntNauticalMiles
    • esriIntYards
    • esriKilometers
    • esriMeters
    • esriMiles
    • esriMillimeters
    • esriNauticalMiles
    • esriYards
  • sources—Allows you to control which network source can be used for locating. For example, you can configure the analysis to locate inputs on streets but not on sidewalks. The list of possible sources on which to locate is specific to the network dataset this service references. Only the sources that are present in the sources array are used for locating. You can specify a whereclause on each source you specified in the sources array to further restrict locating on that source matching certain characteristics using an SQL expression. For example, you can configure the analysis to locate inputs only on street features matching certain road classes such as avoiding highway ramps. Sources is specified as an array of objects, each having the following properties:
    • name—Name of the network source feature class that can be used for locating inputs.
    • where—An SQL expression on the network source feature class.
  • allowAutoRelocate—Allows you to control whether inputs with existing network location fields can be automatically relocated when solving to ensure valid, routable location fields for the analysis. If the value is true, points located on restricted network elements and points affected by barriers will be relocated to the closest routable location. If the value is false, network location fields will be used as is even if the points are unreachable, and this may cause the solve to fail. Even if the value is false, inputs with no location fields or incomplete location fields will be located during the solve operation.

Syntax for locate_settings

Syntax for specifying locate_settings using JSON structure.

Note:

Line barriers and polygon barriers doesn't support the tolerance and toleranceUnits properties.


{
    "default": {
        "tolerance": <value>,
        "toleranceUnits": "<unit>",
        "allowAutoRelocate": true | false,
        "sources": [{
            "name": "<sourceName>",
            "where": "<whereClause>"
        }]
    },
    "overrides": {
        "incidents": {
            "tolerance": <value>,
            "toleranceUnits": "<unit>",
            "allowAutoRelocate": true | false,
            "sources": [{
                "name": "<sourceName>",
                "where": "<whereClause>"
            }]
        },
        "facilities": {
            "tolerance": <value>,
            "toleranceUnits": "<unit>",
            "allowAutoRelocate": true | false,
            "sources": [{
                "name": "<sourceName>",
                "where": "<whereClause>"
            }]
        },
        "point_barriers": {
            "tolerance": <value>,
            "toleranceUnits": "<unit>",
            "allowAutoRelocate": true | false,             
            "sources": [{
                "name": "<sourceName>",
                "where": "<whereClause>"
            }]
        },
        "line_barriers": {
            "allowAutoRelocate": true | false,       
            "sources": [{
                "name": "<sourceName>",
                "where": "<whereClause>"
            }]
        },
        "polygon_barriers": {
            "allowAutoRelocate": true | false,  
            "sources": [{
                "name": "<sourceName>",
                "where": "<whereClause>"
            }]
        }
    }
}

Examples for locate_settings

Example 1: Specify default locate settings using JSON structure

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


{
  "default": {
    "tolerance": 500,
    "toleranceUnits": "esriMeters",
    "allowAutoRelocate": true,
    "sources": [
      {
        "name": "Routing_Streets"
      }
    ]
  }
}

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

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


{
    "default": {
        "tolerance": 20,
        "toleranceUnits": "esriKilometers",
        "allowAutoRelocate": true,
        "sources": [{
            "name": "Routing_Streets"
        }]
    },
    "overrides": {
        "incidents": {
            "sources": [{
                "name": "Routing_Streets",
                "where": "ROAD_CLASS <> 3"
            }]
        },
        "facilities": {
            "sources": [{
                "name": "Routing_Streets",
                "where": "ROAD_CLASS <> 3"
            }]
        }
    }
}

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

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


{
    "default": {
        "tolerance": 20,
        "toleranceUnits": "esriKilometers",
        "allowAutoRelocate": true,
        "sources": [{
            "name": "Routing_Streets"
        }]
    },
    "overrides": {
        "point_barriers": {
            "sources": [{
                "name": "Routing_ND_Junctions"
            }]
        }
    }
}

accumulate_attributes

A list of cost attributes to be accumulated during analysis. These accumulated attributes are for reference only; the solver only uses the cost attribute used by the designated travel mode when solving the analysis.

For each cost attribute that is accumulated, a Total_[Cost Attribute Name]_[Units] field is populated in the outputs created from the tool.

Output parameters

Upon successful execution, the service returns the best route and driving directions between the incident and the chosen facility and the status indicating if the analysis was successful using the following output parameters:

output_closest_facilities and output_facilities

This output parameter gives you access to the facilities that were closest to the incidents. It provides the location of the facilities and attribute information from the corresponding input facilities.

The output_closest_facilities parameter includes only those facilities from the set of input facilities that were closest to at least one incident. Conversely, the output_facilities data type includes all the facilities from the analysis including the facilities that cannot be reached from any of the incidents. You can use the Status field from the output_facilities data type to determine why a facility was not used in the analysis.

The following table lists the fields that are returned for output facilities:

Field nameDescription

Name

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

SourceID

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

SourceOID

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

PosAlong

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

SideOfEdge

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

CurbApproach

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

Status

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

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

SnapX

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

SnapY

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

SnapZ

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

DistanceToNetworkInMeters

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

AdditionalTime

The amount of time added to the total route time when this facility is visited. The values for this field are copied from the AdditionalTime field on the input facilities.

AdditionalDistance

The amount of distance added to the total route distance when this facility is visited. The values for this field are copied from the AdditionalDistance field on the input facilities.

AdditionalCost

The cost added to the total route cost when this facility is visited. The values for this field are copied from the AdditionalCost field on the input facilities. This field is included only when the travel mode used for the analysis has an impedance attribute that is neither time based nor distance based.

Cutoff

The impedance value at which the analysis stopped searching for the facilities from a given incident. The values for this field are copied from the Cutoff field on the input facilities.

ID

A user-defined unique identifier for the facility. The values for this field are copied from the ID field on the input facilities.

ORIG_FID

FacilityOID

The ObjectID value of the input facility. This field is often used to join information from the input facilities.

The output_closest_facilities output includes the ORIG_FID field, and the output_facilities output includes the FacilityOID field.

Bearing

The values for this field are copied from the Bearing field on the input facilities.

BearingTol

The values for this field are copied from the BearingTol field on the input facilities.

NavLatency

The values for this field are copied from the NavLatency field on the input facilities.

Syntax example for output_closest_facilities

The output_closest_facilities parameter is returned as a JSON feature set with following syntax:


{
  "paramName": "output_closest_facilities",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": <wkid>,
      "latestWkid": <wkid>
    },
    "fields": [
      {
        "name": "<field1Name>",
        "type": "<field1Type>",
        "alias": "<field1Alias>",
        "length": "<field1Length>"
      },
      {
        "name": "<field2Name>",
        "type": "<field2Type>",
        "alias": "<field2Alias>",
        "length": "<field2Length>"
      }
    ],
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {
          "x": <x11>,
          "y": <y11>
        }
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {
          "x": <x21>,
          "y": <y21>
        }
      ],
      "exceededTransferLimit": <true|false>
    }
  }
}

Example for output_closest_facilities

The following shows an example of the output_closest_facilities parameter:


{
  "paramName": "output_closest_facilities",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OID",
        "type": "esriFieldTypeOID",
        "alias": "OID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 128
      },
      {
        "name": "CurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "CurbApproach"
      },
      {
        "name": "ORIG_FID",
        "type": "esriFieldTypeSmallInteger",
        "alias": "ORIG_FID"
      }
    ],
    "features": [
      {
        "attributes": {
          "OID": 1,
          "Name": "Location 1",
          "CurbApproach": 0,
          "ORIG_FID": 1
        },
        "geometry": {
          "x": -122.45596200044594,
          "y": 37.75131599973366
        }
      },
      {
        "attributes": {
          "OID": 2,
          "Name": "Location 3",
          "CurbApproach": 0,
          "ORIG_FID": 3
        },
        "geometry": {
          "x": -122.45784400000059,
          "y": 37.74071300000497
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

output_incidents

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

The following table lists the fields that are returned for output incidents:

FieldDescription

Name

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

TargetFacilityCount

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

SourceID

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

SourceOID

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

PosAlong

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

SideOfEdge

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

CurbApproach

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

Status

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

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

SnapX

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

SnapY

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

SnapZ

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

DistanceToNetworkInMeters

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

AdditonalTime

The amount of time added to the total route time when this incident is visited. The values for this field are copied from the AdditionalTime field on the input incident.

AdditionalDistance

The amount of distance added to the total route distance when this incident is visited. The values for this field are copied from the AdditionalDistance field on the input incident.

AdditionalCost

The cost added to the total route cost when this incident is visited. The values for this field are copied from the AdditionalCost field on the input incident. This field is included only when the travel mode used for the analysis has an impedance attribute that is neither time based nor distance based.

Cutoff

The impedance value at which the analysis stopped searching for the incidents from a given facility. The values for this field are copied from the Cutoff field on the input incident.

IncidentOID

The ObjectID value of the input incident. This field is often used to join information from the input facilities.

Bearing

The values for this field are copied from the Bearing field on the input facilities.

BearingTol

The values for this field are copied from the BearingTol field on the input facilities.

NavLatency

The values for this field are copied from the NavLatency field on the input facilities.

output_routes

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

The route_shape and route_line_simplification_tolerance parameters influence the shape of the output routes.

The route geometries are returned in the spatial reference specified as the env:outSR parameter.

The following table provides a description of fields that are returned for each route:

Field nameDescription

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 travel_direction parameter is set to Facility to Incident. For example, Facility 5 - Incident 3 indicates that the route travels from Facility 5 to Incident 3.

If Incident to Facility is specified as the value for the travel_direction parameter, the incident name is first, for example, Incident 3 — Facility 5.

FacilityRank

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

FacilityID

The user-defined unique ID of the facility the route visits. The values for this field are copied from the ID field on the input facilities.

FacilityOID

The ObjectID value of the input facility used to generate the route. This field is often used to join information from facilities to routes.

IncidentID

The user-defined unique ID of the incident the route visits. The values for this field are copied from the ID field on input incidents.

IncidentOID

The ObjectID value of the input incident used to generate the route. This field is often used to join information from incidents to routes.

FacilityCurbApproach

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

IncidentCurbApproach

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

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_Minutes

The cumulative travel time in minutes of the route between the facility and the incident. This includes any AdditionalTime values for the visited facility and incident if specified.

Note:

An additional field, Total_[TimeUnits], is included if the measurement_units parameter is time based and its value is not Minutes. The field values are in the units specified by the measurement_units parameter.

Note:

Additional fields, Total_[AccumulateAttributeName]_[TimeUnits], are included for each time-based cost attribute that is accumulated during the analysis.

Total_Miles

The cumulative travel distance in miles of the route between the facility and the incident. This includes any AdditionalDistance values for the visited facility and incident if specified.

Note:

An additional field, Total_[DistanceUnits], is included if the measurement_units parameter is distance based and its value is not Miles or Kilometers. The field values are in the units specified by the measurement_units parameter.

Note:

Additional fields, Total_[AccumulateAttributeName]_[DistanceUnits], are included for each distance-based cost attribute that is accumulated during the analysis.

Total_Kilometers

The cumulative travel distance in kilometers of the route between the facility and the incident. This includes any AdditionalDistance values for the visited facility and incident if specified.

Note:

An additional field, Total_[DistanceUnits], is included if the measurement_units parameter is distance based and its value is not Miles or Kilometers. The field values are in the units specified by the measurement_units parameter.

Note:

Additional fields, Total_[AccumulateAttributeName]_[DistanceUnits], are included for each distance-based cost attribute that is accumulated during the analysis.

Total_Other

The cumulative travel cost in unknown units of the route between the facility and the incident. This includes any AdditionalCost values for the visited facility and incident if specified.

This field is included only when the travel mode used for the analysis has an impedance attribute that is neither time based nor distance based.

Note:

Additional fields, Total_[AccumulateAttributeName]_Other, are included for each cost attribute that is neither time based nor distance based and accumulated during the analysis.

Note:

An additional field with the name Total_[MeasurementUnits] is included if the measurement_units parameter is not equal to Miles, Kilometers, or Minutes. For example, if the measurement_units parameter is specified as Meters, the output_routes parameter will include Total_Meters, Total_Miles, Total_Kilometers, and Total_Minutes fields.

Syntax example for output_routes

The output_routes parameter is returned as a JSON feature set with following syntax:


{
  "paramName": "output_routes",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": <wkid>,
      "latestWkid": <wkid>,
    },
    "fields": [
      {
        "name": "<field1Name>",
        "type": "<field1Type>",
        "alias": "<field1Alias>",
        "length": "<field1Length>" //length is included only for esriFieldTypeString
      },
      {
        "name": "<field2Name>",
        "type": "<field2Type>",
        "alias": "<field2Alias>",
        "length": "<field2Length>"
      }
    ],
    "features": [
      {
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        },
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        }
      },
      {
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        },
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        }
      }
    ],
    "exceededTransferLimit": <true|false>
  }
}

Example for output_routes

The following shows an example of the output_routes parameter:

Note:

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


{
  "paramName": "output_routes",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OID",
        "type": "esriFieldTypeOID",
        "alias": "OID"
      },
      {
        "name": "FacilityID",
        "type": "esriFieldTypeString",
        "alias": "FacilityID",
        "length": 50
      },
      {
        "name": "FacilityRank",
        "type": "esriFieldTypeInteger",
        "alias": "FacilityRank"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 128
      },
      {
        "name": "IncidentCurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "IncidentCurbApproach"
      },
      {
        "name": "FacilityCurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "FacilityCurbApproach"
      },
      {
        "name": "IncidentID",
        "type": "esriFieldTypeString",
        "alias": "IncidentID",
        "length": 50
      },
      {
        "name": "Total_Miles",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Miles"
      },
      {
        "name": "Total_Kilometers",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Kilometers"
      },
      {
        "name": "Total_Minutes",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Minutes"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "OID": 1,
          "FacilityID": "3",
          "FacilityRank": 1,
          "Name": "Station 39 - Fire Incident",
          "IncidentCurbApproach": 2,
          "FacilityCurbApproach": 1,
          "IncidentID": "1",
          "Total_Miles": 0.6491655620477702,
          "Total_Kilometers": 1.0447307022882064,
          "Total_Minutes": 1.4172383469037848,
          "Shape_Length": 0.010797590608192222
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45787965542172,
                37.74080213810822
              ],
              [
                -122.45748000030176,
                37.740979999727244
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "OID": 2,
          "FacilityID": "1",
          "FacilityRank": 2,
          "Name": "Station 20 - Fire Incident",
          "IncidentCurbApproach": 1,
          "FacilityCurbApproach": 1,
          "IncidentID": "1",
          "Total_Miles": 0.5794746525076059,
          "Total_Kilometers": 0.9325740551652006,
          "Total_Minutes": 1.5610809309860056,
          "Shape_Length": 0.009809811689090443
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45596098061475,
                37.75135883264409
              ],
              [
                -122.45440000035967,
                37.75123999982617
              ],
            ]
          ]
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

output_directions

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

The directions_language, directions_distance_units, and directions_style_name parameters highly influence the driving directions. The features are empty if the populate_directions parameter is false.

The following table lists the fields that are returned for output directions:

FieldDescription

RouteName

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

ArriveTime

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

Type

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

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

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

Maneuver Types

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

Directions String Types

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

SubItemType

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

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

Text

A text description of the travel directions.

ElaspsedTime

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

DriveDistance

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

The value is in the units specified by the Directions_Distance_Units parameter.

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

Syntax example for output_directions

The output_directions parameter is returned as a JSON feature set with following syntax:

Caution:

The service can only return a maximum of 10,000,000features with the output_directions parameter.


{
  "paramName": "output_directions",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": <wkid>,
      "latestWkid": <wkid>,
    },
    "fields": [
      {
        "name": "<field1Name>",
        "type": "<field1Type>",
        "alias": "<field1Alias>",
        "length": "<field1Length>" //length is included only for esriFieldTypeString
      },
      {
        "name": "<field2Name>",
        "type": "<field2Type>",
        "alias": "<field2Alias>",
        "length": "<field2Length>"
      }
    ],
    "features": [
      {
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        },
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        }
      },
      {
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        },
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        }
      }
    ],
    "exceededTransferLimit": <true|false>
  }
}

Example for output_directions

The following shows an example of the output_directions parameter:

Note:

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


{
  "paramName": "output_directions",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "ObjectID",
        "type": "esriFieldTypeOID",
        "alias": "ObjectID"
      },
      {
        "name": "RouteName",
        "type": "esriFieldTypeString",
        "alias": "RouteName",
        "length": 128
      },
      {
        "name": "ArriveTime",
        "type": "esriFieldTypeDate",
        "alias": "ArriveTime",
        "length": 16
      },
      {
        "name": "Type",
        "type": "esriFieldTypeSmallInteger",
        "alias": "Type"
      },
      {
        "name": "SubItemType",
        "type": "esriFieldTypeSmallInteger",
        "alias": "SubItemType"
      },
      {
        "name": "Text",
        "type": "esriFieldTypeString",
        "alias": "Text",
        "length": 255
      },
      {
        "name": "ElapsedTime",
        "type": "esriFieldTypeSingle",
        "alias": "ElapsedTime"
      },
      {
        "name": "DriveDistance",
        "type": "esriFieldTypeSingle",
        "alias": "DriveDistance"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "ObjectID": 1,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 18,
          "SubItemType": 1,
          "Text": "Start at Station 39",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 2,
          "SubItemType": 1,
          "Text": "Go northeast on PORTOLA DR toward REX AVE",
          "ElapsedTime": 1.044524,
          "DriveDistance": 0.5254771,
          "Shape_Length": 0.008828940635196278
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45787965542172,
                37.74080213810822
              ],
              [
                -122.45748000030176,
                37.740979999727244
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 5,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637758034,
          "Type": 1,
          "SubItemType": 1,
          "Text": "Finish at Fire Incident",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 6,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 18,
          "SubItemType": 1,
          "Text": "Start at Station 20",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 7,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 2,
          "SubItemType": 1,
          "Text": "Go east on OLYMPIA WAY toward DELLBROOK AVE",
          "ElapsedTime": 0.5452001,
          "DriveDistance": 0.2105566,
          "Shape_Length": 0.003820738935246935
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45596098061475,
                37.75135883264409
              ],
              [
                -122.45516999989553,
                37.75133999994108
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 9,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637766665,
          "Type": 1,
          "SubItemType": 1,
          "Text": "Finish at Fire Incident",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

output_direction_points

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

Field nameDescription

RouteID

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

Sequence

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

DirectionPointType

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

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

StopID

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

DisplayText

The directions text to display in the consuming application.

ArrivalTime

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

ArrivalUTCOffset

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

Name

The name of the direction point.

ExitName

The highway exit name that appears in the directions instruction.

AlternateName

The alternate source name that appears in the directions instruction.

IntersectingName

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

BranchName

The signpost branch name that appears in the directions instruction.

TowardName

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

Level

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

ShortVoiceInstruction

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

VoiceInstruction

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

Azimuth

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

Syntax example for output_direction_points

The output_direction_points parameter is returned as a JSON feature set with the following syntax:


{
  "paramName": "output_direction_points",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": <wkid>,
      "latestWkid": <wkid>
    },
    "fields": [
      {
        "name": "<field1Name>",
        "type": "<field1Type>",
        "alias": "<field1Alias>",
        "length": "<field1Length>"
      },
      {
        "name": "<field2Name>",
        "type": "<field2Type>",
        "alias": "<field2Alias>",
        "length": "<field2Length>"
      }
    ],
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {
          "x": <x11>,
          "y": <y11>
        }
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {
          "x": <x21>,
          "y": <y21>
        }
      ],
      "exceededTransferLimit": <true|false>
    }
  }
}

Example for output_direction_points

The following shows an example of the output_direction_points parameter:


{
  "paramName": "output_direction_points",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [{
        "name": "ObjectID",
        "type": "esriFieldTypeOID",
        "alias": "ObjectID"
      },
      {
        "name": "RouteID",
        "type": "esriFieldTypeInteger",
        "alias": "Route ID"
      },
      {
        "name": "Sequence",
        "type": "esriFieldTypeInteger",
        "alias": "Sequence"
      },
      {
        "name": "DirectionPointType",
        "type": "esriFieldTypeInteger",
        "alias": "Direction Point Type"
      },
      {
        "name": "StopID",
        "type": "esriFieldTypeInteger",
        "alias": "Stop ID"
      },
      {
        "name": "DisplayText",
        "type": "esriFieldTypeString",
        "alias": "Display Text",
        "length": 1024
      },
      {
        "name": "ArrivalTime",
        "type": "esriFieldTypeDate",
        "alias": "Arrival Time"
      },
      {
        "name": "ArrivalUTCOffset",
        "type": "esriFieldTypeDouble",
        "alias": "Arrival Time: Offset from UTC in Minutes"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Primary Name",
        "length": 1024
      },
      {
        "name": "ExitName",
        "type": "esriFieldTypeString",
        "alias": "Highway Exit Name"
      },
      {
        "name": "AlternateName",
        "type": "esriFieldTypeString",
        "alias": "Alternate Name"
      },
      {
        "name": "IntersectingName",
        "type": "esriFieldTypeString",
        "alias": "Intersecting Name"
      },
      {
        "name": "BranchName",
        "type": "esriFieldTypeString",
        "alias": "Signpost Branch Name"
      },
      {
        "name": "TowardName",
        "type": "esriFieldTypeString",
        "alias": "Signpost Toward Name"
      },
      {
        "name": "Level",
        "type": "esriFieldTypeInteger",
        "alias": "Level"
      },
      {
        "name": "ShortVoiceInstruction",
        "type": "esriFieldTypeString",
        "alias": "Short Voice Instruction",
        "length": 1024
      },
      {
        "name": "VoiceInstruction",
        "type": "esriFieldTypeString",
        "alias": "Voice Instruction",
        "length": 1024
      },
      {
        "name": "Azimuth",
        "type": "esriFieldTypeDouble",
        "alias": "Azimuth"
      }
    ],
    "features": [{
        "attributes": {
          "ObjectID": 1,
          "RouteID": 1,
          "Sequence": 1,
          "DirectionPointType": 51,
          "StopID": 1,
          "DisplayText": "Start at Stop1",
          "ArrivalTime": null,
          "ArrivalUTCOffset": null,
          "Name": "Stop1",
          "ExitName": null,
          "AlternateName": null,
          "IntersectingName": null,
          "BranchName": null,
          "TowardName": null,
          "Level": null,
          "ShortVoiceInstruction": null,
          "VoiceInstruction": null,
          "Azimuth": 0
        },
        "geometry": {
          "x": -116.99007760199999,
          "y": 33.967480587000068
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "RouteID": 1,
          "Sequence": 2,
          "DirectionPointType": 52,
          "StopID": null,
          "DisplayText": "Go north on Nancy Ave toward Cherry Valley Blvd",
          "ArrivalTime": null,
          "ArrivalUTCOffset": null,
          "Name": "Nancy Ave",
          "ExitName": null,
          "AlternateName": null,
          "IntersectingName": "",
          "BranchName": null,
          "TowardName": null,
          "Level": null,
          "ShortVoiceInstruction": null,
          "VoiceInstruction": null,
          "Azimuth": 1.7238311767578125
        },
        "geometry": {
          "x": -116.99007760199999,
          "y": 33.967480587000068
        }
      },
      {
        "attributes": {
          "ObjectID": 3,
          "RouteID": 1,
          "Sequence": 3,
          "DirectionPointType": 305,
          "StopID": null,
          "DisplayText": "Turn right on Cherry Valley Blvd",
          "ArrivalTime": null,
          "ArrivalUTCOffset": null,
          "Name": "Cherry Valley Blvd",
          "ExitName": null,
          "AlternateName": null,
          "IntersectingName": null,
          "BranchName": null,
          "TowardName": null,
          "Level": null,
          "ShortVoiceInstruction": null,
          "VoiceInstruction": null,
          "Azimuth": 90
        },
        "geometry": {
          "x": -116.99003999999996,
          "y": 33.96873000000005
        }
      },
      {
        "attributes": {
          "ObjectID": 4,
          "RouteID": 1,
          "Sequence": 4,
          "DirectionPointType": 50,
          "StopID": 2,
          "DisplayText": "Finish at Stop2, on the left",
          "ArrivalTime": null,
          "ArrivalUTCOffset": null,
          "Name": "Stop2",
          "ExitName": null,
          "AlternateName": null,
          "IntersectingName": null,
          "BranchName": null,
          "TowardName": null,
          "Level": null,
          "ShortVoiceInstruction": null,
          "VoiceInstruction": null,
          "Azimuth": 0
        },
        "geometry": {
          "x": -116.98829886599998,
          "y": 33.96873000000005
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

output_direction_lines

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

Field nameDescription

DirectionPointID

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

RouteID

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

DirectionLineType

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

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

Meters

The length of the line segment measured in meters.

Minutes

The travel time along the line segment in minutes.

FromLevel

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

ToLevel

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

Syntax example for output_direction_lines

The output_direction_lines parameter is returned as a JSON feature set with the following syntax:


{
  "paramName": "output_direction_lines",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": <wkid>,
      "latestWkid": <wkid>
    },
    "fields": [
      {
        "name": "<field1Name>",
        "type": "<field1Type>",
        "alias": "<field1Alias>",
        "length": "<field1Length>" //length is included only for esriFieldTypeString
      },
      {
        "name": "<field2Name>",
        "type": "<field2Type>",
        "alias": "<field2Alias>",
        "length": "<field2Length>"
      }
    ],
    "features": [
      {
        "attributes": {
          "<field1>": <value11>,
          "<field2>": <value12>
        },
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "<field1>": <value21>,
          "<field2>": <value22>
        },
        "geometry": {
          "paths": [
            [
              [
                <x11>,
                <y11>
              ],
              [
                <x12>,
                <y12>
              ]
            ],
            [
              [
                <x21>,
                <y21>
              ],
              [
                <x22>,
                <y22>
              ]
            ]
          ]
        }
      }
    ],
    "exceededTransferLimit": <true|false>
  }
}

Example for output_direction_lines

The following shows an example of the output_direction_lines parameter:


{
  "paramName": "output_direction_lines",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [{
        "name": "ObjectID",
        "type": "esriFieldTypeOID",
        "alias": "ObjectID"
      },
      {
        "name": "DirectionPointID",
        "type": "esriFieldTypeInteger",
        "alias": "Direction Point ID"
      },
      {
        "name": "RouteID",
        "type": "esriFieldTypeInteger",
        "alias": "Route ID"
      },
      {
        "name": "DirectionLineType",
        "type": "esriFieldTypeInteger",
        "alias": "Direction Line Type"
      },
      {
        "name": "Meters",
        "type": "esriFieldTypeDouble",
        "alias": "Meters"
      },
      {
        "name": "Minutes",
        "type": "esriFieldTypeDouble",
        "alias": "Minutes"
      },
      {
        "name": "FromLevel",
        "type": "esriFieldTypeInteger",
        "alias": "From Level"
      },
      {
        "name": "ToLevel",
        "type": "esriFieldTypeInteger",
        "alias": "To Level"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [{
        "attributes": {
          "ObjectID": 1,
          "DirectionPointID": 2,
          "RouteID": 1,
          "DirectionLineType": 1,
          "Meters": 138.63309138928537,
          "Minutes": 0.20794963587952883,
          "FromLevel": null,
          "ToLevel": null,
          "Shape_Length": 0.0012499787017906437
        },
        "geometry": {
          "paths": [
            [
              [
                -116.99007760199999,
                33.967480587000068
              ],
              [
                -116.99003999999996,
                33.96873000000005
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "DirectionPointID": 3,
          "RouteID": 1,
          "DirectionLineType": 1,
          "Meters": 160.91529151117024,
          "Minutes": 0.14887344090869106,
          "FromLevel": null,
          "ToLevel": null,
          "Shape_Length": 0.0017411339999853226
        },
        "geometry": {
          "paths": [
            [
              [
                -116.99003999999996,
                33.96873000000005
              ],
              [
                -116.98971999999998,
                33.96873000000005
              ],
              [
                -116.98903999999999,
                33.96873000000005
              ],
              [
                -116.98829886599998,
                33.96873000000005
              ]
            ]
          ]
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

solve_succeeded

Use this parameter to determine if the service found the routes successfully. The error messages for the failure can be obtained by making a request to get the status of the job.

The solve_succeeded parameter is returned as a JSON feature set with the following syntax:


{
  "paramName": "solve_succeeded",
  "dataType": "GPBoolean",
  "value": <true | false>
}

The following shows an example of the solve_succeeded parameter:


{
  "paramName": "solve_succeeded",
  "dataType": "GPBoolean",
  "value": true
}

Example usage

The Closest Facility service supports synchronous and asynchronous execution modes. Synchronous and asynchronous modes define how the application interacts with the service and gets the results.

The request URL and the parameter names supported by the service when using synchronous execution are different and described on the Closest Facility Service with synchronous execution page.

Caution:

The maximum time an application can use the Closest Facility service when using the asynchronous execution mode is 1 hour (3,600 seconds) by default. If your request does not complete within this time limit, it will time out and return a failure. You can increase this timeout by modifying the The maximum time a client can use a service property using ArcGIS Server Manager.

When using the asynchronous execution mode, the request is of the following form:

https://<gpservice-url>/FindClosestFacility/submitJob?parameters
Note:

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

Finding the closest fire stations

In this example, you will find the two fire stations that can provide the quickest response to a fire at a given address. You will also generate routes and driving directions for the firefighters.

All the fire stations in the neighborhood are specified as the facilities parameter, and the location of the fire is specified as the incidents parameter. To include the name of the fire station in the driving directions, specify the name as the attribute of the facilities. For facilities and incidents, the geometries are in the spatial reference of the network dataset, WGS84. So the spatialReference property is not required.

Because you want to model the fire engines traveling from the stations to the location of the fire, you specify Facility to Incident as the value for the travel_direction parameter. You need to find the two closest fire stations within three minutes of the fire, so specify 2 as the value for the number_of_facilities_to_find parameter and 3 as the value for the cutoff parameter. You need to calculate the best routes that account for the current traffic conditions, so specify the current time as the time_of_day parameter and specify Start Time as the time_of_day_usage parameter.

Request example

The first request is to submit a job that returns the job ID.

https://<gpservice-url>/FindClosestFacilities/submitJob?incidents={"features":[{"geometry":{"x":-122.449614,"y":37.746712},"attributes":{"Name":"Fire Incident"}}]}&facilities={"features":[{"geometry":{"x":-122.455962,"y":37.751316},"attributes":{"Name":"Station 20"}},{"geometry":{"x":-122.440825,"y":37.753199},"attributes":{"Name":"Station 24"}},{"geometry":{"x":-122.457844,"y":37.740713},"attributes":{"Name":"Station 39"}}]}&travel_direction=Facility to Incident&number_of_facilities_to_find=2&cutoff=3&time_of_day=1365637673000&time_of_day_usage=Start Time&populate_directions=true&f=json&token=<yourToken>

JSON Response example


{
  "jobId": "j4459787f65404b439dac83a70d042e98",
  "jobStatus": "esriJobSubmitted"
}

Query job status

The job ID obtained from the response of the first request can be queried periodically to determine the status of the job.

Request to query job status

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>?returnMessages=true&f=json&token=<yourToken>

JSON Response example


{
  "jobId": "j4459787f65404b439dac83a70d042e98",
  "jobStatus": "esriJobSucceeded",
  "results": {
    "Output_Routes": {
      "paramUrl": "results/Output_Routes"
    },
    "Output_Directions": {
      "paramUrl": "results/Output_Directions"
    },
    "Solve_Succeeded": {
      "paramUrl": "results/Solve_Succeeded"
    },
    "Output_Closest_Facilities": {
      "paramUrl": "results/Output_Closest_Facilities"
    }
  },
  "inputs": {
    "Incidents": {
      "paramUrl": "inputs/Incidents"
    },
    "Facilities": {
      "paramUrl": "inputs/Facilities"
    },
    "Measurement_Units": {
      "paramUrl": "inputs/Measurement_Units"
    },
    "Analysis_Region": {
      "paramUrl": "inputs/Analysis_Region"
    },
    "Number_of_Facilities_to_Find": {
      "paramUrl": "inputs/Number_of_Facilities_to_Find"
    },
    "Cutoff": {
      "paramUrl": "inputs/Cutoff"
    },
    "Travel_Direction": {
      "paramUrl": "inputs/Travel_Direction"
    },
    "Use_Hierarchy": {
      "paramUrl": "inputs/Use_Hierarchy"
    },
    "Time_of_Day": {
      "paramUrl": "inputs/Time_of_Day"
    },
    "Time_of_Day_Usage": {
      "paramUrl": "inputs/Time_of_Day_Usage"
    },
    "UTurn_at_Junctions": {
      "paramUrl": "inputs/UTurn_at_Junctions"
    },
    "Point_Barriers": {
      "paramUrl": "inputs/Point_Barriers"
    },
    "Line_Barriers": {
      "paramUrl": "inputs/Line_Barriers"
    },
    "Polygon_Barriers": {
      "paramUrl": "inputs/Polygon_Barriers"
    },
    "Restrictions": {
      "paramUrl": "inputs/Restrictions"
    },
    "Attribute_Parameter_Values": {
      "paramUrl": "inputs/Attribute_Parameter_Values"
    },
    "Route_Shape": {
      "paramUrl": "inputs/Route_Shape"
    },
    "Route_Line_Simplification_Tolerance": {
      "paramUrl": "inputs/Route_Line_Simplification_Tolerance"
    },
    "Populate_Directions": {
      "paramUrl": "inputs/Populate_Directions"
    },
    "Directions_Language": {
      "paramUrl": "inputs/Directions_Language"
    },
    "Directions_Distance_Units": {
      "paramUrl": "inputs/Directions_Distance_Units"
    },
    "Directions_Style_Name": {
      "paramUrl": "inputs/Directions_Style_Name"
    }
  },
  "messages": []
}

Return output closest facilities

Because the job succeeded, a request can be made to return the facilities that are closest to the incidents. The output parameter used to retrieve these results is output_closest_facilities.

Request to return closest facilities

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/results/output_closest_facilities?returnMessages=true&f=json&token=<yourToken>

JSON Response example


{
  "paramName": "Output_Closest_Facilities",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPoint",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OID",
        "type": "esriFieldTypeOID",
        "alias": "OID"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 50
      },
      {
        "name": "ID",
        "type": "esriFieldTypeString",
        "alias": "ID",
        "length": 50
      },
      {
        "name": "AdditionalTime",
        "type": "esriFieldTypeDouble",
        "alias": "Additional Time"
      },
      {
        "name": "AdditionalDistance",
        "type": "esriFieldTypeDouble",
        "alias": "Additional Distance"
      },
      {
        "name": "CurbApproach",
        "type": "esriFieldTypeSmallInteger",
        "alias": "Curb Approach"
      },
      {
        "name": "ORIG_FID",
        "type": "esriFieldTypeSmallInteger",
        "alias": "ORIG_FID"
      }
    ],
    "features": [
      {
        "attributes": {
          "OID": 1,
          "Name": "Station 20",
          "ID": null,
          "AdditionalTime": 0,
          "AdditionalDistance": 0,
          "CurbApproach": 0,
          "ORIG_FID": 1
        },
        "geometry": {
          "x": -122.45596200044594,
          "y": 37.75131599973366
        }
      },
      {
        "attributes": {
          "OID": 2,
          "Name": "Station 39",
          "ID": null,
          "AdditionalTime": 0,
          "AdditionalDistance": 0,
          "CurbApproach": 0,
          "ORIG_FID": 3
        },
        "geometry": {
          "x": -122.45784400000059,
          "y": 37.74071300000497
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

Return output routes

Because the job succeeded, a request can be made to return the routes from the output_routes output parameter.

Request to return output routes

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/results/output_routes?returnMessages=true&f=json&token=<yourToken>

JSON Response example

Note that output_routes includes routes from two of the three fire stations to the fire incident since the two fire stations are closest to the fire incident based on the travel time. The name of the fire station and the incident name are used to construct the Name attribute for each route.

Note:

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


{
  "paramName": "Output_Routes",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "OID",
        "type": "esriFieldTypeOID",
        "alias": "OID"
      },
      {
        "name": "FacilityID",
        "type": "esriFieldTypeString",
        "alias": "FacilityID",
        "length": 50
      },
      {
        "name": "FacilityRank",
        "type": "esriFieldTypeInteger",
        "alias": "FacilityRank"
      },
      {
        "name": "Name",
        "type": "esriFieldTypeString",
        "alias": "Name",
        "length": 128
      },
      {
        "name": "IncidentCurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "IncidentCurbApproach"
      },
      {
        "name": "FacilityCurbApproach",
        "type": "esriFieldTypeInteger",
        "alias": "FacilityCurbApproach"
      },
      {
        "name": "IncidentID",
        "type": "esriFieldTypeString",
        "alias": "IncidentID",
        "length": 50
      },
      {
        "name": "Total_Minutes",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Minutes"
      },
      {
        "name": "Total_Miles",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Miles"
      },
      {
        "name": "FacilityOID",
        "type": "esriFieldTypeInteger",
        "alias": "FacilityOID"
      },
      {
        "name": "IncidentOID",
        "type": "esriFieldTypeInteger",
        "alias": "IncidentOID"
      },
      {
        "name": "Total_Kilometers",
        "type": "esriFieldTypeDouble",
        "alias": "Total_Kilometers"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "OID": 1,
          "FacilityID": "1",
          "FacilityRank": 1,
          "Name": "Station 20 - Fire Incident",
          "IncidentCurbApproach": 1,
          "FacilityCurbApproach": 1,
          "IncidentID": "1",
          "Total_Minutes": 1.4635369356153203,
          "Total_Miles": 0.5767923258767018,
          "FacilityOID": 1,
          "IncidentOID": 1,
          "Total_Kilometers": 0.92826,
          "Shape_Length": 0.009809810977047043
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45596097999999,
                37.75135883300004
              ],
              [
                -122.45439999999996,
                37.75124000000005
              ]                         
            ]
          ]
        }
      },
      {
        "attributes": {
          "OID": 2,
          "FacilityID": "3",
          "FacilityRank": 2,
          "Name": "Station 39 - Fire Incident",
          "IncidentCurbApproach": 2,
          "FacilityCurbApproach": 1,
          "IncidentID": "1",
          "Total_Minutes": 1.738154678946342,
          "Total_Miles": 0.6440599460986813,
          "FacilityOID": 3,
          "IncidentOID": 1,
          "Total_Kilometers": 1.03651,
          "Shape_Length": 0.010791093352716757
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45787965499994,
                37.74080213800005
              ],
              [
                -122.45747999999998,
                37.740980000000036
              ]			
            ]
          ]
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

Return output directions

Because the job succeeded, a request can be made to return the driving directions between the two closest fire stations and the fire incident from the output_directions output parameter.

Request to return output directions

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/results/output_directions?returnMessages=true&f=json&token=<yourToken>

JSON Response example

The output directions include the driving directions as well as the geometry for the directions feature. Note that for each route, the first directions feature only includes the attributes property that contains the directions text. The subsequent directions features include the geometry property that is derived from the underlying streets included in the route along with the attributes property. The names of the fire stations and the incident are used in the driving directions.

Note:

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


{
  "paramName": "Output_Directions",
  "dataType": "GPFeatureRecordSetLayer",
  "value": {
    "displayFieldName": "",
    "geometryType": "esriGeometryPolyline",
    "spatialReference": {
      "wkid": 4326,
      "latestWkid": 4326
    },
    "fields": [
      {
        "name": "ObjectID",
        "type": "esriFieldTypeOID",
        "alias": "ObjectID"
      },
      {
        "name": "RouteName",
        "type": "esriFieldTypeString",
        "alias": "RouteName",
        "length": 128
      },
      {
        "name": "ArriveTime",
        "type": "esriFieldTypeDate",
        "alias": "ArriveTime",
        "length": 16
      },
      {
        "name": "Type",
        "type": "esriFieldTypeSmallInteger",
        "alias": "Type"
      },
      {
        "name": "SubItemType",
        "type": "esriFieldTypeSmallInteger",
        "alias": "SubItemType"
      },
      {
        "name": "Text",
        "type": "esriFieldTypeString",
        "alias": "Text",
        "length": 255
      },
      {
        "name": "ElapsedTime",
        "type": "esriFieldTypeSingle",
        "alias": "ElapsedTime"
      },
      {
        "name": "DriveDistance",
        "type": "esriFieldTypeSingle",
        "alias": "DriveDistance"
      },
      {
        "name": "Shape_Length",
        "type": "esriFieldTypeDouble",
        "alias": "Shape_Length"
      }
    ],
    "features": [
      {
        "attributes": {
          "ObjectID": 1,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 18,
          "SubItemType": 1,
          "Text": "Start at Station 20",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 2,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 2,
          "SubItemType": 1,
          "Text": "Go east on Olympia Way toward Dellbrook Ave",
          "ElapsedTime": 0.5476729,
          "DriveDistance": 0.2098574,
          "Shape_Length": 0.0038207383571576604
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45596097999999,
                37.75135883300004
              ],
              [
                -122.45516999999995,
                37.75134000000003
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 4,
          "RouteName": "Station 20 - Fire Incident",
          "ArriveTime": 1365637760812,
          "Type": 1,
          "SubItemType": 1,
          "Text": "Finish at Fire Incident",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 5,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 18,
          "SubItemType": 1,
          "Text": "Start at Station 39",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      },
      {
        "attributes": {
          "ObjectID": 6,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637673000,
          "Type": 2,
          "SubItemType": 1,
          "Text": "Go northeast on Portola Dr toward Rex Ave",
          "ElapsedTime": 1.350187,
          "DriveDistance": 0.5206896,
          "Shape_Length": 0.008828940334549
        },
        "geometry": {
          "paths": [
            [
              [
                -122.45787965499994,
                37.74080213800005
              ],
              [
                -122.45747999999998,
                37.740980000000036
              ]
            ]
          ]
        }
      },
      {
        "attributes": {
          "ObjectID": 9,
          "RouteName": "Station 39 - Fire Incident",
          "ArriveTime": 1365637777289,
          "Type": 1,
          "SubItemType": 1,
          "Text": "Finish at Fire Incident",
          "ElapsedTime": 0,
          "DriveDistance": 0,
          "Shape_Length": 0
        }
      }
    ],
    "exceededTransferLimit": false
  }
}

JSON Response syntax

When you submit a request, the service assigns a unique job ID for the transaction. The job ID and the status of the job are returned in the response.


{
  "jobId": <jobID>,
  "jobStatus": <jobStatus>
}

The jobStatus property can have the following values:

  • esriJobSubmitted
  • esriJobWaiting
  • esriJobExecuting
  • esriJobSucceeded
  • esriJobFailed
  • esriJobTimedOut
  • esriJobCancelling
  • esriJobCancelled

Job execution

You can use the job ID to periodically check the status of the job and messages. Additionally, if the job has successfully completed, you can use the job ID to retrieve the results or even the inputs. The job information and results remain available for 24 hours after the job is finished.

After the initial request is submitted, you can make a request of the following form to get the status of the job:

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>?token=<yourToken>&returnMessages=true&f=json

Below is a sample JSON syntax returned using the above URL:


{
  "jobId": "<jobId>",
  "jobStatus": "<jobStatus>",
  "messages": [
    {
      "type": "<type1>",
      "description": "<description1>"
    },
    {
      "type": "<type2>",
      "description": "<description2>"
    }
  ]
}

While a job is executing, you can cancel it by making a request of the following form:

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/cancel?token=<yourToken>&f=json
Note:

When you submit your request, if the service is busy processing other requests, the job will wait in the queue. The job status will be reported as esriJobSubmitted. If your application cannot wait for the entire duration while the job is in the queue, you can cancel the request and submit it at a later time. A canceled request will not incur any service credits. However, if your application did not cancel the request, it will eventually execute and will incur service credits regardless of whether your application retrieved the results or ignored them. Therefore, your application should always cancel the request if required.

Job completion

After the successful completion of the job, you can make a request of the following form to retrieve the outputs. Refer to the Output parameters section for more information on how to interpret the solution provided by the service.

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/results/<output_parameter_name>?token=<yourToken>&f=json

You can also retrieve the value for any input parameter by making the requests of the following form:

https://<gpservice-url>/FindClosestFacilities/jobs/<yourJobID>/inputs/<inputParameterName>?token=<yourToken>&f=json

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,000,000

Maximum number of directions features that can be returned.

4 hours

Maximum time a client can use the asynchronous closest facility service.

The limit for snap tolerance cannot be changed, however you can configure other limits by following the steps below:

  1. Open Server Manager for the ArcGIS Server site that contains the NetworkAnalysis geoprocessing service and sign in. If you need help with this step, see Log in to Manager.
  2. Click Services > Manage Services.
  3. In the Manage Services module, locate NetworkAnalysis geoprocessing service and click Edit Service Edit.

    If you don't see the service under the Routing folder, it may be located within another folder under the Site (root) >.

  4. Click the Parameters option and change the limit for the number of records returned by the service by editing the value in Maximum Number of Records Returned by Server text box.
  5. Click the Pooling option and change the maximum time the service can be used by editing the value in the The maximum time a client can use a service text box.
  6. Click Save and Restart to apply your edits and restart the service.