Calculate Route
Calculate Routes
Route Request
Route Style
Route Style | Description |
---|---|
Fastest | Prefer routes with less travel time. Travel time is the most important factor, but not the only one. This is the only route style that considers live traffic conditions as a main factor. Other styles only consider traffic as a minor factor, so usually only blocking traffic can be avoided. |
Shortest | Prefer routes with shorter distances. Distance is the most important factor, but not the only one. |
Eco | Prefer economical routes that use less fuel. |
Easy | Prefer routes with fewer turns and wider roads. |
Route Reference Options
route reference options list avoid items.
Reference Options | Description | Default |
---|---|---|
avoid hov road | to avoid High-Occupancy Vehicle (HOV) lanes. | false |
avoid highway | to avoid highway roads. | false |
avoid toll road | to avoid toll roads. | false |
avoid ferry | to avoid ferry. | false |
avoid car train | to avoid car train ferry. | false |
avoid unpaved road | to avoid roads those surfaces are not solid (e.g., gravel, dirt or grass). | false |
avoid tunnel | to avoid tunnel. | false |
avoid traffic congestion | to avoid congested roads. | true |
avoid traffic closures | to avoid traffic closure roads strictly. Note: the routing calculation will treat them as broken networks and it may lead to failures if it's set to true. Otherwize routes including closure roads may be provided if it turns to false | true |
avoid country border | to avoid crossing country if origin and destination are located in same country. | false |
avoid sharp turn | to avoid sharp turn for safety. especially for big size car. | false |
avoid roads with permission | to avoid roads that entering roads needs permision. | true |
avoid roads with sesonal restrictions | to avoid roads those open or closed affected by seasonl. | true |
avoid designated road segments | to avoid designated road segments | false |
enable safety route | enable route safety calculation which indicates if there is a potential travel risk. Note: the calculation of route safety is facilitated through an auxiliary cloud service which needs imperative configuration within your project context. Otherwise it will be not available even if this option is enabled. | false |
Other Request Options
- Consider heading and car driving speed: Based on heading and speed, the SDK will avoid the intersection when the system identifies a road that users may not have enough time to react to until a suitable road appears.
- Support multiple routes calculating in the same route style.
- Support multiple waypoints.
Create a route request
Request a simple route with origin and destination
A route request is created through the route request builder by providing at least the origin and destination, as shown in the example below .
Request a route in a specific heading & speed
With the SDK, you can consider the direction a user’s device is facing and request a route starting in a specific direction. To receive a route in a specific direction (for example, the direction a user is traveling or the direction a device is facing), pass in the user’s location heading and speed values. These values can be retrieved from map matching result, please refer to Position Engine section.
Request a route with multiple stops
Besides the final destination, the SDK allows for more stopover locations. If your route involves several pick-up and drop-off points, you can add up to 10 waypoints to the request. These coordinates will be treated as stops between the origin and destination in the order you add them — first comes first.
Request a route with route preferences
A RoutePreference object can also be provided for the request, in order to set customized options.
Calculate a Route
A request is processed through a task, which will finally provide the results through a callback. In the callback, an error code will be provided to indicate the general processing result. Also, a response will be provided with detailed routes if the calculation can be performed properly. For more details, please refer to the corresponding section.
Calulate onboard route
Here is an example of offline route calculation.
Calulate offboard route
Before doing the offboard route, you should set the cloud URL,API key, and secret for accessing cloud services. For details, please refer to Set cloud URL when intialization