

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Amazon Location Service Routes
<a name="routes"></a>

![\[Amazon Location Service Routes 概觀。\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/images/routesV2/route-banner.png)


使用 Amazon Location Service Routes，您可以計算多個起點和終點之間的行程時間和距離、視覺化符合道路的車輛 GPS 追蹤，以及更了解您的可用區域。這有助於降低營運成本並改善客戶體驗。

## 功能
<a name="routes-features"></a>

**規劃路由路徑**  
計算兩個或多個位置之間的路由，並考慮各種因素，例如距離、時間和道路條件。您也可以查看同一組位置的替代路由。

**路由最佳化**  
最佳化時間或距離的路由，選擇最快或最短的路由。您也可以排序航點，以最佳化出遊的銷售人員問題。

**路由分析**  
分析效能指標，例如行程時間、距離或停止次數，以確保路由符合您所需的目標。

**服務區域**  
根據距離或時間限制，定義可從特定位置提供服務的地理區域。

**過路費**  
計算路由上與收費基礎設施相關的成本。

**迴避**  
避開高速公路、通道、鐵道和收費道路，以限制您的路線計算。

**速度限制**  
尋找路由中每個區段的速限，確保驅動程式符合當地法規。

![\[使用 Amazon Location Service 路由功能的應用程式。\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/images/routesV2/route-demo.png)


## 使用案例
<a name="routes-usecases"></a>

**提供有效率的路由和turn-by-turn方向**  
從任何起始位置 （地址、POI 或 GPS 座標） 規劃路由，並計算通往多個目的地的最佳路徑，並考量車輛維度和限制。  
如需詳細資訊，請參閱[計算路由](calculate-routes.md)。

**最佳化交付路由**  
使用航點排序來解決周遊的 Salesman 問題，並計算通往多個目的地的最佳路由，將時間和距離降至最低。  
如需詳細資訊，請參閱[最佳化路徑點](actions-optimize-waypoints.md)。

**確定交付是從最近的倉儲進行**  
使用 Matrix Routing 和 Waypoint Sequencing 來識別從倉儲到每個客戶的最快路由，最大限度地提高效率並最大限度地降低成本。  
如需詳細資訊，請參閱[計算路由](calculate-routes.md)及[計算路由矩陣](calculate-route-matrix.md)。

**改善計程車和共乘分派**  
使用矩陣路由來識別最近的可用車輛，並根據即時流量計算最佳路由。這可確保最接近的車輛有效率地到達客戶，同時提高客戶滿意度和業務生產力。進行更多旅程、節省油費，並提供卓越的服務體驗。  
如需詳細資訊，請參閱[計算路由](calculate-routes.md)、[計算路由矩陣](calculate-route-matrix.md)及[計算等線](calculate-isolines.md)。

**尋找服務區域**  
使用 Isoline 路由，根據時間或距離限制來判斷您業務的地理觸角。這可讓企業識別潛在客戶並制定分派計劃。居家醫療保健供應商可以確保他們有足夠的員工和資源，可在 15 分鐘內聯絡所有患者。Isoline 有助於最佳化服務區域、確保及時交付，以及尋找新設施。  
如需詳細資訊，請參閱[計算等線](calculate-isolines.md)。

**將 GPS 追蹤快照至道路**  
對齊 GPS 追蹤以道路和視覺化車輛移動，確保路線遵循和法規合規。機群管理員可以查看車輛是否保持在計劃的路線上，並識別偏差。確認驅動程式遵循準則、發現效率低下，並確保符合法規。更正 GPS 不準確和變化，並呈現車輛活動的真實檢視。在路由最佳化、驅動程式行為和機群管理方面做出更好的決策。  
如需詳細資訊，請參閱[快照至道路](snap-to-roads.md)。

## API
<a name="routes-apis"></a>

此表格提供用於路由規劃和位置型資料處理的 Amazon Location Service APIs 金鑰概觀。每個 API 都提供獨特的功能，例如計算路由、最佳化航點，以及將 GPS 追蹤貼齊道路，以準確追蹤。


**API**  

| API 名稱 | 描述 | 閱讀更多 | 
| --- | --- | --- | 
| 計算路由 | 計算考量車輛限制和即時流量的起點和多個目的地之間的行駛距離、行駛時間和turn-by-turn方向。 | [計算路由](calculate-routes.md) | 
| 計算路由矩陣 | 計算一組出發點和一組目的地之間的路由距離和時間，並考量即時流量。 | [計算路由矩陣](calculate-route-matrix.md) | 
| 計算等高線 | 根據您的行程模式，識別可在指定時間或距離內到達的地理區域。 | [計算等線](calculate-isolines.md) | 
| 最佳化航點 | 尋找前往多個目的地的有效順序，減少行程時間和距離，同時考慮流量和車輛限制等因素。 | [如何最佳化路由的航點](optimize-waypoints.md) | 
| 快照至道路 | 將 GPS 追蹤與最近的道路區段配對，以提高車輛追蹤和路由視覺化的準確性。 | [快照至道路](snap-to-roads.md) | 

# 路由概念
<a name="routes-concepts"></a>

Amazon Location Service 中的 Routes 概念為規劃和最佳化旅程提供了強大的架構，無論是簡單的導覽還是複雜的物流。路由包含各種元件，例如航點、腿部、步驟和跨度，每個元件都有助於實現路由計算的精細性和靈活性。利用 Routes API，您可以計算行程距離、預估行程時間，以及最佳化多站行程。此外，路由幾何、流量感知、速度限制、通行成本和彈性多線編碼等功能可增強視覺化、分析和操作效率的功能。本節涵蓋術語、最佳實務和詳細使用模式，引導您實作有效的導航、交付、現場服務等路由解決方案。

**Topics**
+ [路由術語](routes-terminology.md)
+ [位置 （來源、目的地、航點和追蹤）](concepts-where.md)
+ [何時 （出發和抵達）](concepts-when.md)
+ [方式 （行程模式、迴避和排除）](concepts-how.md)
+ [流量感知](concepts-traffic-awareness.md)
+ [最佳化路由和航點序列](optimize-route-waypoint.md)
+ [驅動程式排程和通知](driver-schedule-notices.md)

# 路由術語
<a name="routes-terminology"></a>

**路由**  
路由提供從出發位置經過航點位置前往目的地的詳細資訊。其中包括行程距離、行程時間、路線幾何、速限、跨度和其他屬性。

**路由矩陣**  
代表從一組原始伺服器到一組目的地之行程距離和行程時間的矩陣。它可作為路由規劃或最佳化應用程式的輸入。

**Waypoint**  
航點是沿著從出發點到目的地之路由的中繼停止點。路由遵循請求中指定的中途停靠點順序。

**腿部**  
腿部代表路由上兩個連續位置之間的旅程。如果位置是越野，則會移至最近的道路。沒有路徑點的路由包含單一腿。具有一或多個航點的路由有多個分支，每個分支代表從一個航點到下一個。某些腿，例如涉及 ferries 的腿，包含與該腿類型相關的特定資訊。

**步驟**  
步驟是腿部內的客群，提供旅程該部分的摘要詳細資訊。步驟類型包括：  
+ **預設步驟** – 具有人類可讀指示的基本步驟，適用於顯示路由概觀的 Web 應用程式。
+ **Turn-by-Turn步驟** – 適用於turn-by-turn應用程式的詳細步驟，提供精細的指示。
+ **旅程前步驟** – 開始旅程前要完成的步驟。範例：乘船。
+ **旅程後步驟** – 旅程結束後要完成的步驟。範例：取消乘船。

**Span**  
跨度代表道路的連續延伸，共用一組一致的屬性。每當其中一個請求的屬性變更時，就會沿著路由建立新的跨度。

**區段**  
區段是道路的可導航部分，通常表示為線性延伸。

**路由幾何**  
路由幾何描述用於視覺化、分析或其他用途的路由路徑。每個路由分支的幾何可以表示為壓縮、編碼的多邊形或簡單的行字串。

**彈性 Polyline**  
用於表示幾何的精簡編碼多邊形格式。建議用於限制回應大小，並針對用戶端解碼進行最佳化。

**簡易行字串**  
代表幾何的 GeoJSON LineString 格式。此格式會產生較大的回應承載，並且是一組排序的座標，可用於在地圖上繪製路由。

# 位置 （來源、目的地、航點和追蹤）
<a name="concepts-where"></a>

指定路由計算的位置，包括路由開始、結束和中繼停止的位置 （或要傳遞的位置）。


**指定路由計算的位置**  

| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | Snap to Road | 
| --- | --- | --- | --- | --- | --- | --- | 
| Origin(s) | 路由的開始位置。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| Waypoint | 要沿著路由包含的中繼位置。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| 目的地 (s) | 路由的結束位置。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| 追蹤點 | GPS 追蹤，其中包含旅程模式發出的歷史位置資訊。這些位置包括裝置無法發出或記錄此資訊時的典型 GPS 不準確和差距。 | 否 | 否 | 否 | 否 | 是，具有 選項 | 

## 可設定的選項
<a name="configurable-options"></a>

提供選項來自訂路徑點、原始伺服器和目的地的路由行為。

**航點選項**


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| AvoidActionsForDistance | 避免對提供的距離採取動作。通常用於確保驅動程式有足夠的時間在接近航點時做出決策。 | 是 | 否 | 否 | 否 | 否 | 
| AvoidUTurns | 指定是否允許在路徑點迴轉。 | 是 | 否 | 否 | 否 | 否 | 
| 標題 | GPS 標題位於航點位置。 | 是 | 否 | 否 | 是 | 否 | 
| 相符 | 設定符合道路網路所提供位置的選項。 | 是，具有 選項 | 否 | 否 | 否 | 否 | 
| SideOfStreet | 指定要符合航點位置的街道邊。 | 是，具有 選項 | 否 | 否 | 是，具有 選項 | 否 | 
| StopDuration | 在航點位置停止的持續時間。 | 是 | 否 | 否 | 否 | 否 | 
| Position | 航點的經度和緯度。 | 是 | 否 | 否 | 是 | 否 | 
| PassThrough | 決定路徑點是否應視為停止或傳遞。 | 是 | 否 | 否 | 否 | 否 | 
| Id | 航點的識別符字串。 | 否 | 否 | 否 | 是 | 否 | 
| AccessHours | 指定造訪目的地的存取時數。 | 否 | 否 | 否 | 是 | 否 | 
| AppointmentTime | 排定的預約時間，位於航點。 | 否 | 否 | 否 | 是 | 否 | 
| ServiceDuration | 路線點的服務時間，例如預約的持續時間。 | 否 | 否 | 否 | 是 | 否 | 
| 之前 | 定義在此路徑點之後必須造訪哪些路徑點。 | 否 | 否 | 否 | 是 | 否 | 

**原始伺服器選項**


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| AvoidActionsForDistance | 避免對提供的距離採取動作。 | 是 | 是 | 是 | 否 | 否 | 
| AvoidUTurns | 指定原始伺服器是否允許 U 轉。 | 是 | 否 | 否 | 否 | 否 | 
| 標題 | 原始位置的 GPS 標題。 | 是 | 是 | 是 | 否 | 否 | 
| 相符 | 將原始位置與道路網路相符的選項。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 否 | 
| SideOfStreet | 指定要符合原始位置的街道邊。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 否 | 
| Id | 原始伺服器的識別符字串。 | 否 | 否 | 是 | 否 | 否 | 

**目的地選項**


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| AvoidActionsForDistance | 避免對目的地提供的距離採取動作。 | 是 | 是 | 是 | 否 | 否 | 
| AvoidUTurns | 指定目的地是否允許 U 轉。 | 是 | 否 | 否 | 否 | 否 | 
| 標題 | 目的地位置的 GPS 標題。 | 是 | 是 | 是 | 是 | 否 | 
| 相符 | 將目的地位置與道路網路相符的選項。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 否 | 
| SideOfStreet | 指定要符合目的地位置的街道邊。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| StopDuration | 在目的地中停止的持續時間。 | 是 | 否 | 否 | 否 | 否 | 
| Id | 目的地的識別符字串。 | 否 | 否 | 是 | 否 | 否 | 
| AccessHours | 指定造訪目的地的存取時數。 | 否 | 否 | 是 | 否 | 否 | 
| AppointmentTime | 目的地的排程預約時間。 | 否 | 否 | 是 | 否 | 否 | 
| ServiceDuration | 目的地的服務時間，例如預約的持續時間。 | 否 | 否 | 是 | 否 | 否 | 

# 何時 （出發和抵達）
<a name="concepts-when"></a>

指定路由計算的時間。時間不僅會決定離開和抵達的時間戳記，也會影響要使用的流量資料。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 離開時間 | 從原始伺服器出發的時間。如果未提供抵達或離開時間，則不會使用動態流量資訊，只會根據歷史流量套用自由流動速度。 | 是 | 是 | 是 | 是 | 否 | 
| 立即離開 | 使用目前時間作為從原始伺服器出發的時間。 | 是 | 是 | 是 | 否 | 否 | 
| 抵達時間 | 抵達目的地的時間。如果未提供抵達或離開時間，則不會使用動態流量資訊，只會根據歷史流量套用自由流動速度。 | 是 | 否 | 是 | 否 | 否 | 

# 方式 （行程模式、迴避和排除）
<a name="concepts-how"></a>

使用下列選項來指定用於路由計算的 行程模式和相關功能。

**行程模式選項**

指定計算路由時的傳輸模式。此設定會影響預估的行駛速度、道路相容性，以及在需要時可能使用 ferries。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| Car | 汽車行駛模式。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是 | 是 | 
| Scooter | Scooter 行程模式。 | 是，具有 選項 | 是 | 是，具有 選項 | 是 | 是 | 
| 行人 | 步行模式。 | 是，具有 選項 | 是 | 是 | 是，具有 選項 | 是 | 
| 卡車 | 卡車行駛模式。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 

**迴避、排除和允許選項**

決定在路由計算期間是否應包含、排除或避免特定功能集。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 迴避 | 在最佳情況下避免的功能。如果路由器找不到有效的路由，則會忽略迴避，且通知會指出無法遵守迴避。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| 排除 | 嚴格排除的功能。如果路由器找不到具有排除選項的有效路由，則不會傳回任何路由。 | 是，具有 選項 | 是，具有 選項 | 否 | 否 | 否 | 
| 允許 | 需要明確啟用的功能。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 

**迴避清單**

列出在最佳情況下避免的功能。如果路由器找不到有效的路由，則會忽略迴避，且通知會指出無法遵守迴避。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 區域 | 要避免的區域，但有例外。 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 是，具有 選項 | 否 | 
| 受控存取高速公路 | 進入點有限的高速道路。 | 是 | 是 | 是 | 是 | 否 | 
| 汽車接駁列車 | 訓練透過通道傳輸車輛。 | 是 | 是 | 是 | 否 | 否 | 
| 泥土道路 | 具有自然表面的未鋪設道路。 | 是 | 是 | 是 | 是 | 否 | 
| 摩天輪 | 跨水體運送車輛的船 | 是 | 是 | 是 | 否 | 否 | 
| 船舶法利 | 鐵道在軌道上運輸車輛。 | 否 | 否 | 是 | 是 | 否 | 
| Rail 摩天輪 | 鐵道在軌道上運輸車輛。 | 否 | 否 | 是 | 是 | 否 | 
| 季節性關閉 | 在某些季節關閉道路。 | 是 | 否 | 是 | 否 | 否 | 
| 通道 | 用於車輛流量的地底通道。 | 是 | 是 | 是 | 是 | 否 | 
| 過路費 | 需要付費才能存取的道路。 | 是 | 是 | 是 | 是 | 否 | 
| 過路費收發器 | 避免收費收發器是唯一付款方式的道路。 | 是 | 否 | 是 | 否 | 否 | 
| U-Turns | 允許車輛反向旋轉的點。 | 是 | 是 | 是 | 是 | 否 | 
| 區域類別 | 要避免的區域類別。 | 是 | 是 | 是 | 否 | 否 | 

**排除項目清單**

列出嚴格排除的功能。如果路由器找不到具有排除選項的有效路由，則不會傳回任何路由。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 國家/地區 | 國家/地區代碼 2 或國家/地區代碼 3，適用於應嚴格排除在路由計算之外的國家/地區。 | 是 | 是 | 否 | 是 | 否 | 

**允許清單**

列出需要明確啟用才能計算路由的功能。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| HOV | 啟用使用高乘載車輛車道進行路線計算。 | 是 | 是 | 是 | 否 | 否 | 
| HOT | 啟用使用高佔用收費通道進行路由計算。 | 是 | 是 | 是 | 否 | 否 | 

# 流量感知
<a name="concepts-traffic-awareness"></a>

決定路由計算期間使用的流量相關資訊類型。流量代表擁塞，不包括與長期事件相關的擁塞。流量資料的準確性會隨著時間降低，讓過去事件的歷史流量資料更可靠。


| 參數 | 描述 | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照到道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 用量 | 在路由計算期間啟用或停用流量資料。啟用時，如果`DepartNow`未提供 `ArrivalTime`、 `DepartureTime`或 ，則只會考慮長期關閉。否則，如果提供時間，則會考慮所有流量資料。 | 是 | 是 | 是 | 是 | 否 | 
| FlowEventThresholdOverride | 流量事件視為有效的持續時間，以秒為單位。有效時，流量資料會用於歷史流量資料。 | 是 | 是 | 是 | 否 | 否 | 

# 最佳化路由和航點序列
<a name="optimize-route-waypoint"></a>

## 最佳化路由
<a name="optimize-routing"></a>

計算路由時的最佳化條件。這可以是按時間測量的最快路由，也可以是按距離測量的最短路由。


| 選項 | 描述 | 測量 | 
| --- | --- | --- | 
| 最快的路由 | 計算最快的路線，專注於將行程時間降至最低。這會將流量條件、道路速度限制和其他因素納入考量。 | 時間 | 
| 最短路由 | 計算最短的路由，將行駛距離降至最低。這通常在距離是關鍵因素時使用，例如降低燃料成本或排放量。 | 距離 | 

## 最佳化航點
<a name="optimize-waypoint"></a>

路由中排序航點的最佳化條件。

# 驅動程式排程和通知
<a name="driver-schedule-notices"></a>

## 驅動程式排程
<a name="driver-schedule"></a>

定義工作和休息排程的驅動程式設定。這對許多司法管轄區來說是強制性的。


| 參數 | Description | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照至道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 自訂休息週期 | 由磁碟機持續時間定義的休息週期，後續為休息持續時間。可以提供任何數量的此類週期。 | 是，具有 選項 | 否 | 否 | 否 | 否 | 
| 長休息週期和短休息週期 | 由短週期和長週期定義的休息週期。短暫的磁碟機持續時間後接短期的磁碟機持續時間。短磁碟機可以重複執行，直到達到長磁碟機持續時間，此時會強制執行長休息持續時間。 | 否 | 否 | 否 | 是，具有 選項 | 否 | 

## 通知、警告和限制條件
<a name="notices-warnings-constraints"></a>

補充資訊，可讓您深入了解在路由計算期間所做的決策。


| 參數 | Description | 路由 | 路由矩陣 | 同軸 | 最佳化航點 | 快照至道路 | 
| --- | --- | --- | --- | --- | --- | --- | 
| 注意 | 有關路由計算的通知。此外，還可能包括通知的影響，指出是否可以按原狀使用路由計算的結果，或在使用前需要手動檢查。 | 是，含詳細資訊 | 否 | 否 | 否 | 是 | 
| FailedConstraints | 請求中提供但無法滿足的限制，導致最佳化問題失敗。 | 否 | 否 | 否 | 是，含詳細資訊 | 否 | 

# 路由 APIs
<a name="choose-routes-apis"></a>

Routes 提供計算位置之間最佳化路徑的功能。這些功能支援需要物流規劃、距離計算和路由最佳化的應用程式。使用者也可以將位置點貼齊道路，以提高準確性。如需詳細資訊，請參閱 [Amazon Location Service Routes](routes.md)。
+ **CalculateIsolines**：根據行程時間或距離產生等線，有助於定義服務區域或可到達性區域。如需詳細資訊，請參閱 [計算等線](calculate-isolines.md)。
+ **CalculateRouteMatrix**：提供多個原始伺服器和目的地之間的距離和行程時間的矩陣，支援物流和行程規劃。如需詳細資訊，請參閱 [計算路由矩陣](calculate-route-matrix.md)。
+ **CalculateRoutes**：計算point-to-point或多站導覽的最佳化路由，包括可自訂的路由偏好設定。如需詳細資訊，請參閱 [計算路由](calculate-routes.md)。
+ **OptimizeWaypoints**：最佳化最有效率行程路線的航點順序，將距離或時間降至最低。如需詳細資訊，請參閱[最佳化路徑點](actions-optimize-waypoints.md)。
+ **SnapToRoads**：將座標對齊最近的道路，透過將點貼齊已知道路來提高 GPS 準確性。如需詳細資訊，請參閱[快照至道路](snap-to-roads.md)。

下表提供許多使用 Routes APIs 最佳解決的業務使用案例。


| **業務需求** | **有用的 API** | **範例** | 
| --- | --- | --- | 
| **計算原始伺服器和目的地的行駛距離和時間**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找原始伺服器和目的地的路由多軸 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找原始伺服器和目的地的路由輪流方向**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **立即離開以尋找路由**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **如果您在特定時間出發，請尋找路線**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **如果您需要在特定時間抵達，請尋找路線**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找最短路由 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找最快的路由 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找替代路由**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找流量感知路由 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **尋找迴避的路線，例如過路費、u-turn、船、高速公路、通道等 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **透過傳遞多邊形或多邊形，尋找具有自訂迴避的路由**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **計算過路費 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` | [計算過路費](calculate-toll-cost.md) | 
| **尋找路線上道路跨度的速限 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRoutes` |  | 
| **在地圖上繪製路由**支援航點標記。 | `GetTile` 和 `GetStyleDescriptor` 搭配轉譯引擎 (MapLibre) 搭配計算路由  |  | 
| **計算多個原始伺服器和目的地的距離和時間的路由矩陣**支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRouteMatrix` | [如何計算多個原始伺服器和目的地的距離和時間的路由矩陣](calculate-route-matrix-distance.md) | 
| **計算具有迴避的路由矩陣 **支援以下項目：[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/choose-routes-apis.html) | `CalculateRouteMatrix` | [如何計算具有迴避的路由矩陣](calculate-route-matrix-with-avoidance.md) | 
| **根據時間計算服務區域 （異色系）**支援旅行模式，例如卡車、行人、汽車和摩托車。 | `CalculateIsolines` | [如何根據時間範圍計算服務區域](calculate-service-area-based-on-time.md) | 
| **根據距離 （距離） 計算服務區域**支援旅行模式，例如卡車、行人、汽車和摩托車。 | `CalculateIsolines` |  | 
| **計算可避免的服務區域**支援旅行模式，例如卡車、行人、汽車和摩托車。 | `CalculateIsolines` |  | 
|  **從反向計算服務區域** 支援旅行模式，例如卡車、行人、汽車和摩托車。  | `CalculateIsolines` |  | 
|  **計算多範圍時間或距離的服務區域** 支援旅行模式，例如卡車、行人、汽車和摩托車。  | `CalculateIsolines` |  | 
| **最佳化路由的路徑點 （周遊銷售人員問題）** 支援旅行模式，例如卡車、行人、汽車和摩托車。  | `OptimizeWaypoint` | [如何最佳化路由的航點](optimize-waypoints.md) | 
| **最佳化具有流量感知的路由路徑點 ** 支援旅行模式，例如卡車、行人、汽車和摩托車。  | `OptimizeWaypoint` |  | 
| **最佳化具有存取小時感知的路由路徑點** 支援旅行模式，例如卡車、行人、汽車和摩托車。 | `OptimizeWaypoint` |  | 
| **將 GPS 追蹤與道路網路配對 **支援旅行模式，例如卡車、行人、汽車和摩托車。 | 貼齊道路  | [如何將 GPS 追蹤比對至道路網路](how-to-match-gps-traces.md) | 
| **在地圖上視覺化相符的 GPS 追蹤 **支援旅行模式，例如卡車、行人、汽車和摩托車。 | `GetStyleDescriptor` 搭配 Snap to road 的轉譯引擎 (MapLibre)  |  | 

# 計算路由
<a name="calculate-routes"></a>

Routes API 會計算兩個或多個位置之間的路由，無論是否具有車輛、卡車、摩托車和行人等不同旅行模式的迴避。使用此 API，您可以自訂路由選項並請求其他路由相關資訊，以滿足特定需求。此 API turn-by-turn導覽，並透過套用參數來自訂路由計算，例如避開收費道路、高速公路或鐵道。API 也會傳回速限和過路費。

如需詳細資訊，請參閱《*Amazon Location Service API 參考*》中的 [CalculateRoutes](https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRoutes.html)。

如需此 API 的請求、回應、cURL 和 CLI 命令範例，請參閱[如何使用計算路由](https://docs.aws.amazon.com/location/latest/developerguide/calculate-routes-how-to.html)。

![\[Amazon Location Service Routes 概觀。\]](http://docs.aws.amazon.com/zh_tw/location/latest/developerguide/images/routesV2/P2P-Turn-by-turn-navigation.gif)


## 使用案例
<a name="use-cases"></a>
+ 在**路由圖上顯示地理詳細資訊：**使用進階映射功能，透過豐富的地理資訊視覺化詳細的路由，包括地標、地形和城市基礎設施。透過允許使用者檢視從起點到目的地的明確路由，增強決策能力。此功能可以支援導航、規劃和各種物流案例，並顯示交通模式的路線，例如汽車、卡車、機車和行人。透過新增躲避或過路費計算等元素來自訂路由。
+ **turn-by-turn導覽：**在 Web 和行動裝置上提供無縫導覽支援。使用者可以turn-by-turn方向，確保有效率的旅程。兩個平台都可以利用導覽指示來提供個人或商務旅遊的路由，包括速度限制。
+ **沿著路線計算過路費：**將過路費計算納入路線規劃，為包含過路費、橋樑或通道的路線提供準確的定價預估。預先顯示過路費，以協助駕駛和規劃人員做出符合成本效益的決策，並在必要時避免過路費。
+ **確保符合速限：**整合速限資料，以協助駕駛人保持在法律限制內，降低罰款風險並提升更安全、省油的駕駛。物流和機群管理也可以透過即時監控速度合規來受益。
+ **協助貨運和車輛路由解決方案：**將路由、導航和追蹤功能整合到物流入口網站，簡化貨運和車輛路由操作。有效率地規劃多個交付的路由、即時追蹤貨物，以及透過更好的路由管理燃料成本。

## 了解請求
<a name="understanding-request"></a>

**注意**  
 對於 `ap-southeast-1`和 中的客戶`ap-southeast-5`，支援的請求和回應欄位可能會有所不同。如需詳細資訊，請參閱 [CalculateRoutes API 參考](https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRoutes.html)。

請求需要 `Origin`和 `Destination` 參數，而 `Allow`、 `Avoid`和 等選用參數可`Traffic`自訂路由以滿足特定需求和限制。

**來源**  
路由的開始位置，以經度和緯度表示。

**目的地**  
路由的結束位置。

**航點**  
要沿著開始和結束位置之間的路由包含的中繼位置。

**OptimizeRoutingFor**  
路由的最佳化條件，例如最快或最短。

**LegGeometryFormat**  
每個路由分支傳回的幾何格式。

**避免**  
在路由計算期間要避免的功能，如果找不到替代路由則忽略。

**流量**  
影響路由計算的流量相關選項。

**過路費**  
影響路由計算和過路費的過路費相關選項。

**LegAdditionalFeatures**  
可在旅程中每個區段的回應中啟用的功能。

**SpanAdditionalFeatures**  
可在旅程中每個區段的回應內啟用的跨度功能。

## 了解回應
<a name="understanding-response"></a>

回應提供路由詳細資訊，例如旅程的腿部、關於路由計算的通知，以及包含距離和持續時間的摘要資訊。

**路由**  
包含腿部和相關聯屬性的路由陣列。

**注意**  
有關路由的警告或資訊訊息。

**LegGeometryFormat**  
指定路由幾何的格式。

### 腿部詳細資訊
<a name="leg-details"></a>

視傳輸模式而定，旅程的每個區段可以是 Ferry、Pedestrian 或 Vehicle 類型。雖然每個腿都包含與傳輸模式無關的屬性，但您可以在以下位置找到特定屬性：

**FerryLegDetails**  
腿部的 Ferry 特定屬性。

**VehicleLegDetails**  
腿部的車輛特定屬性。

**PedestrianLegDetails**  
腿部的行人特定屬性。

### 步驟
<a name="steps"></a>

旅程的每個部分都分為步驟，說明路由部分的動作。步驟可以是預設，適用於基本應用程式，也可以是 TurnByTurn，適用於turn-by-turn導覽。每個步驟都包含與步驟類型無關的屬性，例如持續時間和距離，以及 ExitStepDetails 等其他特定屬性，這些屬性僅適用於結束步驟。

**BeforeTravelSteps**  
開始旅程之前要執行的步驟。

**TravelSteps**  
在旅程中執行的步驟。

**AfterTravelSteps**  
完成旅程後要執行的步驟。

### 範圍
<a name="spans"></a>

旅程的每個區段都可以分割為跨度。跨度是腿部的一部分，對於一組請求的 具有相同的值`SpanAdditionalFeatures`。範圍除以道路屬性，例如 `SpeedLimit`、道路名稱或區域。傳回的跨度可用來視覺化道路屬性和存取相關資訊。

# 計算過路費
<a name="calculate-toll-cost"></a>

本主題提供與計算過路費相關的欄位和定義的概觀。使用這些欄位，您可以指定付款方式、貨幣和車輛特性等參數，以自訂過路費計算。


| 欄位名稱 | 路由 | 
| --- | --- | 
| 轉換器 | 是，具有 選項 | 
| Vignette | 是，具有 選項 | 
| 貨幣 | 是，具有 選項 | 
| EmissionType | 是，具有 選項 | 
| VehicleCategory | 是，具有 選項 | 

## 定義
<a name="definitions"></a>

本節提供用於過路費計算的每個欄位的簡短定義。

****轉換器****  
收發器是過路費的付款方式，與其他付款方式相比，可能產生不同的價格。

****Vignette****  
短片是一種道路定價形式。當使用者擁有必要的短片時，不需要額外的過路費。

****貨幣****  
回報過路費的貨幣。除了本地貨幣之外，還包含轉換後的貨幣，這也會影響回應中過路費摘要中使用的貨幣。

****EmissionType****  
車輛的排放類型，用於根據車輛排放計算過路費。

****VehicleCategory****  
用於過路費計算的車輛子類別。

# 了解路由步驟
<a name="understanding-route-steps"></a>

本節定義完成旅程所需的各種動作和步驟。路由步驟因行程模式而異，並提供概觀應用程式和詳細turn-by-turn導覽的指引。

## 路由步驟概觀
<a name="route-steps-overview"></a>

以下類型的路由步驟定義完成路由分支所需的動作，因行程模式和行程階段而異。


| **Step type (步驟類型)** | **Description** | 
| --- | --- | 
| Default steps | 提供人類可讀指示的基本步驟，通常用於 Web 型應用程式，以提供路由的概觀。 | 
| Turn by turn steps | 建立turn-by-turn導覽應用程式的詳細步驟，提供更精細的方向。 | 
| Before travel steps | 開始行程區段之前需要完成的步驟，例如乘船。 | 
| After travel steps | 行程區段完成後要執行的步驟，例如下船。 | 

## 依行程模式分類的步驟明細
<a name="route-step-types"></a>


| **區段** | **Step (步驟)** | **行前** | **行程** | **旅行後** | 
| --- | --- | --- | --- | --- | 
| 車輛 | 抵達 | 否 | 是 | 否 | 
| 車輛 | Continue | 否 | 是 | 否 | 
| 車輛 | ContinueHighway | 否 | 是 | 否 | 
| 車輛 | 離開 | 否 | 是 | 否 | 
| 車輛 | Exit(退出) | 否 | 是 | 否 | 
| 行人 | 抵達 | 否 | 是 | 否 | 
| 行人 | 費用 | 否 | 是 | 否 | 
| 船舶 | 等候 | 否 | 否 | 是 | 
| 船舶 | 電路板 | 是 | 否 | 否 | 
| 船舶 | 下機 | 否 | 否 | 是 | 

# 計算路由矩陣
<a name="calculate-route-matrix"></a>

矩陣路由服務會計算路由矩陣，提供多個原始伺服器和目的地之間的行程時間或距離。此服務提供彈性的自訂選項，可讓您指定行程模式、流量條件和其他路由參數。矩陣計算的大小和形狀可能有所不同，同時支援正方形和非正方形矩陣，並容納動態或自由流動流量資料。

如需詳細資訊，請參閱《*Amazon Location Service API 參考*》中的 [CalculateRouteMatrix](https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRouteMatrix.html)。

如需此 API 的請求、回應、cURL 和 CLI 命令範例，請參閱[如何使用計算路由矩陣](https://docs.aws.amazon.com/location/latest/developerguide/calculate-route-matrix-how-to.html)。

## 使用案例
<a name="route-matrix-use-cases"></a>
+ **最佳化物流和電子商務的交付路由：**有效率地計算多個取件和交付地點之間的行程時間和距離，以最佳化路由。物流公司可以使用此功能，透過規劃跨城市的高效路徑，將成本和交付時間降至最低。它非常適合為當日或次日服務設定最佳化交付時段，並規劃多站交付路由。
+ **在共乘應用程式中比對駕駛和乘客：**透過尋找位置之間的最快路線，使用路由計算來比對駕駛與最接近乘客。共乘應用程式可以透過提供即時駕駛人抵達估計來增強使用者體驗，確保快速取件和下車。支援各種運輸模式，例如汽車、自行車和機車。
+ **規劃和最佳化機群管理的路由：**透過最佳化路由來管理大型機群，以減少油耗和行駛時間。機群管理員可以將最有效率的路由指派給多個停靠站的車輛，從而提高整體營運效率。使用案例包括服務機群、運輸公司和公用程式，其中最佳路由規劃對於網站造訪至關重要。

## 了解請求
<a name="route-matrix-request"></a>

**注意**  
 對於 `ap-southeast-1`和 中的客戶`ap-southeast-5`，支援的請求和回應欄位可能會有所不同。如需詳細資訊，請參閱 [CalculateRouteMatrix API 參考](https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateRouteMatrix.html)。

請求包含路由計算的**原始**伺服器和**目的地**，以及根據偏好設定和限制條件量身打造矩陣的選用參數。如需詳細資訊，請參閱計算路由矩陣 API 的 API 參考。
+ `Origins`：以經度和緯度表示的原始座標清單。
+ `Destinations`：目的地座標的清單。
+ `OptimizeRoutingFor`：最佳化條件，例如 "Fastest" 或 "Shortest" 路由。
+ `RoutingBoundary`：定義要計算的邊界，可以是「無限制」或限制在特定幾何。
+ `Avoid`：在路由計算期間要避免的功能。如果找不到可行的路由，則忽略。
+ `Traffic`：與流量相關的選項會影響路由計算。

## 了解回應
<a name="route-matrix-response"></a>

回應包含原始伺服器和目的地之間計算路由的矩陣，以及距離和持續時間等詳細資訊。如果適用，也會提供路由的錯誤和界限。如需計算路由矩陣 API 的其他詳細資訊，請參閱 API 參考。
+ `RouteMatrix`：包含原始伺服器與目的地之間的行程距離 （以公尺為單位） 和持續時間 （以秒為單位） 的矩陣。
+ `ErrorCount`：在路由計算期間遇到的錯誤數目。
+ `RoutingBoundary`：計算矩陣的邊界。

# 計算等線
<a name="calculate-isolines"></a>

計算等線 API 可讓您判斷可在指定時間或距離限制內到達的區域。透過考慮道路限制、交通條件和旅行模式等因素，它會產生概述可存取區域的等線，支援城市規劃、物流和服務可存取性應用程式。此 API 可透過在設定的時間範圍或距離限制內視覺化服務範圍、運輸選項或資源，用於城市規劃、房地產分析和可存取性研究。透過在地圖上顯示這些等線，使用者可以評估在特定限制範圍內的行程觸角，增強網站選擇、服務涵蓋範圍和資源配置的決策。

如需詳細資訊，請參閱《*Amazon Location Service API 參考*》中的 [CalculateIsolines](https://docs.aws.amazon.com/location/latest/APIReference/API_CalculateIsolines.html)。

如需此 API 的請求、回應、cURL 和 CLI 命令範例，請參閱[如何使用計算等線](https://docs.aws.amazon.com/location/latest/developerguide/calculate-isolines-how-to.html)。

## 使用案例
<a name="use-cases"></a>
+ **透過行程時間等線評估醫療保健可存取性：**產生等線，根據行程時間評估從各個鄰里對醫療保健設施的存取。醫療保健組織可以使用此功能來識別服務不足的區域，並對診所位置或行動健康服務做出明智的決策，從而改善社群醫療保健存取。
+ **使用行程時間等線分析零售擴展的市場觸角：**建立等線，以根據行程時間代表客戶對零售據點的存取。零售企業可以使用這些視覺化以策略方式擴展和最佳化銷售潛力，來評估新商店位置並了解客戶人口統計特性。
+ **使用等線最佳化物流和交付區域：**產生等線，根據時間敏感的物流需求定義交付區域。物流公司可以從分發中心將可在特定時間範圍內到達的區域視覺化，改善路線規劃、營運效率和及時交付。
+ **使用等線規劃旅遊和娛樂存取：**將旅遊景點到附近住所的旅遊時間視覺化。旅遊局可以透過在地圖上顯示這些等線，協助旅客找到方便的住宿選項、提升當地企業和提升旅遊體驗。
+ **透過等化線改善緊急回應規劃：**產生等化線，以評估從緊急服務位置到社群中各種區域的回應時間。緊急管理團隊可以在關鍵回應時間內識別區域，最佳化資源配置以改善事件期間的回應。
+ **使用等線分析人力資源規劃的換行模式：**產生等線以視覺化換行時間，並識別高行程時間的區域。企業可以將這些洞見用於遠端工作政策或辦公室重新定位，以提高員工滿意度和生產力。

## 了解請求
<a name="understanding-request"></a>

請求接受參數，例如 `Origin`、 `Destination`和 `Thresholds`來定義等高線。選用參數，例如 `Allow`、 `Avoid`和 `TravelModeOptions`，允許自訂同軸限制。如需更多資訊，請參閱。

**來源**  
以經度和緯度計算等線的起點。

**閾值**  
用於定義等線界限的時間或距離限制。

**TravelMode**  
運輸模式，例如汽車、行人或卡車。

**OptimizeIsolineFor**  
最佳化條件，例如準確性、平衡或快速計算。

**DepartureTime**  
如果指定了用於計算時間相依同軸線的離開時間。

**ArrivalTime**  
抵達時間，如果指定的話，用於計算時間相依的同軸線。

**IsolineGranularity**  
等線邊界的點數和解析度上限。

## 了解回應
<a name="understanding-response"></a>

回應包含具有屬性的等線，例如 `IsolineGeometryFormat`，根據請求參數概述可觸及區域。

**等線**  
計算具有相關聯屬性的同軸線，包括幾何和連線。

**幾何**  
概述計算的同軸邊界的幾何清單。

**連線**  
等線幾何之間的連線，包括每個連線的幾何。

# 最佳化路徑點
<a name="actions-optimize-waypoints"></a>

最佳化航點 API 會計算最有效率的序列，以沿著路由造訪多個航點。使用進階演算法，此 API 可將行程時間和距離降至最低，同時考慮流量條件、迴避和車輛規格等因素。整合最佳化航點 API 可協助企業簡化操作、減少油耗、提高交付效率並改善客戶滿意度。API 提供最佳化路由，在多站行程案例中實現更好的決策和資源配置。

如需詳細資訊，請參閱《*Amazon Location Service API 參考*》中的 [OptimizeWaypoints](https://docs.aws.amazon.com/location/latest/APIReference/API_OptimizeWaypoints.html)。

如需此 API 的請求、回應、cURL 和 CLI 命令範例，請參閱[如何使用最佳化航點](https://docs.aws.amazon.com/location/latest/developerguide/optimize-waypoints-how-to.html)。

## 使用案例
<a name="use-cases"></a>
+ **增強多站交付效率：**有效率地最佳化多個交付停止的序列，以減少行程時間和成本。交付服務可以透過計算最有效率的駕駛路線、將油費降至最低並確保及時交付來簡化操作，從而提高客戶滿意度和營運效率。
+ **簡化現場服務操作：**最佳化一天內多個任務站點的造訪順序，減少現場服務技術人員的周遊時間。這可讓公司每天完成更多任務，提高生產力和服務交付。
+ 為**旅行社規劃有效率的導覽路線：**最佳化包含多個景點的行程，以最大化觀光，同時將行程時間降至最低。旅行社可以使用此功能為導覽行程建立最佳計劃，透過更好地利用可用時間來增強整體旅遊體驗。
+ **改善乘車共享駕駛效率：**最佳化多個乘客的上車和下車序列，減少等待時間並增強乘車體驗。共乘服務可以最大化駕駛收益，並透過最佳化航點確保為乘客提供及時的服務。
+ **最佳化垃圾收集服務的路由：**規劃垃圾收集路由，以將行程距離和時間降至最低，這有助於垃圾管理公司簡化操作並確保及時收集、節省成本並減少環境影響。
+ **協調活動和會議的物流：**管理運輸物流，以將設備和用品交付到多個場地，最佳化載入和卸載路由。這可讓事件規劃器簡化運輸、減少延遲，並確保事件的物料及時送達。
+ **增強緊急回應路由：**規劃通往多個緊急狀況的最快路由，在關鍵情況下最佳化回應時間。緊急服務可以改善回應效率，使用最佳化的航點可能可以節省生命。
+ **促進現場代表的銷售路線規劃：**為每天造訪多個客戶的銷售代表最佳化路線、將旅遊時間降至最低，並將客戶造訪次數最大化。這有助於公司提高生產力，並利用更多的銷售機會。

## 了解請求
<a name="understanding-request"></a>

請求需要 `Origin`和 等參數`Waypoints`，才能計算最佳化序列。選用參數，例如 `Avoid`、 `Traffic`和 `Driver` 允許其他自訂。

**航點**  
要依序最佳化的路徑點清單。

**來源**  
用於最佳化之路由的起始位置。

**目的地**  
用於最佳化之路由的選用結束位置。

**OptimizeSequencingFor**  
排序最佳化的條件，例如最快或最短的路由。

**流量**  
流量相關選項會影響路由計算。

**驅動程式**  
驅動程式的工作和休息週期，以確保符合區域駕駛法規。

**叢集**  
叢集可讓您指定如何叢集附近的路徑點，以改善最佳化的序列。

每個航點也可以指定必須滿足的限制條件，例如 `AppointmentTime`、 `AccessHours`和排序限制條件，例如`Before`另一個航點。

## 了解回應
<a name="understanding-response"></a>

回應提供最佳化航點序列的詳細資訊，包括 `OptimizedWaypoints`和旅程的整體 `Distance`和 `Duration` 。

**OptimizedWaypoints**  
依其最佳化順序排列的路徑點清單。

**ImpedingWaypoints**  
防止最佳化序列的航點，包括未滿足的失敗限制條件。

**連線**  
路線點之間行程的詳細資訊，包括距離和持續時間。

**TimeBreakdown**  
路由的總 `Travel`、`Service`、 `Rest`和 `Wait`持續時間明細。

**ClusterIndex**  
與航點相關聯的叢集索引。只有在處理請求時執行叢集時，才會在回應中包含索引。

# 快照至道路
<a name="snap-to-roads"></a>

Snap to Road API 透過將 GPS 座標對齊數位地圖上最近的道路區段，增強地理定位的準確性。此 API 會取得通常從行動裝置或車輛收集的原始經度和緯度資料，並「快照」指向對應的道路網路，以修正 GPS 偏離或訊號遺失所造成的不正確。透過整合 Snap to Road API，您可以確保應用程式提供可靠且準確的資料，在各種情況下支援更好的決策和營運效率。

如需詳細資訊，請參閱《*Amazon Location Service API 參考*》中的 [SnapToRoads](https://docs.aws.amazon.com/location/latest/APIReference/API_SnapToRoads.html)。

如需此 API 的請求、回應、cURL 和 CLI 命令範例，請參閱[如何使用 Snap to Roads](https://docs.aws.amazon.com/location/latest/developerguide/snap-to-roads-how-to.html)。

## 使用案例
<a name="use-cases"></a>
+ 透過**貼齊道路網路來提高導航準確性：**有效率地將 GPS 座標對齊最近的道路區段，以提高導航準確性。此功能對於映射和導航服務非常有用，可為使用者提供精確的方向和即時位置更新，從而增強導航體驗。
+ **改善機群管理應用程式的資料準確性：**將車輛 GPS 座標貼齊最近的道路，以更正報告的車輛位置。在機群管理系統中，此功能可確保準確的車輛追蹤，實現最佳化的物流和更佳的操作效率。

## 了解請求
<a name="understanding-request"></a>

請求需要與道路`TracePoints`相符，並搭配選用參數，例如 `SnappedGeometryFormat`和 `SnapRadius`來控制幾何格式和貼齊半徑。

**TracePoints**  
要貼齊道路網路的座標清單。

**SnappedGeometryFormat**  
傳回幾何的格式，例如「FlexiblePolyline」或「Simple」。

**SnapRadius**  
考量道路貼齊的追蹤點周圍半徑。

## 了解回應
<a name="understanding-response"></a>

回應包含更正後的幾何和貼齊的追蹤點，具有 `SnappedGeometry`和 等屬性`SnappedTracePoints`來表示準確性和貼齊可信度。

**SnappedGeometry**  
已貼齊路由的已更正幾何。

**SnappedTracePoints**  
貼齊道路的追蹤點調整座標。

**注意**  
有關貼齊程序的警告或資訊訊息。

# 如何
<a name="routes-how-to"></a>

本節提供利用 Routes APIs 解決路由和導覽挑戰的指南。這些教學課程涵蓋將路由功能整合到您的應用程式的基本任務。每個主題都著重於特定的使用案例，讓您能夠有效率地實作針對業務需求量身打造的進階路由功能。

**Topics**
+ [了解如何使用 CalculateRoutes](calculate-routes-how-to.md)
+ [了解如何使用 CalculateIsolines](calculate-isolines-how-to.md)
+ [了解如何使用 CalculateRouteMatrix](calculate-route-matrix-how-to.md)
+ [了解如何使用 OptimizeWaypoints](optimize-waypoints-how-to.md)
+ [了解如何使用 SnapToRoads](snap-to-roads-how-to.md)

# 了解如何使用 CalculateRoutes
<a name="calculate-routes-how-to"></a>

本節提供使用 step-by-step說明`CalculateRoutes`。本主題詳細介紹如何尋找具有特定組態的路由，例如整合turn-by-turn導覽、設定行程模式和新增航點。

**Topics**
+ [如何尋找原始伺服器和目的地的路由](calculate-routes-origin-destination-waypoints.md)
+ [如何尋找turn-by-turn路由](how-to-find-turn-by-turn-route.md)
+ [如何尋找道路跨度的速限](calculate-routes-speed-limit-road.md)
+ [如何尋找替代路由](calculate-routes-alternate.md)
+ [如何計算路由的過路費](calculate-routes-tolls.md)
+ [如何建立具有自訂迴避的路由](calculate-routes-custom-avoidance-poly.md)
+ [如何建立自訂避免數個潛在項目的路由](calculate-routes-custom-avoidance-multiple.md)
+ [如何尋找最快的路由](calculate-routes-custom-avoidance-fast.md)
+ [如何尋找最短路由](calculate-routes-custom-avoidance-shortest.md)

# 如何尋找原始伺服器和目的地的路由
<a name="calculate-routes-origin-destination-waypoints"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援交通模式，例如卡車、行人、汽車和摩托車。它還支援最多 25 個航點 （中途停靠點），包括僅具有一些限制的原始伺服器和目的地。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **尋找point-to-point路由：**根據各種行程模式和其他選項，判斷兩個位置之間的最佳路由。

## 範例
<a name="calculate-routes-examples"></a>

### 使用 Car TravelMode 計算從原始伺服器到目的地的路由
<a name="calculate-routes-car-mode"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ]
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.020098,
                                    49.232872
                                ],
                                "Position": [
                                    -123.0203051,
                                    49.2328499
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.1181051,
                                    49.282423
                                ],
                                "Position": [
                                    -123.1180883,
                                    49.2824349
                                ]
                            }
                        },
                        "TravelSteps": [
                            {
                                "Distance": 1288,
                                "Duration": 102,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "Type": "Turn"
                            },
                            {
                                "Distance": 7092,
                                "Duration": 568,
                                "Type": "Keep"
                            },
                            {
                                "Distance": 65,
                                "Duration": 26,
                                "Type": "Turn"
                            },
                            {
                                "Distance": 50,
                                "Duration": 18,
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "Type": "Arrive"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.118105,
    49.282423
  ],
  "Destination": [
    -123.020098,
    49.232872
  ]
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.118105 49.282423 \
--destination -123.020098 49.232872
```

------

# 如何尋找turn-by-turn路由
<a name="how-to-find-turn-by-turn-route"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援交通模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases-turn-by-turn"></a>
+ **建立導覽行動應用程式：**使用 API turn-by-turn導覽指示。
+ 在 **Web 平台上顯示指示：**顯示 Web 應用程式的詳細路由指引，以協助您導覽。

## 範例
<a name="calculate-routes-examples-turn-by-turn"></a>

### 使用 Car TravelMode 計算路由
<a name="calculate-routes-car-mode-turn-by-turn"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ],
    "TravelStepType": "TurnByTurn",
    "TravelMode": "Car"
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "Arrival": {
                            "Place": {
                                "Position": [-123.0203051, 49.2328499]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "Position": [-123.1180883, 49.2824349]
                            }
                        },
                        "TravelSteps": [
                            {
                                "Distance": 1288,
                                "Duration": 102,
                                "Type": "Depart",
                                "NextRoad": {
                                    "RoadName": "W Georgia St",
                                    "RouteNumber": "HWY-1A"
                                }
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "Type": "Keep",
                                "NextRoad": {
                                    "RoadName": "Main St",
                                    "RouteNumber": "HWY-1A"
                                }
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "Type": "Turn",
                                "NextRoad": {
                                    "RoadName": "Main St",
                                    "RouteNumber": "HWY-1A"
                                }
                            },
                            {
                                "Distance": 7092,
                                "Duration": 568,
                                "Type": "Keep",
                                "NextRoad": {
                                    "RoadName": "Kingsway",
                                    "RouteNumber": "HWY-1A"
                                }
                            },
                            {
                                "Distance": 65,
                                "Duration": 26,
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "Type": "Arrive"
                            }
                        ]
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.118105,
    49.282423
  ],
  "Destination": [
    -123.020098,
    49.232872
  ],
  "TravelStepType": "TurnByTurn",
  "TravelMode": "Car"
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.118105 49.282423 \
--destination -123.020098 49.232872 \
--travel-step-type "TurnByTurn" \
--travel-mode "Car"
```

------

# 如何尋找道路跨度的速限
<a name="calculate-routes-speed-limit-road"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援旅行模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **稽核速度限制合規：**注意速度限制和合規。
+ **通知驅動程式速度限制：**如果可能不清楚，則通知驅動程式速度限制。

## 範例
<a name="calculate-routes-speed-examples"></a>

### 在 車輛 TravelMode 中尋找速限
<a name="calculate-routes-speed"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        13.055211,
        52.704802
    ],
    "Destination": [
        13.551910,
        52.282705
    ],
    "TravelMode": "Car",
    "SpanAdditionalFeatures": ["SpeedLimit"]
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.55191,
                                    52.282705
                                ],
                                "Position": [
                                    13.5507836,
                                    52.2859121
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.055211,
                                    52.704802
                                ],
                                "Position": [
                                    13.0555036,
                                    52.7056073
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [
                            {
                                "GeometryOffset": 0,
                                "SpeedLimit": {
                                    "Unlimited": true
                                }
                            },
                            {
                                "GeometryOffset": 151,
                                "SpeedLimit": {
                                    "MaxSpeed": 120.00000762939453
                                }
                            },
                            {
                                "GeometryOffset": 167,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 195,
                                "SpeedLimit": {
                                    "MaxSpeed": 120.00000762939453
                                }
                            },
                            {
                                "GeometryOffset": 220,
                                "SpeedLimit": {
                                    "Unlimited": true
                                }
                            },
                            {
                                "GeometryOffset": 356,
                                "SpeedLimit": {
                                    "MaxSpeed": 120.00000762939453
                                }
                            },
                            {
                                "GeometryOffset": 358,
                                "SpeedLimit": {
                                    "MaxSpeed": 100
                                }
                            },
                            {
                                "GeometryOffset": 368,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 384,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 639,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 701,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 726,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 805,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 839,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 1384,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 1393,
                                "SpeedLimit": {
                                    "MaxSpeed": 50
                                }
                            },
                            {
                                "GeometryOffset": 1443,
                                "SpeedLimit": {
                                    "MaxSpeed": 30.000001907348633
                                }
                            },
                            {
                                "GeometryOffset": 1454,
                                "SpeedLimit": {
                                    "MaxSpeed": 50
                                }
                            },
                            {
                                "GeometryOffset": 1504,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 1513,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 1516,
                                "SpeedLimit": {
                                    "MaxSpeed": 60.000003814697266
                                }
                            },
                            {
                                "GeometryOffset": 1555,
                                "SpeedLimit": {
                                    "MaxSpeed": 80
                                }
                            },
                            {
                                "GeometryOffset": 1748,
                                "SpeedLimit": {
                                    "MaxSpeed": 120.00000762939453
                                }
                            },
                            {
                                "GeometryOffset": 1904,
                                "SpeedLimit": {
                                    "MaxSpeed": 100
                                }
                            },
                            {
                                "GeometryOffset": 1945,
                                "SpeedLimit": {
                                    "Unlimited": true
                                }
                            },
                            {
                                "GeometryOffset": 2006,
                                "SpeedLimit": {
                                    "MaxSpeed": 70
                                }
                            },
                            {
                                "GeometryOffset": 2017,
                                "SpeedLimit": {
                                    "MaxSpeed": 50
                                }
                            },
                            {
                                "GeometryOffset": 2033,
                                "SpeedLimit": {
                                    "MaxSpeed": 30.000001907348633
                                }
                            }
                        ],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 9099,
                                "Duration": 262,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 18849,
                                "Duration": 800,
                                "ExitNumber": [],
                                "GeometryOffset": 162,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 4290,
                                "Duration": 212,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 701,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 14418,
                                "Duration": 651,
                                "ExitNumber": [],
                                "GeometryOffset": 828,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1255,
                                "Duration": 62,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1359,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 1607,
                                "Duration": 139,
                                "ExitNumber": [],
                                "GeometryOffset": 1393,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 934,
                                "Duration": 92,
                                "ExitNumber": [],
                                "GeometryOffset": 1442,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 320,
                                "Duration": 27,
                                "ExitNumber": [],
                                "GeometryOffset": 1473,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 320,
                                "Duration": 33,
                                "ExitNumber": [],
                                "GeometryOffset": 1491,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 17863,
                                "Duration": 680,
                                "ExitNumber": [],
                                "GeometryOffset": 1504,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 2888,
                                "Duration": 95,
                                "ExitNumber": [],
                                "GeometryOffset": 1917,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 321,
                                "Duration": 28,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1977,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 549,
                                "Duration": 41,
                                "ExitNumber": [],
                                "GeometryOffset": 2006,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 386,
                                "Duration": 51,
                                "ExitNumber": [],
                                "GeometryOffset": 2023,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 98,
                                "Duration": 15,
                                "ExitNumber": [],
                                "GeometryOffset": 2033,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 2036,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A111"
                    }
                },
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A113"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    13.055211,
    52.704802
  ],
  "Destination": [
    13.551910,
    52.282705
  ],
  "TravelMode": "Car",
  "SpanAdditionalFeatures": ["SpeedLimit"]
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin 13.055211 52.704802 \
--destination 13.551910 52.282705 \
--travel-mode "Car" \
--span-additional-features "SpeedLimit"
```

------

# 如何尋找替代路由
<a name="calculate-routes-alternate"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援交通模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **識別替代路由：**能夠挑選符合您業務需求的最佳路由。

## 範例
<a name="calculate-routes-alternate-examples"></a>

### 在 Car TravelMode 中尋找替代路由
<a name="calculate-routes-alternate"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        13.055211,
        52.704802
    ],
    "Destination": [
        13.551910,
        52.282705
    ],
    "TravelMode": "Car",
    "MaxAlternatives": 2
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.55191,
                                    52.282705
                                ],
                                "Position": [
                                    13.5507836,
                                    52.2859121
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.055211,
                                    52.704802
                                ],
                                "Position": [
                                    13.0555036,
                                    52.7056073
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 9099,
                                "Duration": 262,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 18849,
                                "Duration": 800,
                                "ExitNumber": [],
                                "GeometryOffset": 162,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 4290,
                                "Duration": 212,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 701,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 14418,
                                "Duration": 651,
                                "ExitNumber": [],
                                "GeometryOffset": 828,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1255,
                                "Duration": 62,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1359,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 1607,
                                "Duration": 139,
                                "ExitNumber": [],
                                "GeometryOffset": 1393,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 934,
                                "Duration": 92,
                                "ExitNumber": [],
                                "GeometryOffset": 1442,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 320,
                                "Duration": 27,
                                "ExitNumber": [],
                                "GeometryOffset": 1473,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 320,
                                "Duration": 33,
                                "ExitNumber": [],
                                "GeometryOffset": 1491,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 17863,
                                "Duration": 680,
                                "ExitNumber": [],
                                "GeometryOffset": 1504,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 2888,
                                "Duration": 95,
                                "ExitNumber": [],
                                "GeometryOffset": 1917,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 321,
                                "Duration": 28,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1977,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 549,
                                "Duration": 41,
                                "ExitNumber": [],
                                "GeometryOffset": 2006,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 386,
                                "Duration": 51,
                                "ExitNumber": [],
                                "GeometryOffset": 2023,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 98,
                                "Duration": 15,
                                "ExitNumber": [],
                                "GeometryOffset": 2033,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 2036,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A111"
                    }
                },
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A113"
                    }
                }
            ]
        },
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.55191,
                                    52.282705
                                ],
                                "Position": [
                                    13.5507836,
                                    52.2859121
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.055211,
                                    52.704802
                                ],
                                "Position": [
                                    13.0555036,
                                    52.7056073
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 91047,
                                "Duration": 2880,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 3496,
                                "Duration": 119,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1473,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 321,
                                "Duration": 28,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1565,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 549,
                                "Duration": 41,
                                "ExitNumber": [],
                                "GeometryOffset": 1594,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 386,
                                "Duration": 51,
                                "ExitNumber": [],
                                "GeometryOffset": 1611,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 98,
                                "Duration": 15,
                                "ExitNumber": [],
                                "GeometryOffset": 1621,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 1624,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A10"
                    }
                }
            ]
        },
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.55191,
                                    52.282705
                                ],
                                "Position": [
                                    13.5507836,
                                    52.2859121
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    13.055211,
                                    52.704802
                                ],
                                "Position": [
                                    13.0555036,
                                    52.7056073
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 9099,
                                "Duration": 262,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 18849,
                                "Duration": 800,
                                "ExitNumber": [],
                                "GeometryOffset": 162,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 4290,
                                "Duration": 212,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 701,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 12258,
                                "Duration": 554,
                                "ExitNumber": [],
                                "GeometryOffset": 828,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 18567,
                                "Duration": 1218,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 1282,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 250,
                                "Duration": 28,
                                "ExitNumber": [],
                                "GeometryOffset": 1760,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 4856,
                                "Duration": 245,
                                "ExitNumber": [],
                                "GeometryOffset": 1793,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 3202,
                                "Duration": 165,
                                "ExitNumber": [],
                                "GeometryOffset": 1970,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 386,
                                "Duration": 51,
                                "ExitNumber": [],
                                "GeometryOffset": 2072,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 98,
                                "Duration": 15,
                                "ExitNumber": [],
                                "GeometryOffset": 2082,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 2085,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "A111"
                    }
                },
                {
                    "RouteNumber": {
                        "Language": "de",
                        "Value": "B96"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    13.055211,
    52.704802
  ],
  "Destination": [
    13.551910,
    52.282705
  ],
  "TravelMode": "Car",
  "MaxAlternatives": 2
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin 13.055211 52.704802 \
--destination 13.551910 52.282705 \
--travel-mode "Car" \
--max-alternatives 2
```

------

# 如何計算路由的過路費
<a name="calculate-routes-tolls"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援交通模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **計算過路費：**能夠在路由規劃期間計算過路費。
+ **稽核過路費：**能夠在旅行後稽核過路費。

## 範例
<a name="calculate-routes-tolls-examples"></a>

### 在 Car TravelMode 中計算路由的過路費
<a name="calculate-routes-tolls"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        2.234491,
        48.815704
    ],
    "Destination": [
        5.11412,
        47.260723
    ],
    "TravelMode": "Car",
    "Tolls": {
        "AllTransponders": true,
        "AllVignettes": true
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    5.11412,
                                    47.2607229
                                ],
                                "Position": [
                                    5.1128203,
                                    47.2596356
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    2.234491,
                                    48.8157039
                                ],
                                "Position": [
                                    2.2346482,
                                    48.815674
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [
                            {
                                "Country": "FRA",
                                "PaymentSites": [
                                    {
                                        "Name": "FLEURY-EN-BIERE",
                                        "Position": [
                                            2.53988,
                                            48.42578
                                        ]
                                    },
                                    {
                                        "Name": "POUILLY-EN-AUXOIS",
                                        "Position": [
                                            4.56112,
                                            47.25244
                                        ]
                                    }
                                ],
                                "Rates": [
                                    {
                                        "Id": "2d680295-fb0f-45aa-a8ed-79d9f0f9ff9f",
                                        "LocalPrice": {
                                            "Currency": "EUR",
                                            "Estimate": false,
                                            "Range": false,
                                            "Value": 21.700000762939453
                                        },
                                        "Name": "APRR",
                                        "PaymentMethods": [
                                            "Cash",
                                            "BankCard",
                                            "CreditCard",
                                            "Transponder",
                                            "TravelCard"
                                        ],
                                        "Transponders": [
                                            {
                                                "SystemName": "BipandGo"
                                            },
                                            {
                                                "SystemName": "BipandGo"
                                            },
                                            {
                                                "SystemName": "BipandGo IDVROOM carpoorling"
                                            },
                                            {
                                                "SystemName": "Cito30"
                                            },
                                            {
                                                "SystemName": "Easytrip pass"
                                            },
                                            {
                                                "SystemName": "Liane 30"
                                            },
                                            {
                                                "SystemName": "Liber-t"
                                            },
                                            {
                                                "SystemName": "Liber-t mobilitis"
                                            },
                                            {
                                                "SystemName": "Pass Pont-Pont"
                                            },
                                            {
                                                "SystemName": "Progressivi'T Maurienne"
                                            },
                                            {
                                                "SystemName": "TopEurop"
                                            },
                                            {
                                                "SystemName": "Tunnel Pass+"
                                            },
                                            {
                                                "SystemName": "Ulys"
                                            },
                                            {
                                                "SystemName": "Ulys Europe"
                                            },
                                            {
                                                "SystemName": "Viaduc-t 30"
                                            }
                                        ]
                                    }
                                ],
                                "Systems": [
                                    0
                                ]
                            }
                        ],
                        "TollSystems": [
                            {
                                "Name": "APRR"
                            }
                        ],
                        "TravelSteps": [
                            {
                                "Distance": 122,
                                "Duration": 21,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 32,
                                "Duration": 7,
                                "ExitNumber": [],
                                "GeometryOffset": 7,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 74,
                                "Duration": 14,
                                "ExitNumber": [],
                                "GeometryOffset": 8,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 199,
                                "Duration": 33,
                                "ExitNumber": [],
                                "GeometryOffset": 9,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 21,
                                "Duration": 10,
                                "ExitNumber": [],
                                "GeometryOffset": 17,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 461,
                                "Duration": 63,
                                "ExitNumber": [],
                                "GeometryOffset": 20,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1557,
                                "Duration": 145,
                                "ExitNumber": [],
                                "GeometryOffset": 41,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 3471,
                                "Duration": 151,
                                "ExitNumber": [],
                                "GeometryOffset": 135,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 9796,
                                "Duration": 430,
                                "ExitNumber": [],
                                "GeometryOffset": 242,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 2473,
                                "Duration": 112,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 582,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 674,
                                "Duration": 25,
                                "ExitNumber": [],
                                "GeometryOffset": 669,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 253953,
                                "Duration": 7468,
                                "ExitNumber": [],
                                "GeometryOffset": 679,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 37379,
                                "Duration": 1192,
                                "ExitNumber": [],
                                "ExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "GeometryOffset": 5701,
                                "Type": "Exit"
                            },
                            {
                                "Distance": 2021,
                                "Duration": 110,
                                "ExitNumber": [],
                                "GeometryOffset": 6695,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 7380,
                                "Duration": 316,
                                "ExitNumber": [],
                                "GeometryOffset": 6776,
                                "RoundaboutPassStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutPass"
                            },
                            {
                                "Distance": 4253,
                                "Duration": 156,
                                "ExitNumber": [],
                                "GeometryOffset": 6987,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 813,
                                "Duration": 54,
                                "ExitNumber": [],
                                "GeometryOffset": 7081,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1909,
                                "Duration": 109,
                                "ExitNumber": [],
                                "GeometryOffset": 7133,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Sharp"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 827,
                                "Duration": 47,
                                "ExitNumber": [],
                                "GeometryOffset": 7182,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 680,
                                "Duration": 41,
                                "ExitNumber": [],
                                "GeometryOffset": 7216,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 224,
                                "Duration": 12,
                                "ExitNumber": [],
                                "GeometryOffset": 7258,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 25,
                                "Duration": 2,
                                "ExitNumber": [],
                                "GeometryOffset": 7265,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 748,
                                "Duration": 51,
                                "ExitNumber": [],
                                "GeometryOffset": 7267,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 656,
                                "Duration": 46,
                                "ExitNumber": [],
                                "GeometryOffset": 7299,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 1119,
                                "Duration": 78,
                                "ExitNumber": [],
                                "GeometryOffset": 7329,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 432,
                                "Duration": 26,
                                "ExitNumber": [],
                                "GeometryOffset": 7383,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1864,
                                "Duration": 100,
                                "ExitNumber": [],
                                "GeometryOffset": 7402,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 1110,
                                "Duration": 93,
                                "ExitNumber": [],
                                "GeometryOffset": 7470,
                                "RoundaboutExitStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "RoundaboutExit"
                            },
                            {
                                "Distance": 232,
                                "Duration": 10,
                                "ExitNumber": [],
                                "GeometryOffset": 7563,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 642,
                                "Duration": 29,
                                "ExitNumber": [],
                                "GeometryOffset": 7572,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 357,
                                "Duration": 25,
                                "ExitNumber": [],
                                "GeometryOffset": 7580,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 63,
                                "Duration": 10,
                                "ExitNumber": [],
                                "GeometryOffset": 7600,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2626,
                                "Duration": 411,
                                "ExitNumber": [],
                                "GeometryOffset": 7602,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 234,
                                "Duration": 37,
                                "ExitNumber": [],
                                "GeometryOffset": 7627,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 7632,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "fr",
                        "Value": "A6"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    2.234491,
    48.815704
  ],
  "Destination": [
    5.11412,
    47.260723
  ],
  "TravelMode": "Car",
  "Tolls": {
    "AllTransponders": true,
    "AllVignettes": true
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin 13.055211 52.704802 \
--destination 13.551910 52.282705 \
--travel-mode "Car" \
--tolls '{"AllTransponders": true, "AllVignettes": true}'
```

------

# 如何建立具有自訂迴避的路由
<a name="calculate-routes-custom-avoidance-poly"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援交通模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **使用自訂避免來計算路由：**使用避免來自訂路由，以獲得更好的路由和往返規劃。

## 範例
<a name="calculate-routes-custom-avoidance-examples"></a>

### 使用 CalculateRoutes 搭配 avoid BoundingBox 來建立自訂路由。
<a name="calculate-routes-custom-avoidance-poly"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.116655,
        49.281538
    ],
    "Destination": [
        -123.01791785749363,
        49.22782762759908
    ],
    "TravelMode": "Car",
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "BoundingBox": [
                        -123.078693,
                        49.238987,
                        -123.054638,
                        49.251694
                    ]
                }
            }
        ]
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.0179179,
                                    49.2278276
                                ],
                                "Position": [
                                    -123.0229001,
                                    49.22883
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.116655,
                                    49.281538
                                ],
                                "Position": [
                                    -123.1166332,
                                    49.2815528
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1144,
                                "Duration": 85,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 35,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 433,
                                "Duration": 47,
                                "ExitNumber": [],
                                "GeometryOffset": 40,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 54,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 54,
                                "Duration": 4,
                                "ExitNumber": [],
                                "GeometryOffset": 79,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 520,
                                "Duration": 39,
                                "ExitNumber": [],
                                "GeometryOffset": 83,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1123,
                                "Duration": 111,
                                "ExitNumber": [],
                                "GeometryOffset": 101,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 141,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2843,
                                "Duration": 209,
                                "ExitNumber": [],
                                "GeometryOffset": 167,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 3219,
                                "Duration": 246,
                                "ExitNumber": [],
                                "GeometryOffset": 255,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 64,
                                "Duration": 23,
                                "ExitNumber": [],
                                "GeometryOffset": 332,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 334,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RoadName": {
                        "Language": "en",
                        "Value": "Boundary Rd"
                    }
                },
                {
                    "RoadName": {
                        "Language": "en",
                        "Value": "Grandview Hwy"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.116655,
    49.281538
  ],
  "Destination": [
    -123.01791785749363,
    49.22782762759908
  ],
  "TravelMode": "Car",
  "Avoid": {
    "Areas": [
      {
        "Geometry": {
          "BoundingBox": [
            -123.078693,
            49.238987,
            -123.054638,
            49.251694
          ]
        }
      }
    ]
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.13277 49.281538 \
--destination -123.01791785749363 49.22782762759908 \
--travel-mode "Car" \
--avoid '{"Areas":[{"Geometry":{"BoundingBox":[-123.054638,49.238987,-123.054638,49.251694]}}]}'
```

------

### 使用 CalculateRoutes 搭配 避免多邊形來建立自訂路由。
<a name="calculate-routes-custom-avoidance-poly-polygon"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.116655,
        49.281538
    ],
    "Destination": [
        -123.01791785749363,
        49.22782762759908
    ],
    "TravelMode": "Car",
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "polygon": [
                        [
                            [
                                -123.06953,
                                49.256419
                            ],
                            [
                                -123.080486,
                                49.242115
                            ],
                            [
                                -123.058573,
                                49.242115
                            ],
                            [
                                -123.06953,
                                49.256419
                            ]
                        ]
                    ]
                }
            }
        ]
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.0179179,
                                    49.2278276
                                ],
                                "Position": [
                                    -123.0229001,
                                    49.22883
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.116655,
                                    49.281538
                                ],
                                "Position": [
                                    -123.1166332,
                                    49.2815528
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1144,
                                "Duration": 85,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 35,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 433,
                                "Duration": 47,
                                "ExitNumber": [],
                                "GeometryOffset": 40,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 54,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 54,
                                "Duration": 4,
                                "ExitNumber": [],
                                "GeometryOffset": 79,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 520,
                                "Duration": 39,
                                "ExitNumber": [],
                                "GeometryOffset": 83,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1123,
                                "Duration": 111,
                                "ExitNumber": [],
                                "GeometryOffset": 101,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 141,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 448,
                                "Duration": 34,
                                "ExitNumber": [],
                                "GeometryOffset": 167,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1797,
                                "Duration": 151,
                                "ExitNumber": [],
                                "GeometryOffset": 182,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2836,
                                "Duration": 224,
                                "ExitNumber": [],
                                "GeometryOffset": 222,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 339,
                                "Duration": 30,
                                "ExitNumber": [],
                                "GeometryOffset": 326,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 64,
                                "Duration": 23,
                                "ExitNumber": [],
                                "GeometryOffset": 335,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 337,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                },
                {
                    "RoadName": {
                        "Language": "en",
                        "Value": "Nanaimo St"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.116655,
    49.281538
  ],
  "Destination": [
    -123.01791785749363,
    49.22782762759908
  ],
  "TravelMode": "Car",
  "Avoid": {
    "Areas": [
      {
        "Geometry": {
          "polygon": [
            [
              [
                -123.06953,
                49.256419
              ],
              [
                -123.080486,
                49.242115
              ],
              [
                -123.058573,
                49.242115
              ],
              [
                -123.06953,
                49.256419
              ]
            ]
          ]
        }
      }
    ]
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.13277 49.281538 \
--destination -123.01791785749363 49.22782762759908 \
--travel-mode "Car" \
--avoid '{"Areas":[{"Geometry":{"Polygon":[[[-123.06953,49.256419],[-123.05167,49.242115],[-123.02381,49.242115],[-123.06953,49.256419]]]}}]}'
```

------

### 使用 CalculateRoutes 搭配 PolylinePolygon 來建立自訂路由。
<a name="calculate-routes-custom-avoidance-poly-polyline"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.116655,
        49.281538
    ],
    "Destination": [
        -123.01791785749363,
        49.22782762759908
    ],
    "TravelMode": "Car",
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "PolylinePolygon": [
                        "BF0s0sJxglvXr5CvkCAgpEs5CvkC"
                    ]
                }
            }
        ]
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.0179179,
                                    49.2278276
                                ],
                                "Position": [
                                    -123.0229001,
                                    49.22883
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.116655,
                                    49.281538
                                ],
                                "Position": [
                                    -123.1166332,
                                    49.2815528
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1144,
                                "Duration": 85,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 35,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 433,
                                "Duration": 47,
                                "ExitNumber": [],
                                "GeometryOffset": 40,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 54,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 54,
                                "Duration": 4,
                                "ExitNumber": [],
                                "GeometryOffset": 79,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 520,
                                "Duration": 39,
                                "ExitNumber": [],
                                "GeometryOffset": 83,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1123,
                                "Duration": 111,
                                "ExitNumber": [],
                                "GeometryOffset": 101,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1131,
                                "Duration": 81,
                                "ExitNumber": [],
                                "GeometryOffset": 141,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 448,
                                "Duration": 34,
                                "ExitNumber": [],
                                "GeometryOffset": 167,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 1797,
                                "Duration": 151,
                                "ExitNumber": [],
                                "GeometryOffset": 182,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2836,
                                "Duration": 224,
                                "ExitNumber": [],
                                "GeometryOffset": 222,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 339,
                                "Duration": 30,
                                "ExitNumber": [],
                                "GeometryOffset": 326,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 64,
                                "Duration": 23,
                                "ExitNumber": [],
                                "GeometryOffset": 335,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 337,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                },
                {
                    "RoadName": {
                        "Language": "en",
                        "Value": "Nanaimo St"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.116655,
    49.281538
  ],
  "Destination": [
    -123.01791785749363,
    49.22782762759908
  ],
  "TravelMode": "Car",
  "Avoid": {
    "Areas": [
      {
        "Geometry": {
          "PolylinePolygon": [
            "BF0s0sJxglvXr5CvkCAgpEs5CvkC"
          ]
        }
      }
    ]
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.13277 49.281538 \
--destination -123.01791785749363 49.22782762759908 \
--travel-mode "Car" \
--avoid '{"Areas":[{"Geometry":{"PolylinePolygon":["BF0s0sJxglvXr5CvkCAgpEs5CvkC"]}}]}'
```

------

### 使用 CalculateRoutes 搭配 avoid Corridor 來建立自訂路由。
<a name="calculate-routes-custom-avoidance-corridor"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.116655,
        49.281538
    ],
    "Destination": [
        -123.01791785749363,
        49.22782762759908
    ],
    "TravelMode": "Car",
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "PolylineCorridor": {
                        "Polyline": "Redacted",
                        "Radius": 10
                    }
                }
            }
        ]
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.0179179,
                                    49.2278276
                                ],
                                "Position": [
                                    -123.0229001,
                                    49.22883
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.116655,
                                    49.281538
                                ],
                                "Position": [
                                    -123.1166332,
                                    49.2815528
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1144,
                                "Duration": 85,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 35,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "ExitNumber": [],
                                "GeometryOffset": 40,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2468,
                                "Duration": 204,
                                "ExitNumber": [],
                                "GeometryOffset": 90,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 1100,
                                "Duration": 88,
                                "ExitNumber": [],
                                "GeometryOffset": 170,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1588,
                                "Duration": 133,
                                "ExitNumber": [],
                                "GeometryOffset": 214,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 47,
                                "Duration": 14,
                                "ExitNumber": [],
                                "GeometryOffset": 260,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 2478,
                                "Duration": 196,
                                "ExitNumber": [],
                                "GeometryOffset": 265,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 339,
                                "Duration": 30,
                                "ExitNumber": [],
                                "GeometryOffset": 357,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 64,
                                "Duration": 23,
                                "ExitNumber": [],
                                "GeometryOffset": 366,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 368,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.116655,
    49.281538
  ],
  "Destination": [
    -123.01791785749363,
    49.22782762759908
  ],
  "TravelMode": "Car",
  "Avoid": {
    "Areas": [
      {
        "Geometry": {
          "PolylineCorridor": {
            "Polyline": "Redacted",
            "Radius": 10
          }
        }
      }
    ]
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.116655 49.281538 \
--destination -123.01791785749363 49.22782762759908 \
--travel-mode "Car" \
--avoid '{"Areas": [{"Geometry": {"PolylineCorridor": {"Polyline": "BF2mysJnmkvX5ekiC", "Radius": 10}}}]}'
```

------

### 使用 CalculateRoutes 搭配 avoid PolylineCorridor 來建立自訂路由。
<a name="calculate-routes-custom-avoidance-polyline-corridor"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.116655,
        49.281538
    ],
    "Destination": [
        -123.01791785749363,
        49.22782762759908
    ],
    "TravelMode": "Car",
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "Corridor": {
                        "LineString": [
                            [
                                -123.06532243038754,
                                49.245226301868776
                            ],
                            [
                                -123.0547357660333,
                                49.24030469850804
                            ]
                        ],
                        "Radius": 10
                    }
                }
            }
        ]
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.0179179,
                                    49.2278276
                                ],
                                "Position": [
                                    -123.0229001,
                                    49.22883
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.116655,
                                    49.281538
                                ],
                                "Position": [
                                    -123.1166332,
                                    49.2815528
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1144,
                                "Duration": 85,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 35,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "ExitNumber": [],
                                "GeometryOffset": 40,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 2468,
                                "Duration": 204,
                                "ExitNumber": [],
                                "GeometryOffset": 90,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 1100,
                                "Duration": 88,
                                "ExitNumber": [],
                                "GeometryOffset": 170,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 1588,
                                "Duration": 133,
                                "ExitNumber": [],
                                "GeometryOffset": 214,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 47,
                                "Duration": 14,
                                "ExitNumber": [],
                                "GeometryOffset": 260,
                                "Type": "Continue"
                            },
                            {
                                "Distance": 2478,
                                "Duration": 196,
                                "ExitNumber": [],
                                "GeometryOffset": 265,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 339,
                                "Duration": 30,
                                "ExitNumber": [],
                                "GeometryOffset": 357,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 64,
                                "Duration": 23,
                                "ExitNumber": [],
                                "GeometryOffset": 366,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 368,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.116655,
    49.281538
  ],
  "Destination": [
    -123.01791785749363,
    49.22782762759908
  ],
  "TravelMode": "Car",
  "Avoid": {
    "Areas": [
      {
        "Geometry": {
          "Corridor": {
            "LineString": [
              [
                -123.06532243038754,
                49.245226301868776
              ],
              [
                -123.0547357660333,
                49.24030469850804
              ]
            ],
            "Radius": 10
          }
        }
      }
    ]
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.13277 49.281538 \
--destination -123.01791785749363 49.22782762759908 \
--travel-mode "Car" \
--avoid '{"Areas":[{"Geometry":{"Corridor":{"LineString":[[-123.06532243038754,49.245226301868776],[-123.0547357660333,49.24030469850804]],"Radius":10}}}]}'
```

------

# 如何建立自訂避免數個潛在項目的路由
<a name="calculate-routes-custom-avoidance-multiple"></a>

CalculateRoutes API 可協助您尋找原始伺服器和目的地之間的最佳路由，以及驅動程式休息的最佳機會。它支援旅行模式，例如汽車、卡車、行人和摩托車。它還支援最多 25 個航點 （中途停靠點），包括原始伺服器和目的地，只有幾個限制條件。

## 潛在的使用案例
<a name="potential-use-cases"></a>
+ **使用自訂避免來計算路由：**使用避免來自訂路由，以獲得更好的路由和交通規劃。

## 範例
<a name="calculate-routes-examples"></a>

### 使用 CalculateRoutes 來避免過路費、迴轉費、花車、高速公路、通道等。
<a name="calculate-routes-custom-avoidance-tolls-ferries"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ],
    "TravelMode": "Car",
    "Avoid": {
        "TollRoads": true,
        "UTurns": true,
        "Ferries": true,
        "ControlledAccessHighways": true,
        "Tunnels": true
    }
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.020098,
                                    49.232872
                                ],
                                "Position": [
                                    -123.0203051,
                                    49.2328499
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.1181051,
                                    49.282423
                                ],
                                "Position": [
                                    -123.1180883,
                                    49.2824349
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1288,
                                "Duration": 102,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 37,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "ExitNumber": [],
                                "GeometryOffset": 42,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 7092,
                                "Duration": 568,
                                "ExitNumber": [],
                                "GeometryOffset": 92,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 65,
                                "Duration": 26,
                                "ExitNumber": [],
                                "GeometryOffset": 337,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 50,
                                "Duration": 18,
                                "ExitNumber": [],
                                "GeometryOffset": 339,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 343,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.118105,
    49.282423
  ],
  "Destination": [
    -123.020098,
    49.232872
  ],
  "TravelMode": "Car",
  "Avoid": {
    "TollRoads": true,
    "UTurns": true,
    "Ferries": true,
    "ControlledAccessHighways": true,
    "Tunnels": true
  }
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.118105 49.282423 \
--destination -123.020098 49.232872 \
--travel-mode "Car" \
--avoid '{"TollRoads": true, "UTurns": true, "Ferries": true, "ControlledAccessHighways": true, "Tunnels": true}'
```

------

# 如何尋找最快的路由
<a name="calculate-routes-custom-avoidance-fast"></a>

CalculateRoutes API 可協助您尋找原始伺服器與目的地之間的最快路由。

## 潛在的使用案例
<a name="calculate-routes-fast-potential-use"></a>
+ **針對時間效率最佳化路由：**透過計算最快的路由來改善交付操作。這有助於減少物流和交付服務中的行程時間。

## 範例
<a name="calculate-routes-fast-examples"></a>

### 計算最快的路由
<a name="calculate-routes-fast-car"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ],
    "TravelMode": "Car",
    "OptimizeRoutingFor": "FastestRoute"
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.020098,
                                    49.232872
                                ],
                                "Position": [
                                    -123.0203051,
                                    49.2328499
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.1181051,
                                    49.282423
                                ],
                                "Position": [
                                    -123.1180883,
                                    49.2824349
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1288,
                                "Duration": 102,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 37,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "ExitNumber": [],
                                "GeometryOffset": 42,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 7092,
                                "Duration": 568,
                                "ExitNumber": [],
                                "GeometryOffset": 92,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 65,
                                "Duration": 26,
                                "ExitNumber": [],
                                "GeometryOffset": 337,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 50,
                                "Duration": 18,
                                "ExitNumber": [],
                                "GeometryOffset": 339,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 343,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "Origin": [
    -123.118105,
    49.282423
  ],
  "Destination": [
    -123.020098,
    49.232872
  ],
  "TravelMode": "Car",
  "OptimizeRoutingFor": "FastestRoute"
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.118105 49.282423 \
--destination -123.020098 49.232872 \
--travel-mode "Car" \
--optimize-routing-for "FastestRoute"
```

------

# 如何尋找最短路由
<a name="calculate-routes-custom-avoidance-shortest"></a>

CalculateRoutes API 可協助您尋找原始伺服器與目的地之間的最短路由。

## 潛在的使用案例
<a name="calculate-routes-short-potential-use"></a>
+ **針對時間效率最佳化路由：**透過計算最短路由來改善交付操作。這有助於減少物流和交付服務中的行程距離。

## 範例
<a name="calculate-routes-short-examples"></a>

### 使用 CalculateRoutes 來尋找最短的路線並節省行程距離。
<a name="calculate-routes-shortest"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ],
    "TravelMode": "Car",
    "OptimizeRoutingFor": "ShortestRoute"
}
```

------
#### [ Sample response ]

```
{
    "LegGeometryFormat": "FlexiblePolyline",
    "Notices": [],
    "Routes": [
        {
            "Legs": [
                {
                    "Geometry": {
                        "Polyline": "Redacted"
                    },
                    "TravelMode": "Car",
                    "Type": "Vehicle",
                    "VehicleLegDetails": {
                        "AfterTravelSteps": [],
                        "Arrival": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.020098,
                                    49.232872
                                ],
                                "Position": [
                                    -123.0203051,
                                    49.2328499
                                ]
                            }
                        },
                        "Departure": {
                            "Place": {
                                "ChargingStation": false,
                                "OriginalPosition": [
                                    -123.1181051,
                                    49.282423
                                ],
                                "Position": [
                                    -123.1180883,
                                    49.2824349
                                ]
                            }
                        },
                        "Incidents": [],
                        "Notices": [],
                        "PassThroughWaypoints": [],
                        "Spans": [],
                        "Tolls": [],
                        "TollSystems": [],
                        "TravelSteps": [
                            {
                                "Distance": 1288,
                                "Duration": 102,
                                "ExitNumber": [],
                                "GeometryOffset": 0,
                                "Type": "Depart"
                            },
                            {
                                "Distance": 262,
                                "Duration": 24,
                                "ExitNumber": [],
                                "GeometryOffset": 37,
                                "RampStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right"
                                },
                                "Type": "Ramp"
                            },
                            {
                                "Distance": 1356,
                                "Duration": 134,
                                "ExitNumber": [],
                                "GeometryOffset": 42,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 7092,
                                "Duration": 568,
                                "ExitNumber": [],
                                "GeometryOffset": 92,
                                "KeepStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left"
                                },
                                "Type": "Keep"
                            },
                            {
                                "Distance": 65,
                                "Duration": 26,
                                "ExitNumber": [],
                                "GeometryOffset": 337,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Left",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 50,
                                "Duration": 18,
                                "ExitNumber": [],
                                "GeometryOffset": 339,
                                "TurnStepDetails": {
                                    "Intersection": [],
                                    "SteeringDirection": "Right",
                                    "TurnIntensity": "Typical"
                                },
                                "Type": "Turn"
                            },
                            {
                                "Distance": 0,
                                "Duration": 0,
                                "ExitNumber": [],
                                "GeometryOffset": 343,
                                "Type": "Arrive"
                            }
                        ],
                        "TruckRoadTypes": [],
                        "Zones": []
                    }
                }
            ],
            "MajorRoadLabels": [
                {
                    "RouteNumber": {
                        "Language": "en",
                        "Value": "HWY-1A"
                    }
                }
            ]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/routes?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.118105,
        49.282423
    ],
    "Destination": [
        -123.020098,
        49.232872
    ],
    "TravelMode": "Car",
    "OptimizeRoutingFor": "ShortestRoute"
}'
```

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

```
aws geo-routes calculate-routes --key ${YourKey} \
--origin -123.118105 49.282423 \
--destination -123.020098 49.232872 \
--travel-mode "Scooter" \
--optimize-routing-for "ShortestRoute"
```

------

# 了解如何使用 CalculateIsolines
<a name="calculate-isolines-how-to"></a>

在本節中，您將了解如何搭配使用 `CalculateIsolines`與時間或距離範圍，以及設定要避免的區域。

**Topics**
+ [如何根據時間範圍計算服務區域](calculate-service-area-based-on-time.md)
+ [如何根據距離範圍計算服務區域](calculate-service-area-based-on-distance.md)
+ [如何根據避免情況計算服務區域](calculate-service-area-based-on-avoidance.md)

# 如何根據時間範圍計算服務區域
<a name="calculate-service-area-based-on-time"></a>

CalculateIsolines API 可讓您判斷指定時間或距離範圍內的可連線服務區域，並考量道路網路和交通狀況。此功能支援應用程式定義餐廳、雜貨店或其他服務供應商的服務區域，以協助規劃燃料效率並定義服務涵蓋範圍的可存取區域。

## 潛在的使用案例
<a name="calculate-service-area-time-potential-use"></a>
+ **規劃服務區域：**使用此 API 根據行程時間或距離規劃餐廳或雜貨交付等服務的可存取區域。

## 範例
<a name="calculate-service-area-time-examples"></a>

### 使用 Car TravelMode 根據時間範圍計算服務區域
<a name="calculate-service-area-time"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Time": [
            500,
            1000,
            1500
        ]
    },
    "TravelMode": "Car"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ],
            "TimeThreshold": 500
        },
        {
            "Connections": [],
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ],
            "TimeThreshold": 1000
        },
        {
            "Connections": [],
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ],
            "TimeThreshold": 1500
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Time": [
            500,
            1000,
            1500
        ]
    },
    "TravelMode": "Car"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Time": [500, 1000, 1500]}' \
--travel-mode "Car"
```

------

# 如何根據距離範圍計算服務區域
<a name="calculate-service-area-based-on-distance"></a>

CalculateIsolines API 可讓您判斷指定時間或距離範圍內的可連線服務區域，並考量道路網路和交通狀況。此功能支援應用程式定義餐廳、雜貨店或其他服務供應商的服務區域，以協助規劃燃料效率並定義服務涵蓋範圍的可存取區域。

## 潛在的使用案例
<a name="calculate-service-area-distance-potential-use"></a>
+ **規劃服務區域：**使用此 API 根據行程時間或距離規劃餐廳或雜貨交付等服務的可存取區域。

## 範例
<a name="calculate-service-area-distance-examples"></a>

### 使用 Car TravelMode 根據距離範圍計算服務區域
<a name="calculate-service-area-distance"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            1000,
            2000,
            3000
        ]
    },
    "TravelMode": "Car"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "DistanceThreshold": 1000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        },
        {
            "Connections": [],
            "DistanceThreshold": 2000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        },
        {
            "Connections": [],
            "DistanceThreshold": 3000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            1000,
            2000,
            3000
        ]
    },
    "TravelMode": "Car"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Distance": [1000, 2000, 3000]}' \
--travel-mode "Car"
```

------

# 如何根據避免情況計算服務區域
<a name="calculate-service-area-based-on-avoidance"></a>

CalculateIsolines API 可讓您判斷指定時間或距離範圍內的可連線服務區域，並考量要避免的道路網路和交通條件。此功能支援應用程式定義餐廳、雜貨店或其他服務供應商的服務區域，以協助規劃燃料效率並定義服務涵蓋範圍的可存取區域。

## 潛在的使用案例
<a name="calculate-service-area-avoidance-potential-use"></a>
+ **規劃服務區域：**使用此 API 根據避免情況規劃餐廳或雜貨交付等服務的可存取區域。

## 範例
<a name="calculate-service-area-avoidance-examples"></a>

### 使用 Car TravelMode 根據迴避情況計算服務區域
<a name="calculate-service-area-avoidance-car"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "UTurns": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Car"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "DistanceThreshold": 4000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "UTurns": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Car"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Distance": [4000]}' \
--avoid '{"TollRoads": true, "UTurns": true, "ControlledAccessHighways": true, "Ferries": true, "DirtRoads": true, "SeasonalClosure": true, "CarShuttleTrains": true, "TollTransponders": true, "ZoneCategories": [{"Category": "Environmental"}]}' \
--travel-mode "Car"
```

------

### 使用 Truck TravelMode 根據迴避情況計算服務區域
<a name="calculate-service-area-avoidance-truck"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "UTurns": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Truck"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "DistanceThreshold": 4000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "UTurns": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Truck"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Distance": [4000]}' \
--avoid '{"TollRoads": true, "UTurns": true, "ControlledAccessHighways": true, "Ferries": true, "DirtRoads": true, "SeasonalClosure": true, "CarShuttleTrains": true, "TollTransponders": true, "ZoneCategories": [{"Category": "Environmental"}]}' \
--travel-mode "Truck"
```

------

### 根據行人迴避情況計算服務區域
<a name="calculate-service-area-avoidance-truck"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Pedestrian"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "DistanceThreshold": 4000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Pedestrian"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Distance": [4000]}' \
--avoid '{"TollRoads": true, "ControlledAccessHighways": true, "Ferries": true, "DirtRoads": true, "SeasonalClosure": true, "CarShuttleTrains": true, "TollTransponders": true, "ZoneCategories": [{"Category": "Environmental"}]}' \
--travel-mode "Pedestrian"
```

------

### 使用 Scooter TravelMode 根據迴避情況計算服務區域
<a name="calculate-service-area-avoidance-scooter"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "DifficultTurns": false,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Scooter"
}
```

------
#### [ Sample response ]

```
{
    "DepartureTime": "2024-10-28T14:27:56-07:00",
    "IsolineGeometryFormat": "FlexiblePolyline",
    "Isolines": [
        {
            "Connections": [],
            "DistanceThreshold": 4000,
            "Geometries": [
                {
                    "PolylinePolygon": [
                        "Redacted"
                    ]
                }
            ]
        }
    ],
    "SnappedOrigin": [
        -123.11687,
        49.2813999
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/isolines?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.11679620827039,
        49.28147612192166
    ],
    "DepartureTime": "2024-10-28T21:27:56Z",
    "Thresholds": {
        "Distance": [
            4000
        ]
    },
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true,
        "DirtRoads": true,
        "SeasonalClosure": true,
        "CarShuttleTrains": true,
        "TollTransponders": true,
        "ZoneCategories": [
            {
                "Category": "Environmental"
            }
        ]
    },
    "TravelMode": "Scooter"
}'
```

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

```
aws geo-routes calculate-isolines --key ${YourKey} \
--origin -123.11679620827039 49.28147612192166 \
--departure-time "2024-10-28T21:27:56Z" \
--thresholds '{"Distance": [4000]}' \
--avoid '{"TollRoads": true, "ControlledAccessHighways": true, "Ferries": true, "DirtRoads": true, "SeasonalClosure": true, "CarShuttleTrains": true, "TollTransponders": true, "ZoneCategories": [{"Category": "Environmental"}]}' \
--travel-mode "Scooter"
```

------

# 了解如何使用 CalculateRouteMatrix
<a name="calculate-route-matrix-how-to"></a>

在本節中，您將了解如何使用 `CalculateRouteMatrix` 尋找多個原始伺服器和目的地的有效路由。

**Topics**
+ [如何計算多個原始伺服器和目的地的距離和時間的路由矩陣](calculate-route-matrix-distance.md)
+ [如何計算具有迴避的路由矩陣](calculate-route-matrix-with-avoidance.md)

# 如何計算多個原始伺服器和目的地的距離和時間的路由矩陣
<a name="calculate-route-matrix-distance"></a>

CalculateRouteMatrix API 會計算路由，並為每個原始伺服器和目的地組合提供行程時間和行程距離。此功能適用於需要跨多個位置進行路由規劃和最佳化的應用程式。

回應`Distance`包含每個原始目的地對的公尺數和秒`Duration`數。

## 潛在的使用案例
<a name="calculate-route-matrix-potential-use"></a>
+ **最佳化路由規劃：**使用路由矩陣做為路由最佳化軟體的輸入，以提高服務效率並縮短行程時間。

## 範例
<a name="calculate-route-matrix-examples"></a>

### 具有無限制路由界限的 CalculateRouteMatrix
<a name="calculate-route-matrix-unbounded"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1907,
                "Duration": 343
            }
        ],
        [
            {
                "Distance": 5629,
                "Duration": 954
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

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

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}, {"Position": [-123.11179620827039, 49.3014761219]}]' \
--destinations '[{"Position": [-123.11179620827039, 49.28897192166]}]' \
--departure-time "2024-05-28T21:27:56Z" \
--routing-boundary '{"Unbounded": true}'
```

------

### 具有幾何型路由界限的 CalculateRouteMatrix
<a name="calculate-route-matrix-geometry"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Geometry": {
            "AutoCircle": {
                "Margin": 10000,
                "MaxRadius": 30000
            }
        }
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1907,
                "Duration": 344
            }
        ],
        [
            {
                "Distance": 5629,
                "Duration": 950
            }
        ]
    ],
    "RoutingBoundary": {
        "Geometry": {
            "Circle": {
                "Center": [
                    -123.1142962082704,
                    49.29147612191083
                ],
                "Radius": 11127
            }
        },
        "Unbounded": false
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        },
        {
            "Position": [-123.11179620827039, 49.3014761219]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "DepartureTime": "2024-05-28T21:27:56Z",
    "RoutingBoundary": {
        "Geometry": {
            "AutoCircle": {
                "Margin": 10000,
                "MaxRadius": 30000
            }
        }
    }
}'
```

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

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}, {"Position": [-123.11179620827039, 49.3014761219]}]' \
--destinations '[{"Position": [-123.11179620827039, 49.28897192166]}]' \
--departure-time "2024-05-28T21:27:56Z" \
--routing-boundary '{"Geometry": {"AutoCircle": {"Margin": 10000, "MaxRadius": 30000}}}'
```

------

# 如何計算具有迴避的路由矩陣
<a name="calculate-route-matrix-with-avoidance"></a>

CalculateRouteMatrix API 會計算路由，並傳回從每個原始伺服器到指定清單中每個目的地的行駛時間和距離。回應包含`Distance`以公尺為單位的 和以秒為單位`Duration`的 。API 可用來設定特定區域或道路功能的迴避選項，確保路由避免指定的區域或條件。如果替代路由不可行，則可以略過迴避偏好設定。

## 潛在的使用案例
<a name="calculate-route-matrix-potential-use"></a>
+ **路線規劃和最佳化：**使用路由矩陣作為需要最佳化旅遊路線的軟體輸入，同時避免某些區域或道路功能。

## 範例
<a name="calculate-route-matrix-examples"></a>

### 具有迴避區域的 CalculateRouteMatrix
<a name="calculate-route-matrix-avoidance-area"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "BoundingBox": [
                         -123.116561,
                         49.281517,
                         -123.110165,
                         49.285689
                    ]
                }
            }
        ]
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1855,
                "Duration": 295
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "Areas": [
            {
                "Geometry": {
                    "BoundingBox": [
                         -123.116561,
                         49.281517,
                         -123.110165,
                         49.285689
                    ]
                }
            }
        ]
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

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

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}]' \
--destinations '[{"Position": [-123.112317039, 49.28897192166]}]' \
--avoid '{"Areas": [{"Geometry": {"BoundingBox": [-123.116561, 49.281517, -123.110165, 49.285689]}}]}' \
--routing-boundary '{"Unbounded": true}'
```

------

### CalculateRouteMatrix 避免收費道路、高速公路和鐵道
<a name="calculate-route-matrix-avoidance-features"></a>

------
#### [ Sample request ]

```
{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true    
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ Sample response ]

```
{
    "ErrorCount": 0,
    "RouteMatrix": [
        [
            {
                "Distance": 1855,
                "Duration": 295
            }
        ]
    ],
    "RoutingBoundary": {
        "Unbounded": true
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/route-matrix?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origins": [
        {
            "Position": [-123.11679620827039, 49.28147612192166]
        }
    ],
    "Destinations": [
        {
            "Position": [-123.112317039, 49.28897192166]
        }
    ],
    "Avoid": {
        "TollRoads": true,
        "ControlledAccessHighways": true,
        "Ferries": true    
    },
    "RoutingBoundary": {
        "Unbounded": true
    }
}'
```

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

```
aws geo-routes calculate-route-matrix --key ${YourKey} \
--origins '[{"Position": [-123.11679620827039, 49.28147612192166]}]' \
--destinations '[{"Position": [-123.112317039, 49.28897192166]}]' \
--avoid '{"TollRoads": true, "ControlledAccessHighways": true, "Ferries": true}' \
--routing-boundary '{"Unbounded": true}'
```

------

# 了解如何使用 OptimizeWaypoints
<a name="optimize-waypoints-how-to"></a>

了解如何使用 `OptimizeWaypoints` 來尋找最佳路由，以將行程時間或距離降至最低。

**Topics**
+ [如何最佳化路由的航點](optimize-waypoints.md)
+ [如何針對具有流量感知的路由最佳化路徑點](optimize-waypoints-traffic-awareness.md)
+ [如何針對具有存取時數意識的路由最佳化路徑點](optimize-waypoints-access-hours.md)

# 如何最佳化路由的航點
<a name="optimize-waypoints"></a>

OptimizeWaypoints API 會計算一系列路徑點之間最有效率的路由，將行程時間或總距離降至最低。此 API 會考慮道路網路和流量條件來判斷最佳路徑，以解決行駛中的銷售人員問題。

## 潛在的使用案例
<a name="optimize-waypoints-potential-use"></a>
+ **分析服務區域模式：**使用航點最佳化，對商業服務區域做出明智的決策，並提高物流效率。

## 範例
<a name="optimize-waypoints-examples"></a>

### 使用 Car TravelMode 最佳化路線點
<a name="optimize-waypoints-car"></a>

------
#### [ Sample Request ]

```
{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ]
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car"
}
```

------
#### [ Sample Response ]

```
{
    "Connections": [
        {
            "Distance": 1989,
            "From": "Origin",
            "RestDuration": 0,
            "To": "Waypoint0",
            "TravelDuration": 258,
            "WaitDuration": 0
        },
        {
            "Distance": 3010,
            "From": "Waypoint0",
            "RestDuration": 0,
            "To": "Waypoint1",
            "TravelDuration": 298,
            "WaitDuration": 0
        },
        {
            "Distance": 2371,
            "From": "Waypoint1",
            "RestDuration": 0,
            "To": "Destination",
            "TravelDuration": 311,
            "WaitDuration": 0
        }
    ],
    "Distance": 7370,
    "Duration": 867,
    "ImpedingWaypoints": [],
    "OptimizedWaypoints": [
        {
            "DepartureTime": "2024-10-25T18:13:42Z",
            "Id": "Origin",
            "Position": [
                -123.09574,
                49.274426
            ]
        },
        {
            "DepartureTime": "2024-10-25T18:18:00Z",
            "Id": "Waypoint0",
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "DepartureTime": "2024-10-25T18:22:58Z",
            "Id": "Waypoint1",
            "Position": [
                -123.089557,
                49.271774
            ]
        },
        {
            "ArrivalTime": "2024-10-25T18:28:09Z",
            "Id": "Destination",
            "Position": [
                -123.095185,
                49.263728
            ]
        }
    ],
    "TimeBreakdown": {
        "RestDuration": 0,
        "ServiceDuration": 0,
        "TravelDuration": 867,
        "WaitDuration": 0
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/optimize-waypoints?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ]
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car"
}'
```

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

```
aws geo-routes optimize-waypoints --key ${YourKey} \
--origin -123.095740 49.274426 \
--waypoints '[{"Position": [-123.115193 , 49.280596]}, {"Position": [-123.089557 , 49.271774]}]' \
--destination -123.095185 49.263728 \
--departure-time "2024-10-25T18:13:42Z" \
--travel-mode "Car"
```

------

# 如何針對具有流量感知的路由最佳化路徑點
<a name="optimize-waypoints-traffic-awareness"></a>

OptimizeWaypoints API 會計算多個航點之間的最佳路由，以將行程時間或總距離降至最低。它利用進階演算法來解決周遊的 Salesman 問題，判斷最有效率的路徑，同時考慮道路網路和即時流量條件等因素。

## 潛在的使用案例
<a name="optimize-waypoints-potential-use"></a>
+ **最佳化多站路由以實現交付效率：**透過計算多個停止之間的最短或最快路由來改善交付操作。這有助於降低物流和交付服務中的營運成本、油耗和行駛時間。

## 範例
<a name="optimize-waypoints-examples"></a>

### 使用汽車 TravelMode 透過流量感知最佳化航點
<a name="optimize-waypoints-traffic-car"></a>

------
#### [ Sample request ]

```
{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ]
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car",
    "Traffic": {
        "Usage": "UseTrafficData"
    }
}
```

------
#### [ Sample response ]

```
{
    "Connections": [
        {
            "Distance": 1989,
            "From": "Origin",
            "RestDuration": 0,
            "To": "Waypoint0",
            "TravelDuration": 324,
            "WaitDuration": 0
        },
        {
            "Distance": 2692,
            "From": "Waypoint0",
            "RestDuration": 0,
            "To": "Waypoint1",
            "TravelDuration": 338,
            "WaitDuration": 0
        },
        {
            "Distance": 2371,
            "From": "Waypoint1",
            "RestDuration": 0,
            "To": "Destination",
            "TravelDuration": 395,
            "WaitDuration": 0
        }
    ],
    "Distance": 7052,
    "Duration": 1057,
    "ImpedingWaypoints": [],
    "OptimizedWaypoints": [
        {
            "DepartureTime": "2024-10-25T18:13:42Z",
            "Id": "Origin",
            "Position": [
                -123.09574,
                49.274426
            ]
        },
        {
            "ArrivalTime": "2024-10-25T18:19:06Z",
            "DepartureTime": "2024-10-25T18:19:06Z",
            "Id": "Waypoint0",
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "ArrivalTime": "2024-10-25T18:24:44Z",
            "DepartureTime": "2024-10-25T18:24:44Z",
            "Id": "Waypoint1",
            "Position": [
                -123.089557,
                49.271774
            ]
        },
        {
            "ArrivalTime": "2024-10-25T18:31:19Z",
            "Id": "Destination",
            "Position": [
                -123.095185,
                49.263728
            ]
        }
    ],
    "TimeBreakdown": {
        "RestDuration": 0,
        "ServiceDuration": 0,
        "TravelDuration": 1057,
        "WaitDuration": 0
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/optimize-waypoints?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ]
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car",
    "Traffic": {
        "Usage": "UseTrafficData"
    }
}'
```

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

```
aws geo-routes optimize-waypoints --key ${YourKey} \
--origin -123.095740 49.274426 \
--waypoints '[{"Position": [-123.115193 , 49.280596]}, {"Position": [-123.089557 , 49.271774]}]' \
--destination -123.095185 49.263728 \
--departure-time "2024-10-25T18:13:42Z" \
--travel-mode "Car" \
--traffic '{"Usage": "UseTrafficData"}'
```

------

# 如何針對具有存取時數意識的路由最佳化路徑點
<a name="optimize-waypoints-access-hours"></a>

OptimizeWaypoints API 也會計算一組路徑點之間的最佳路由，目標是將行程時間或涵蓋的總距離降至最低。它解決了周遊銷售員問題，即確定最有效率的路徑，並考慮道路網路和交通條件等因素。

## 潛在的使用案例
<a name="optimize-waypoints-access-hours-potential-use"></a>
+ **分析客戶存取時數：**規劃客戶存取時數的效率。

## 範例
<a name="optimize-waypoints-examples"></a>

### 使用 Car TravelMode 最佳化具有存取時數感知的航點
<a name="optimize-waypoints-car"></a>

------
#### [ Sample Request ]

```
{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ],
            "SideOfStreet": {
                "Position": [
                    -123.089557,
                    49.271774
                ],
                "UseWith": "AnyStreet"
            },
            "AccessHours": {
                "From": {
                    "DayOfWeek": "Saturday",
                    "TimeOfDay": "00:02:42Z"
                },
                "To": {
                    "DayOfWeek": "Friday",
                    "TimeOfDay": "1:33:36+02:50"
                }
            },
            "Heading": "250",
            "ServiceDuration": "200"
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ],
            "AccessHours": {
                "From": {
                    "DayOfWeek": "Monday",
                    "TimeOfDay": "00:02:42Z"
                },
                "To": {
                    "DayOfWeek": "Tuesday",
                    "TimeOfDay": "1:33:36+02:50"
                }
            },
            "ServiceDuration": "200"
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car"
}
```

------
#### [ Sample Response ]

```
{
    "Connections": [
        {
            "Distance": 1989,
            "From": "Origin",
            "RestDuration": 0,
            "To": "Waypoint0",
            "TravelDuration": 258,
            "WaitDuration": 20682
        },
        {
            "Distance": 3360,
            "From": "Waypoint0",
            "RestDuration": 0,
            "To": "Waypoint1",
            "TravelDuration": 378,
            "WaitDuration": 172222
        },
        {
            "Distance": 2371,
            "From": "Waypoint1",
            "RestDuration": 0,
            "To": "Destination",
            "TravelDuration": 311,
            "WaitDuration": 0
        }
    ],
    "Distance": 7720,
    "Duration": 194251,
    "ImpedingWaypoints": [],
    "OptimizedWaypoints": [
        {
            "DepartureTime": "2024-10-25T18:13:42Z",
            "Id": "Origin",
            "Position": [
                -123.09574,
                49.274426
            ]
        },
        {
            "ArrivalTime": "2024-10-25T18:18:00Z",
            "DepartureTime": "2024-10-26T00:06:02Z",
            "Id": "Waypoint0",
            "Position": [
                -123.115193,
                49.280596
            ]
        },
        {
            "ArrivalTime": "2024-10-26T00:12:20Z",
            "DepartureTime": "2024-10-28T00:06:02Z",
            "Id": "Waypoint1",
            "Position": [
                -123.089557,
                49.271774
            ]
        },
        {
            "ArrivalTime": "2024-10-28T00:11:13Z",
            "Id": "Destination",
            "Position": [
                -123.095185,
                49.263728
            ]
        }
    ],
    "TimeBreakdown": {
        "RestDuration": 0,
        "ServiceDuration": 400,
        "TravelDuration": 947,
        "WaitDuration": 192904
    }
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/optimize-waypoints?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
    "Origin": [
        -123.095740,
        49.274426
    ],
    "Waypoints": [
        {
            "Position": [
                -123.115193,
                49.280596
            ],
            "SideOfStreet": {
                "Position": [
                    -123.089557,
                    49.271774
                ],
                "UseWith": "AnyStreet"
            },
            "AccessHours": {
                "From": {
                    "DayOfWeek": "Saturday",
                    "TimeOfDay": "00:02:42Z"
                },
                "To": {
                    "DayOfWeek": "Friday",
                    "TimeOfDay": "1:33:36+02:50"
                }
            },
            "Heading": "250",
            "ServiceDuration": "200"
        },
        {
            "Position": [
                -123.089557,
                49.271774
            ],
            "AccessHours": {
                "From": {
                    "DayOfWeek": "Monday",
                    "TimeOfDay": "00:02:42Z"
                },
                "To": {
                    "DayOfWeek": "Tuesday",
                    "TimeOfDay": "1:33:36+02:50"
                }
            },
            "ServiceDuration": "200"
        }
    ],
    "DepartureTime": "2024-10-25T18:13:42Z",
    "Destination": [
        -123.095185,
        49.263728
    ],
    "TravelMode": "Car"
}'
```

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

```
aws geo-routes optimize-waypoints --key ${YourKey} \
--origin -123.095740 49.274426 \
--waypoints '[{"Position": [-123.115193 , 49.280596], "SideOfStreet": {"Position": [-123.089557, 49.271774], "UseWith": "AnyStreet"}, "AccessHours": {"From": {"DayOfWeek": "Saturday", "TimeOfDay": "00:02:42Z"}, "To": {"DayOfWeek": "Friday", "TimeOfDay": "1:33:36+02:50"}}, "Heading": 250, "ServiceDuration": 200}, {"Position": [-123.089557, 49.271774], "AccessHours": {"From": {"DayOfWeek": "Monday", "TimeOfDay": "00:02:42Z"}, "To": {"DayOfWeek": "Tuesday", "TimeOfDay": "1:33:36+02:50"}}, "ServiceDuration": 200}]' \
--destination -123.095185 49.263728 \
--departure-time "2024-10-25T18:13:42Z" \
--travel-mode "Car"
```

------

# 了解如何使用 SnapToRoads
<a name="snap-to-roads-how-to"></a>

 本主題說明如何使用 `SnapToRoads` 將 GPS 追蹤與道路網路對齊，提高導航和機群管理應用程式的位置準確性。此 API 會將座標貼齊最近的道路區段，同時遵守行駛模式限制，以修正 GPS 偏離和訊號遺失。範例說明實際用途，例如疊加 GPS 追蹤、填補資料差距，以及減少雜訊以更清晰的路由視覺化。

**Topics**
+ [如何將 GPS 追蹤比對至道路網路](how-to-match-gps-traces.md)

# 如何將 GPS 追蹤比對至道路網路
<a name="how-to-match-gps-traces"></a>

SnapToRoads API 可讓您將 GPS 追蹤比對至道路網路。GPS 追蹤包含使用 GPS 裝置記錄的位置和中繼資料，例如時間戳記、速度和標題。這些追蹤通常具有誤差範圍，使其難以直接用於分析和視覺化。

SnapToRoads 會考慮指定行程模式的法律和時間限制，同時比對追蹤。如果追蹤強烈建議違反限制，則會維持實際採取的路由。

## 潛在的使用案例
<a name="potential-use"></a>
+ 將 **GPS 追蹤覆蓋在最可能行駛的道路上：**此功能有助於將 GPS 資料與道路網路上最準確的路徑對齊，以支援更清晰的資料視覺化。
+ **攔截 GPS 追蹤中的差距：**SnapToRoads 可以透過將座標貼齊道路區段來填補差距，為應用程式建立更連續且有用的資料集。
+ **篩選雜訊和極端值：**透過貼齊最近的道路，此 API 可協助移除極端值並減少 GPS 雜訊，改善分析的資料可靠性。

## 範例
<a name="examples"></a>

### 使用汽車模式比對 GPS 追蹤
<a name="match-gps-car-mode"></a>

------
#### [ Sample request ]

```
{
  "TracePoints": [
    {
      "Position": [8.53404,50.16364],
      "Timestamp": "2024-05-22T18:13:42Z"
    },
    {
      "Position": [8.53379056,50.16352417],
      "Speed": 20,
      "Timestamp": "2024-05-22T18:13:59Z"
    }
  ],
  "TravelMode": "Car"
}
```

------
#### [ Sample response ]

```
{
    "Notices": [],
    "SnappedGeometry": {
        "Polyline": "Redacted"
    },
    "SnappedGeometryFormat": "FlexiblePolyline",
    "SnappedTracePoints": [
        {
            "Confidence": 1,
            "OriginalPosition": [8.53404, 50.16364],
            "SnappedPosition": [8.53402, 50.16367]
        },
        {
            "Confidence": 0.86,
            "OriginalPosition": [8.53379056, 50.16352417],
            "SnappedPosition": [8.53375, 50.16356]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/snap-to-roads?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "TracePoints": [
    {
      "Position": [8.53404,50.16364],
      "Timestamp": "2024-05-22T18:13:42Z"
    },
    {
      "Position": [8.53379056,50.16352417],
      "Speed": 20,
      "Timestamp": "2024-05-22T18:13:59Z"
    }
  ],
  "TravelMode": "Car"
}'
```

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

```
aws geo-routes snap-to-roads --key ${YourKey} \
--trace-points '[{"Position": [8.53404, 50.16364], "Timestamp": "2024-05-22T18:13:42Z"}, {"Position": [8.53379056, 50.16352417], "Speed": 20, "Timestamp": "2024-05-22T18:13:59Z"}]' \
--travel-mode "Car"
```

------

### 使用卡車模式搭配選項來比對 GPS 追蹤
<a name="match-gps-truck-mode-options"></a>

------
#### [ Sample request ]

```
{
  "TracePoints": [
    {
      "Position": [8.53404,50.16364],
      "Timestamp": "2024-05-22T18:13:42Z"
    },
    {
      "Position": [8.53379056,50.16352417],
      "Speed": 20,
      "Timestamp": "2024-05-22T18:13:59Z"
    }
  ],
  "TravelMode": "Truck",
  "TravelModeOptions": {
    "Truck": {
      "GrossWeight": 10000
    }
  }
}
```

------
#### [ Sample response ]

```
{
    "Notices": [],
    "SnappedGeometry": {
        "Polyline": "Redacted"
    },
    "SnappedGeometryFormat": "FlexiblePolyline",
    "SnappedTracePoints": [
        {
            "Confidence": 1,
            "OriginalPosition": [8.53404, 50.16364],
            "SnappedPosition": [8.53402, 50.16367]
        },
        {
            "Confidence": 0.86,
            "OriginalPosition": [8.53379056, 50.16352417],
            "SnappedPosition": [8.53375, 50.16356]
        }
    ]
}
```

------
#### [ cURL ]

```
curl --request POST \
  --url 'https://routes.geo.eu-central-1.amazonaws.com/v2/snap-to-roads?key=Your_key' \
  --header 'Content-Type: application/json' \
  --data '{
  "TracePoints": [
    {
      "Position": [8.53404,50.16364],
      "Timestamp": "2024-05-22T18:13:42Z"
    },
    {
      "Position": [8.53379056,50.16352417],
      "Speed": 20,
      "Timestamp": "2024-05-22T18:13:59Z"
    }
  ],
  "TravelMode": "Truck",
  "TravelModeOptions": {
    "Truck": {
      "GrossWeight": 10000
    }
  }
}'
```

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

```
aws geo-routes snap-to-roads --key ${YourKey} \
--trace-points '[{"Position": [8.53404, 50.16364], "Timestamp": "2024-05-22T18:13:42Z"}, {"Position": [8.53379056, 50.16352417], "Speed": 20, "Timestamp": "2024-05-22T18:13:59Z"}]' \
--travel-mode "Truck" \
--travel-mode-options '{"Truck": {"GrossWeight": 10000}}'
```

------

# 管理成本和用量
<a name="routes-whats-next"></a>

當您繼續了解 Amazon Location 路由時，請務必了解如何管理服務容量、確保遵循用量限制，並透過配額和 API 最佳化獲得最佳結果。透過套用效能和準確性的最佳實務，您可以自訂應用程式以有效率地處理與位置相關的查詢，並最大化您的 API 請求。

**Topics**
+ [最佳實務](routes-best-practices.md)
+ [路由定價](routes-pricing.md)
+ [Routes Quota 和用量](routes-quota-usage.md)

# 最佳實務
<a name="routes-best-practices"></a>

本節涵蓋在與 API 互動時使用壓縮以及在 Simple (GeoJSON) 和 FlexiblePolyline 格式之間進行選擇的最佳實務，提供最佳化效能、頻寬和資料處理的指引。

## 壓縮
<a name="compression"></a>

為了增強應用程式與 API 互動時的效能和效率，建議針對回應啟用壓縮，尤其是在處理大型文字型承載時。您可以在 API 請求中包含 `Accept-Encoding`標頭來啟用壓縮，並指定您偏好的壓縮方法。我們支援 `gzip`和 `deflate` 的壓縮功能，`gzip`通常提供更好的壓縮比率。

### 啟用壓縮的時機
<a name="when-to-enable-compression"></a>

**大型回應**  
針對大型文字型回應啟用壓縮，以減少頻寬使用量並改善載入時間。

**網路限制條件**  
如果您的應用程式透過有限頻寬或高延遲網路運作，壓縮可以增強資料傳輸效率。

### 如何有效使用壓縮
<a name="how-to-use-compression-effectively"></a>

**設定接受編碼標頭**  
在您的 HTTP 請求`Accept-Encoding: gzip, deflate`中包含 ，以通知我們的 API 您支援這些壓縮方法。啟用和處理壓縮的方法因 [AWS 開發套件](https://docs.aws.amazon.com/sdkref/latest/guide/overview.html)和程式設計語言而異。例如，適用於 [Java 的 AWS 開發套件 v1](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ClientConfiguration.html#withGzip-boolean-) 使用 `ClientConfiguration`類別中的 `withGzip`方法來啟用 gzip，而適用於 Go 的 AWS 開發套件則需要新增特定中介軟體以進行壓縮處理。如需其他 SDKs，請參閱 [AWS 開發套件參考指南](https://docs.aws.amazon.com/sdkref/latest/guide/overview.html)以取得詳細說明。

**正確處理解壓縮**  
確保您的用戶端應用程式可以根據 API 傳回的`Content-Encoding`標頭正確解壓縮回應。

**測試和監控**  
定期評估壓縮對您應用程式效能的影響，平衡降低承載大小與解壓縮程序中任何額外 CPU 額外負荷的優點。

## 折線
<a name="polyline"></a>

與我們的 API 互動時，在 Simple (GeoJSON) 和 FlexiblePolyline 格式之間進行選擇的最佳實務，以最佳化地理空間資料的效能和可用性。

### 使用 Simple (GeoJSON) 格式
<a name="use-simple-format"></a>

**可讀性和標準化**  
當您需要廣為人知且可讀的格式，以便於偵錯和與各種地理空間工具的互通性時使用。

**精確度**  
當您的應用程式需要高精度的座標時，請選擇簡易格式，因為 GeoJSON 會維持完整的十進位精度而不會遺失。

**較小的資料集**  
使用較小的座標資料集時，簡單格式是理想的選擇，其中壓縮的大小縮減優勢最少。

### 使用 FlexiblePolyline 格式
<a name="use-flexiblepolyline-format"></a>

**資料大小縮減**  
FlexiblePolyline 非常適合當您需要利用失真壓縮技術將傳輸的資料量降至最低時，特別是對於大型座標清單。

**URL 安全性**  
FlexiblePolyline 提供精簡且 URL 安全的字串，可直接用於查詢參數，無需額外的編碼。

**效能最佳化**  
FlexiblePolyline 有助於減少承載大小，進而加快資料傳輸速度並降低頻寬使用量，因此對於高效能應用程式或受限網路的操作至關重要。

# 路由定價
<a name="routes-pricing"></a>

請參閱以下每個 API 的定價儲存貯體：

## 計算路由
<a name="calculate-routes-price"></a>

此價格是根據 API 請求的數量。 `CalculateRoutes`有三個定價儲存貯體：Core、Advanced 和 Premium。

**核心**  
此價格儲存貯體支援 Car、Truck 和 Pedestrian 的旅程模式，無需過路費計算。

**Advanced (進階)**  
此價格儲存貯體支援替代的旅遊模式，例如 Scooter，無需過路費計算。

**高級**  
此價格儲存貯體支援過路費計算。當您透過設定請求參數 `LegAdditionalFeatures["Tolls"]`或 來請求過路費計算時，無論行程模式為何`SpanAdditionalFeatures["TollSystems"]`，都會向您收取 Premium 價格的費用。

## 計算路由矩陣
<a name="calculate-route-matri-price"></a>

此價格是根據計算的路由數。每個請求中計算的路由數量等於原始伺服器數量乘以目的地數量 `Number of Routes = Number of origins x Number of Destinations`。例如，在 100 個目的地使用 300 個原始伺服器的矩陣大小時，計算出的路由總數為 30，000 (300 x 100 = 30，000)。

**注意**  
路由計算會針對每個原始伺服器和目的地對計費。如果您使用大型的原始伺服器和目的地矩陣，您的成本將相應增加。

`CalculateRouteMatrix` 有 2 個定價儲存貯體：Core 和 Advanced。

**核心**  
此價格儲存貯體支援 Car、Truck 和 Pedestrian 的旅遊模式。

**Advanced (進階)**  
此價格儲存貯體支援替代行程模式，例如 Scooter。

## 最佳化航點
<a name="optimize-waypoint-price"></a>

此價格是根據 API 請求的數量。 `OptimizeWaypoint`有 2 個定價儲存貯體：進階和進階。

**Advanced (進階)**  
 此定價儲存貯體在單一請求中最多支援 30 個航點；Car、Truck 和 Pedestrian 的旅程模式，輸入點的週框方塊在 200 公里內，沒有選用參數，例如 `Avoid`、、`Clustering`、`Driver``Exclude.Countries``TravelModeOptions.Truck.HazardousCargos`、`TravelModeOptions.Truck.TunnelRestrictionCode`、、，以及沒有其他航點或目的地限制，例如 `AccessHours`、`AppointmentTime`、`Before``Heading`、、、`ServiceDuration`、、`SideOfStreet`。  
自動叢集可能會在路徑點接近時發生，但仍視為進階定價儲存貯體。

**高級**  
 此定價儲存貯體在單一請求中最多支援 50 個航點；不限制行程模式；在 500 公里內輸入點的週框方塊；以及選用參數，例如 `Avoid`、`Clustering`、`Driver``Exclude.Countries`、`TravelModeOptions.Truck.HazardousCargos`、、`TravelModeOptions.Truck.TunnelRestrictionCode`。此外，此定價儲存貯體支援選用的航點和目的地限制條件，例如 `AccessHours`、`AppointmentTime`、`Before`、`Heading`、`ServiceDuration`、`SideOfStreet`。  
如果套用任何選用的航點和目的地限制，則單一請求最多只能支援 20 個航點。

## Snap-to-road
<a name="snap-to-road-price"></a>

此價格是根據 API 請求的數量。 `SnaptoRoad`有 2 個定價儲存貯體：進階和進階。

**Advanced (進階)**  
此定價儲存貯體支援旅行模式 Car、Truck 和 Pedestrian，`TracePoints`計數高達 200，且飛行距離上限為 `TracePoints` 100 公里。

**高級**  
此定價儲存貯體對旅遊模式沒有限制，最多 5，000 `TracePoints`點。

## 計算 Isoline
<a name="calculate-isoline-price"></a>

此價格是根據回應中計算的等線數。 `CalculateIsolines`有 2 個定價儲存貯體：進階和進階。

**Advanced (進階)**  
此定價儲存貯體支援旅行模式 Car、Truck 和 Pedestrian，`Thresholds.Time`其值高達 60 分鐘，`Thresholds.Distance`或值高達 100 公里。

**高級**  
此定價儲存貯體對行程模式沒有限制，`Thresholds.Time`值上限為 180 分鐘，`Thresholds.Distance`值上限為 300KM。

# Routes Quota 和用量
<a name="routes-quota-usage"></a>

## 服務配額
<a name="service-quota"></a>

Amazon Location Service APIs 具有預設配額。您可以使用[服務配額主控台增加配額](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)。若限制超過預設值的 2 倍，請透過自助式主控台或聯絡支援。


**Service Quota 限制**  

| API 名稱 | 預設 | 最大可調整限制 | 超過可調整的最大限制 | 
| --- | --- | --- | --- | 
| [計算路由](calculate-routes.md) | 20 | 40 | 請求[服務配額主控台](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)或聯絡支援團隊 | 
| [計算等線](calculate-isolines.md) | 20 | 40 | 請求[服務配額主控台](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)或聯絡支援團隊 | 
| [快照至道路](snap-to-roads.md) | 20 | 40 | 請求[服務配額主控台](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)或聯絡支援團隊 | 
| [計算路由矩陣](calculate-route-matrix.md) | 5 | 10 | 請求[服務配額主控台](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)或聯絡支援團隊 | 
| [最佳化路徑點](actions-optimize-waypoints.md) | 5 | 10 | 請求[服務配額主控台](https://console.aws.amazon.com/servicequotas/home#!/services/geo/quotas)或聯絡支援團隊 | 

## 其他用量限制
<a name="other-usage-limits"></a>

除了服務配額之外，還適用下列 API 用量限制：


**其他用量限制**  

| API 名稱 | 限制 | Value | 
| --- | --- | --- | 
| [快照至道路](snap-to-roads.md) | 所有 TracePoints 之間的幾何距離總和 | 500KM | 
| [最佳化路徑點](actions-optimize-waypoints.md) | 原始伺服器、所提供排序中的航點和目的地之間的地理位置距離總和 | 100KM | 
| [最佳化路徑點](actions-optimize-waypoints.md) | 圍繞原始伺服器、航點和目的地的週框方塊周邊 | 500KM | 
| [計算路由矩陣](calculate-route-matrix.md) | 未限制路由的原始伺服器與目的地之間的最大距離 （如果使用 Avoid 或 TravelModeOptions.Truck) | 60KM | 
| [計算路由矩陣](calculate-route-matrix.md) | 原始伺服器與無限制路由目的地之間的最大距離 | 10000KM | 
| [計算路由](calculate-routes.md) | 壓縮後的回應承載大小 | 6MB | 
| [計算路由矩陣](calculate-route-matrix.md) | 壓縮後的回應承載大小 | 6MB | 
| [計算等線](calculate-isolines.md) | 壓縮後的回應承載大小 | 6MB | 
| [最佳化路徑點](actions-optimize-waypoints.md) | 壓縮後的回應承載大小 | 6MB | 
| [快照至道路](snap-to-roads.md) | 壓縮後的回應承載大小 | 6MB | 

## 後續步驟
<a name="next-steps"></a>

如需更多詳細資訊，請參閱下列內容：
+ [屬性](https://docs.aws.amazon.com/location/latest/developerguide/data-attribution.html)：Amazon Location Service 的資料屬性需求相關資訊。
+ [SLA](https://aws.amazon.com/location/sla/)：Amazon Location Service 的服務層級協議，包括運作時間承諾和回應時間。
+ [服務條款](https://aws.amazon.com/service-terms/)：管理 Amazon Location Service 使用的條款，包括限制和約束。