

# Calculating routes using Amazon Location Service
<a name="calculating-routes"></a>

**Note**  
We released a new version of the Routes API, see the updated [Routes Developer Guide](https://docs.aws.amazon.com//location/latest/developerguide/routes.html) or [Routes API](https://docs.aws.amazon.com/location/latest/APIReference/API_Operations_Amazon_Location_Service_Routes_V2.html) for revised information.

Amazon Location lets you select a data provider for calculating a route by creating and configuring a route calculator resource.

You can use the route calculator resource to [calculate a route](calculate-route.md) given specific parameters using the AWS SDK, or the REST API endpoints. Use this route calculator resource to calculate routes between an origin, a destination and up to 23 waypoints for different modes of transportation, avoidances, and traffic conditions. 

You can also use the route calculator resource to create inputs for your route planning algorithms or products by [calculating a route matrix](calculate-route-matrix.md). Calculate the travel time and travel distance between a set of departure positions and a set of destination positions. Route planning software can use that time and distance data to optimize a route or a set of routes; for example, if you are planning multiple delivery routes, and want to find the best route and time for each stop. You can calculate a matrix of routes for different modes of transportation, avoidances, and traffic conditions.

**Note**  
For an overview of routing concepts, see [Learn about routing in Amazon Location Service](route-concepts.md).

**Topics**
+ [Prerequisites for calculating routes using Amazon Location](routes-prerequisites.md)
+ [Calculate a route with Amazon Location](calculate-route.md)
+ [Route planning with a route matrix in Amazon Location](calculate-route-matrix.md)
+ [Positions not located on a road in Amazon Location](snap-to-nearby-road.md)
+ [Departure time with Amazon Location](departure-time.md)
+ [Travel mode with Amazon Location](travel-mode.md)
+ [Managing your route calculator resources with Amazon Location](managing-route-calculators.md)

# Prerequisites for calculating routes using Amazon Location
<a name="routes-prerequisites"></a>

This page outlines prerequisites to get started with the service's routing features, which enable you to calculate optimized routes and travel times between multiple locations. It covers essential topics, such as configuring access permissions, setting up the required resources within your AWS account, and any additional dependencies or tools needed based on your specific use case or development environment. 

## Create a route calculator resource
<a name="create-route-calculator-resource"></a>

Before you can calculate a route, create a route calculator resource in your AWS account. 

When you create a route calculator resource, you can choose from the data providers available:

1. **Esri** – For more information about Esri's coverage in your region of interest, see [Esri details on street networks and traffic coverage](https://doc.arcgis.com/en/arcgis-online/reference/network-coverage.htm).

1. **HERE Technologies** – For more information about HERE's coverage in your region of interest, see [HERE car routing coverage](https://developer.here.com/documentation/routing-api/dev_guide/topics/coverage/car-routing.html) and [HERE truck routing coverage](https://developer.here.com/documentation/routing-api/dev_guide/topics/coverage/truck-routing.html).

1. **Grab** – For more information about Grab's coverage, see [Countries/regions and area covered](grab.md#grab-coverage-area).

**Note**  
If your application is tracking or routing assets you use in your business, such as delivery vehicles or employees, you must not use Esri as your geolocation provider. See section 82 of the [AWS service terms](https://aws.amazon.com/service-terms) for more details.

You can do this using the Amazon Location Service console, the AWS CLI, or the Amazon Location APIs.

------
#### [ Console ]

**To create a route calculator resource using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. In the left navigation pane, choose **Route calculators**.

1. Choose **Create route calculator**.

1. Fill out the following boxes:
   + ****Name **** – Enter a name for the route calculator resource. For example, *ExampleCalculator*. Maximum 100 characters. Valid entries include alphanumeric characters, hyphens, periods, and underscores.
   + ****Description** ** – Enter an optional description.

1. For **Data providers**, choose a [data provider](https://aws.amazon.com/location/data-providers/) to use as a route calculator.

1. (Optional) Under **Tags**, enter a tag **Key** and **Value**. This adds a tag your new route calculator resource. For more information, see [Tagging your resources](tagging.md).

1. Choose **Create route calculator**.

------
#### [ API ]

**To create a route calculator resource using the Amazon Location APIs**

Use the `[CreateRouteCalculator](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CreateRouteCalculator.html)` operation from the Amazon Location Places APIs. 

The following example is an API request to create a route calculator resource called *ExampleCalculator* using the data provider *Esri*. 

```
POST /routes/v0/calculators
Content-type: application/json

{
   "CalculatorName": "ExampleCalculator",
   "DataSource": "Esri",
   "Description": "string",
   "Tags": { 
      "Tag1" : "Value1" 
   }
}
```

------
#### [ AWS CLI ]

**To create a route calculator resource using AWS CLI commands**

Use the `create-route-calculator` command.

The following example creates a route calculator resource called *ExampleCalculator* using *Esri* as the data provider. 

```
aws location \
  create-route-calculator \
  --calculator-name "ExampleCalculator" \
  --data-source "Esri" \
  --tags Tag1=Value1
```

------

**Note**  
Billing depends on your usage. You may incur fees for the use of other AWS services. For more information, see [Amazon Location Service pricing](https://aws.amazon.com/location/pricing/).

## Authenticating your requests
<a name="routes-identity-pool"></a>

Once you create a route calculator resource and you're ready to begin building location features into your application, choose how you would authenticate your requests: 
+ To explore ways you can access the services, see [Accessing Amazon Location Service](how-to-access.md).
+ If you have a website with anonymous users, you may want to use API Keys or Amazon Cognito.

  **Example**

  The following example shows using an API key for authorization, using [AWS JavaScript SDK v3](https://aws.amazon.com/sdk-for-javascript/), and the Amazon Location [JavaScript Authentication helper](loc-sdk-auth.md).

  ```
  import { LocationClient, CalculateRouteCommand } from "@aws-sdk/client-location";
  import { withAPIKey } from "@aws/amazon-location-utilities-auth-helper";
  
  const apiKey = "v1.public.your-api-key-value"; // API key
  
  // Create an authentication helper instance using an API key
  const authHelper = await withAPIKey(apiKey);
  
  const client = new LocationClient({
    region: "<region>", // region containing Cognito pool
    ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location
  });
  
  const input = {
    CalculatorName: "ExampleCalculator",
    DeparturePosition: [-123.4567, 45.6789],
    DestinationPosition: [-123.123, 45.234],
  };
  
  const command = new CalculateRouteCommand(input);
  
  const response = await client.send(command);
  ```

# Calculate a route with Amazon Location
<a name="calculate-route"></a>

You can use Amazon Location Service to calculate routes between an origin and a destination, with up to 23 waypoints along the route, for different modes of transportation, avoidances, and traffic conditions.

**Note**  
You must first create a route calculator resource and set up authentication for your requests to Amazon Location. For more information, see [Prerequisites for calculating routes using Amazon Location](routes-prerequisites.md).

## Start calculating routes
<a name="start-calculate-route"></a>

Submit a simple request by using the `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` operation. A simple request contains the following required fields:
+ `DeparturePosition` – The starting position for which to calculate the route from. Defined as `[longitude, latitude]`
+ `DestinationPosition` – The end position to which to calculate the route. Defined as `[longitude, latitude]`. 

**Note**  
If you specify a departure or destination position that's not located on a road, Amazon Location [moves the position to the nearest road](snap-to-nearby-road.md).

You can optionally specify [waypoints](#waypoints), a [departure time](departure-time.md), and a [ travel mode](travel-mode.md) in your request.

You can use the AWS CLI or the Amazon Location APIs.

------
#### [ API ]

The following example is a `CalculateRoute` request using the route calculator resource *ExampleCalculator*. The request specifies calculating a route from a departure position [*-122.7565*, *49.0021*] to a destination position [*-122.3394*, *47.6159*].

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159]
}
```

------
#### [ AWS CLI ]

The following example is a `calculate-route` command using the route calculator resource *ExampleCalculator*. The request specifies calculating a route from a departure position [*-122.7565*, *49.0021*] to a destination position [*-122.3394*, *47.6159*].

```
aws location \
    calculate-route \
        --calculator-name ExampleCalculator \
        --departure-position -122.7565 49.0021 \
        --destination-position -122.3394 47.6159
```

------

By default, the response returns `Distance` in kilometers. You can change the unit of measurement to miles using the following optional parameter:
+ `DistanceUnit` – Specifies the unit system to use for the distance results.

**Example**  

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159],
   "DistanceUnit": "Miles"
}
```

## Setting waypoints
<a name="waypoints"></a>

When calculating a route, you can specify up to 23 intermediate stopover points between the departure position and the destination position using waypoint positions.
+ `WaypointPositions` – Specifies an ordered list of intermediate positions to include along a route between the departure position and destination position. 
**Note**  
If you specify a waypoint position that's not located on a road, Amazon Location moves the position to the nearest road.

**Example**  
The following `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` request calculates a route with 2 waypoints:  
+ The departure position is [-122.7565, 49.0021], and the destination position is [-122.3394, 47.6159].
+ For the request parameter `WaypointPositions`:
  + The first stop over position is [*-122.1884, 48.0936*]. 
  + The second stop over position is [*-122.3493, 47.6205*]. 
+ To include the leg linestring geometry between these two waypoints, set the following optional parameter to *true*:
  + `IncludeLegGeometry` – Includes the geometry of each path between a pair of positions in the response.

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159],
   "WaypointPositions":[
        [-122.1884,48.0936],
        [-122.3493,47.6205]
    ],
   "IncludeLegGeometry": true
}
```

## Example response
<a name="example-response-calculate-route"></a>

The following is an example request with the corresponding response when calling the `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` operation from the Amazon Location Routes API with the `IncludeLegGeometry` set to *true*, which includes the linestring geometry of each path between a pair of positions in the response.

------
#### [ Example request ]

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159],
   "IncludeLegGeometry": true
}
```

------
#### [ Example response ]

```
{
   "Legs": [ 
      { 
         "Distance": 178.5,
         "DurationSeconds": 6480,
         "EndPosition": [-122.3394,47.6159],
         "Geometry": { 
            "LineString": [ 
               [-122.7565,49.0021],
               [-122.3394,47.6159]
            ]
         },
         "StartPosition": [-122.7565,49.0021],
         "Steps": [ 
            { 
               "Distance": 178.5,
               "DurationSeconds": 6480,
               "EndPosition": [-122.3394,47.6159],
               "GeometryOffset": 0,
               "StartPosition": [-122.7565,49.0021]
            }
         ]
      }
   ],
   "Summary": { 
      "DataSource": "Esri",
      "Distance": 178.5,
      "DistanceUnit": "Kilometers",
      "DurationSeconds": 6480,
      "RouteBBox": [
        -122.7565,49.0021,
        -122.3394,47.6159
    ]
   }
}
```

------

# Route planning with a route matrix in Amazon Location
<a name="calculate-route-matrix"></a>

You can use Amazon Location Service to create inputs to your route planning and optimization software. You can create route results, including travel time and travel distance, for routes between a set of departure positions and a set of destination positions.

For example, given departure positions A and B, and destination positions X and Y, Amazon Location Service will return travel time and travel distance for routes from A to X, A to Y, B to X, and B to Y. 

You can calculate the routes with different modes of transportation, avoidances, and traffic conditions. For example, you can specify that the vehicle is a truck that is 35 feet long, and the route calculated will use those restrictions to determine the travel time and travel distance.

The number of results returned (and routes calculated) is the number of departure positions multiplied by the number of destination positions. You are charged for each route calculated, not each request to the service, so a route matrix with 10 departures and 10 destinations will be billed as 100 routes.

## Calculating a route matrix
<a name="calc-route-matrix-howto"></a>

You can calculate a matrix of routes between a set of departure positions and a set of destination positions. The route results will include travel time and travel distance.

**Prerequisite**
+ You must first create a route calculator resource and set up authentication for your requests to Amazon Location. For more information, see [Prerequisites for calculating routes using Amazon Location](routes-prerequisites.md).

Submit a request by using the `[CalculateRouteMatrix](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRouteMatrix.html)` operation. A minimal request contains the following required fields:
+ `DeparturePositions` – The set of starting positions for which to calculate the routes. Defined as an array of `[longitude, latitude]`
+ `DestinationPositions` – The set of end positions for which to calculate the routes. Defined as an array of `[longitude, latitude]`. 

**Note**  
If you specify a departure or destination position that's not located on a road, Amazon Location [moves the position to the nearest road](snap-to-nearby-road.md).

You can optionally specify a [departure time](departure-time.md), and a [ travel mode](travel-mode.md) in your request.

You can use the AWS CLI or the Amazon Location APIs.

------
#### [ API ]

The following example is a `CalculateRouteMatrix` request using the route calculator resource *ExampleCalculator*. The request specifies calculating the matrix of routes from departure positions [*-122.7565*, *49.0021 *] and [*-122.2014*, *47.6101*] to destination positions [*-122.3394*, *47.6159 *] and [*-122.4813*, *48.7511*].

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
   "DeparturePositions": [
       [-122.7565,49.0021],
       [-122.2014,47.6101]
   ],
   "DestinationPositions": [
       [-122.3394, 47.6159],
       [-122.4813,48.7511]
   ]
}
```

------
#### [ AWS CLI ]

The following example is a `calculate-route-matrix` command using the route calculator resource *ExampleCalculator*. The request specifies calculating the matrix of routes from departure positions [*-122.7565*, *49.0021 *] and [*-122.2014*, *47.6101*] to destination positions [*-122.3394*, *47.6159 *] and [*-122.4813*, *48.7511*].

```
aws location \
    calculate-route-matrix \
        --calculator-name ExampleCalculator \
        --departure-positions "[[-122.7565,49.0021],[-122.2014,47.6101]]" \
	    --destination-positions "[[-122.3394,47.6159],[-122.4813,48.7511]]"
```

------

By default, the response returns `Distance` in kilometers. You can change the unit of measurement to miles using the following optional parameter:
+ `DistanceUnit` – Specifies the unit system to use for the distance results.

**Example**  

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
   "DeparturePositions": [
       [-122.7565,49.0021],
       [-122.2014,47.6101]
   ],
   "DestinationPositions": [
       [-122.3394, 47.6159],
       [-122.4813,48.7511]
   ],
   "DistanceUnit": "Miles"
}
```

## Restrictions on departure and destination positions
<a name="matrix-routing-position-limits"></a>

When calculating a route matrix, there are restrictions on the departure and destination positions. These restrictions vary depending on the provider used by the `RouteCalculator` resource.


****  

| Limitation | Esri | Grab | HERE | 
| --- | --- | --- | --- | 
| Number of positions | Up to 10 departure positions and 10 destination positions. | Up to 350 departure positions and 350 destination positions. |  Up to 350 departure positions and 350 destination positions. For longer routes, additional restrictions apply. See the [ section](#matrix-routing-longer-routes).  | 
| Distance between positions | Any pair of departure and destination positions must be within 400 km of each other (40km for walking routes). |  |  All departure and destination positions must fall within a 180 km diameter circle. For longer routes, additional restrictions apply. See the [ section](#matrix-routing-longer-routes).  | 
| Route length | Routes will not be completed if the total travel time for the route is over 400 minutes. |    |  Routes that deviate more than 10 km outside a circle around the departure and destination points will not be calculated. For longer routes, additional restrictions apply. See the [ section](#matrix-routing-longer-routes).  | 
| Regions | Calculating a route matrix is not supported in Korea. | Available in Southeast Asia. For a list of supported countries/regions and more information, see [Countries/regions and area covered](grab.md#grab-coverage-area). | No additional restrictions. | 

### Longer route planning
<a name="matrix-routing-longer-routes"></a>

Calculating a matrix of route results is useful for efficient route planning, but the calculation can take some time. All of the Amazon Location Service data providers put limitations on the number of routes or the distance of the routes that can be calculated. For example, HERE allows creating routes between 350 departure and destination positions, but those positions must fall within a 180km circle. What if you want to plan with longer routes?

You can calculate a matrix of routes with unrestricted lengths for a smaller numbers of routes, using, a `RouteCalculator` with HERE as the data provider. This does not change the way that you call the `[CalculateRouteMatrix](https://docs.aws.amazon.com/location/previous/APIReference/API_CalculateRouteMatrix.html)` API, Amazon Location simply allows longer routes when you meet the requirements.

The requirements for longer length route calculations are:
+ The `RouteCalculator` must use the HERE data provider.
+ The number of departure positions must not be greater than 15.
+ The total number of routes to calculate must not be greater than 100.
+ Long distance routing is not allowed for truck routing with toll avoidances when the routes are greater than 1,000 km. This combination is slower to calculate, and can cause the call to time out. You can calculate these routes individually with the [CalculateRoute](https://docs.aws.amazon.com/location/previous/APIReference/API_CalculateRoute.html) operation.

If your call does not meet these requirements (for example, you are requesting 150 route calculations in a single call), then `CalculateRouteMatrix` will revert to only allowing the shorter route rules. You can then calculate the routes, as long as the positions are within a 180km circle.

When calculating longer routes, keep these points in mind:
+ Longer routes can take longer to calculate, even longer than the maximum time for Amazon Location APIs. If you get frequent timeouts with specific routes, you can try a smaller number of routes in each call to `CalculateRouteMatrix`.
+ If you add more destination or departure positions to your `CalculateRouteMatrix` request, the operation can switch into the more restricted mode, and you can get an error for a route that can be calculated without issue when there are fewer routes to create. In this case, reduce the number of destination or departure positions, and make multiple requests to get the full set of route calculations that you need.

## Example response
<a name="example-response-route-matrix"></a>

The following is an example request with the corresponding response when calling the `[CalculateRouteMatrix](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRouteMatrix.html)` operation from the Amazon Location Routes API.

------
#### [ Example request ]

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route-matrix
Content-type: application/json
{
   "DeparturePositions": [
       [-122.7565,49.0021],
       [-122.2014,47.6101]
   ],
   "DestinationPositions": [
       [-122.3394, 47.6159],
       [-122.4813,48.7511]
   ]
}
```

------
#### [ Example response ]

```
{
    "RouteMatrix": [
        [
            {
                "Distance": 178.764,
                "DurationSeconds": 7565
            },
            {
                "Distance": 39.795,
                "DurationSeconds": 1955
            }
        ],
        [
            {
                "Distance": 15.31,
                "DurationSeconds": 1217
            },
            {
                "Distance": 142.506,
                "DurationSeconds": 6279
            }
        ]
    ],
    "Summary": {
        "DataSource": "Here",
        "RouteCount": 4,
        "ErrorCount": 0,
        "DistanceUnit": "Kilometers"
    }
}
```

------

# Positions not located on a road in Amazon Location
<a name="snap-to-nearby-road"></a>

When using `CalculateRoute` or `CalculateRouteMatrix`, if you specify a departure, destination, or waypoint position that's not located on a road Amazon Location moves the position to a nearby road.

The following `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` request specifies a departure position and destination position that's not located on a road:

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-123.128014, 49.298472],
   "DestinationPosition": [-123.134701, 49. 294315]
}
```

The resulting response returns a position that's snapped to a nearby road:

```
{
   "Legs": [
      {
         "StartPosition": [-123.12815, 49.29717],
         "EndPosition":   [-123.13375, 49.2926],
         "Distance": 4.223,
         "DurationSeconds": 697,
         "Steps": [
            {
               "StartPosition": [ -123.12815, 49.29717 ],
               "EndPosition":   [ -123.12806, 49.29707 ],
               "Distance": 0.013,
               "DurationSeconds": 8
            },
            {
               "StartPosition": [ -123.12806, 49.29707 ],
               "EndPosition":   [ -123.1288, 49.29659 ],
               "Distance": 0.082,
               "DurationSeconds": 36
            },
            {
               "StartPosition": [ -123.1288, 49.29659 ],
               "EndPosition":   [ -123.12021, 49.29853 ],
               "Distance": 0.742,
               "DurationSeconds": 128
            },
            {
               "StartPosition": [ -123.12021, 49.29853 ],
               "EndPosition":   [ -123.1201, 49.29959 ],
               "Distance": 0.131,
               "DurationSeconds": 26
            },
            {
               "StartPosition": [ -123.1201, 49.29959 ],
               "EndPosition":   [ -123.13562, 49.30681 ],
               "Distance": 1.47,
               "DurationSeconds": 238
            },
            {
               "StartPosition": [ -123.13562, 49.30681 ],
               "EndPosition":   [ -123.13693, 49.30615 ],
               "Distance": 0.121,
               "DurationSeconds": 28
            },
            {
               "StartPosition": [ -123.13693, 49.30615 ],
               "EndPosition":   [ -123.13598, 49.29755 ],
               "Distance": 0.97,
               "DurationSeconds": 156
            },
            {
               "StartPosition": [ -123.13598, 49.29755 ],
               "EndPosition":   [ -123.13688, 49.29717 ],
               "Distance": 0.085,
               "DurationSeconds": 15
            },
            {
               "StartPosition": [ -123.13688, 49.29717 ],
               "EndPosition":   [ -123.13375, 49.2926 ],
               "Distance": 0.609,
               "DurationSeconds": 62
            }
         ]
      }
   ],
   "Summary": {
      "RouteBBox": [ -123.13693, 49.2926, -123.1201, 49.30681 ],
      "DataSource": "Here",
      "Distance": 4.223,
      "DurationSeconds": 697,
      "DistanceUnit": "Kilometers"
   }
}
```

# Departure time with Amazon Location
<a name="departure-time"></a>

By default, when you call `CalculateRoute` or `CalculateRouteMatrix`, if you don't provide a departure time in the request, the calculated routes reflects optimal traffic conditions.

You can set a specific a departure time to use live and predictive traffic conditions from your chosen data provider, by using one of the following options:
+ `DepartNow` – When set to *true*, it uses live traffic conditions to calculate the fastest travel path.
+ `DepartureTime` – When provided, it uses predictive and known traffic conditions for the requested time. Defined in the following [format](https://www.iso.org/iso-8601-date-and-time-format.html): `YYYY-MM-DDThh:mm:ss.sssZ`. 

**Example**  
The following `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` request sets the departure time to July 2, 2024, at 12:15:20 UTC.  

```
POST /routes/v0/calculators/ExampleCalculator/calculate/route
Content-type: application/json
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159],
   "WaypointPositions":[
        [-122.1884,48.0936],
        [-122.3493,47.6205]
    ]
    "IncludeLegGeometry": true,
    "DepartureTime": 2024-07-02T12:15:20.000Z,
}
```

# Travel mode with Amazon Location
<a name="travel-mode"></a>

You can set a travel mode when using `CalculateRoute` or `CalculateRouteMatrix`. The mode of travel affects speed of travel and road compatibility. While the default mode of travel is by car, you can specify which mode of travel you're using while traveling along a route with the following optional parameter:
+ `TravelMode` – Specifies the mode of transport when calculating a route, such as: *`Bicycle`*, *`Car`*, *`Motorcycle`*, *`Truck`*, or *`Walking`*.

**Limitations**
+ If you specify `Walking` for the travel mode and your data provider is Esri, the start and destination must be within 40km.
+ `Bicycle` or `Motorcycle` are available only when using Grab as the data provider.
+ Grab provides only `Bicycle` and `Walking` routes in certain cities. For more information, see [Countries/regions and area covered](grab.md#grab-coverage-area).
+ `Truck` is not available when using Grab as the data provider.

**Additional preferences**

If you specify a `TravelMode` of *`Car`*, you can specify additional route preferences with the following optional parameter:
+ `CarModeOptions` – Specifies route preferences when traveling in a car, such as *`AvoidFerries`* or *`AvoidTolls`*.

If you specify a `TravelMode` of *`Truck`*, you can specify additional route preferences with the following optional parameter:
+ `TruckModeOptions` – Specifies route preferences when traveling in a truck, such as *`AvoidFerries`* or *`AvoidTolls`*, in addition to specifying routes that can accommodate the *`TruckDimensions`* and *`TruckWeight`*.

**Example**  
The following `[CalculateRoute](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_CalculateRoute.html)` request specifies *`Truck`* as the mode of travel. Additional route restrictions include: avoiding routes that use ferries and avoiding roads that can't accommodate the truck dimensions and weight.  

```
{
   "DeparturePosition": [-122.7565,49.0021],
   "DestinationPosition": [-122.3394, 47.6159],
   "DepartNow": true,
   "TravelMode": "Truck",
   "TruckModeOptions": { 
      "AvoidFerries": true,
      "AvoidTolls": false,
      "Dimensions": { 
         "Height": 4.5,
         "Length": 15.5,
         "Unit": "Meters",
         "Width": 4.5
      },
      "Weight": { 
         "Total": 7500,
         "Unit": "Pounds"
      }
   }
}
```

# Managing your route calculator resources with Amazon Location
<a name="managing-route-calculators"></a>

You can manage your route calculator resources using the Amazon Location console, the AWS CLI, or the Amazon Location APIs.

## List your route calculator resources
<a name="viewing-route-calculators"></a>

You can view your route calculator list using the Amazon Location console, the AWS CLI, or the Amazon Location APIs:

------
#### [ Console ]

**To view a list of route calculators using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Route calculators** from the left navigation pane.

1. View the route calculator details under **My route calculators**.

------
#### [ API ]

Use the `[ListRouteCalculators](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_ListRouteCalculators.html)` operation from the Amazon Location Routes APIs. 

The following example is an API request to get a list of route calculators in the AWS account. 

```
POST /routes/v0/list-calculators
```

The following is an example response for `[ListRouteCalculators](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_ListRouteCalculators.html)`:

```
{
       "Entries": [ 
          { 
             "CalculatorName": "ExampleCalculator",
             "CreateTime": 2020-09-30T22:59:34.142Z,
             "DataSource": "Esri",
             "Description": "string",
             "UpdateTime": 2020-09-30T23:59:34.142Z
          }
       ],
       "NextToken": "1234-5678-9012"
    }
```

------
#### [ CLI ]

Use the `list-route-calculators` command.

The following example is an AWS CLI to get a list of route calculators in the AWS account. 

```
aws location list-route-calculators
```

------

## Get route calculator details
<a name="get-route-calculator-details"></a>

You can get details about any route calculator resource in your AWS account using the Amazon Location console, the AWS CLI, or the Amazon Location APIs:

------
#### [ Console ]

**To view the details of a route calculator using the Amazon Location console**

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Route calculators** from the left navigation pane.

1. Under **My route calculators**, select the name link of the target route calculator. 

------
#### [ API ]

Use the `[DescribeRouteCalculator](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_DescribeRouteCalculator.html)` operation from the Amazon Location Routes APIs. 

The following example is an API request to get the route calculator details for *ExampleCalculator*.

```
GET /routes/v0/calculators/ExampleCalculator
```

The following is an example response for `[DescribeRouteCalculator](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_DescribeRouteCalculator.html)`:

```
{
       "CalculatorArn": "arn:aws:geo:us-west-2:123456789012:route-calculator/ExampleCalculator",
       "CalculatorName": "ExampleCalculator",
       "CreateTime": 2020-09-30T22:59:34.142Z,
       "DataSource": "Esri",
       "Description": "string",
       "Tags": { 
          "Tag1" : "Value1" 
       },
       "UpdateTime": 2020-09-30T23:59:34.142Z
    }
```

------
#### [ CLI ]

Use the `describe-route-calculator` command.

The following example is an AWS CLI to get the route calculator details for *ExampleCalculator*.

```
aws location describe-route-calculator \
        --calculator-name "ExampleCalculator"
```

------

## Delete a route calculator
<a name="delete-route-calculator"></a>

You can delete a route calculator from your AWS account using the Amazon Location console, the AWS CLI, or the Amazon Location APIs:

------
#### [ Console ]

**To delete a route calculator using the Amazon Location console**

**Warning**  
This operation deletes the resource permanently. 

 

1. Open the Amazon Location console at [https://console.aws.amazon.com/location/](https://console.aws.amazon.com/location/home).

1. Choose **Route calculators** from the left navigation pane.

1. Under **My route calculators**, select the target route calculator. 

1. Choose **Delete route calculator**.

------
#### [ API ]

Use the `[DeleteRouteCalculator](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_DeleteRouteCalculator.html)` operation from the Amazon Location Routes APIs. 

The following example is an API request to delete the geofence collection *ExampleCalculator*.

```
DELETE /routes/v0/calculators/ExampleCalculator
```

The following is an example response for `[DeleteRouteCalculator](https://docs.aws.amazon.com/location-routes/latest/APIReference/API_DeleteRouteCalculator.html)`:

```
HTTP/1.1 200
```

------
#### [ CLI ]

Use the `delete-route-calculator` command.

The following example is an AWS CLI command to delete the geofence collection *ExampleCalculator*.

```
aws location delete-route-calculator \
        --calculator-name "ExampleCalculator"
```

------