calculate_route
¶
calculate_route(
calculator_name: ResourceName,
departure_position: Position,
destination_position: Position,
*,
config_overrides: Optional[LocationClientConfig] = None,
waypoint_positions: Optional[WaypointPositionList] = None,
travel_mode: Optional[TravelMode] = None,
departure_time: Optional[Timestamp] = None,
depart_now: Optional[SensitiveBoolean] = None,
distance_unit: Optional[DistanceUnit] = None,
include_leg_geometry: Optional[SensitiveBoolean] = None,
car_mode_options: Optional[CalculateRouteCarModeOptions] = None,
truck_mode_options: Optional[CalculateRouteTruckModeOptions] = None,
arrival_time: Optional[Timestamp] = None,
optimize_for: Optional[OptimizationMode] = None,
key: Optional[ApiKey] = None,
) -> CalculateRouteResponse
This operation is no longer current and may be deprecated in the future. We recommend you upgrade to The version 2 If you are using an Amazon Web Services SDK or the Amazon Web Services CLI, note that the Routes API version 2 is found under Since Grab is not yet fully supported in Routes API version 2, we recommend you continue using API version 1 when using Grab.CalculateRoutes or CalculateIsolines unless you require Grab data.
CalculateRoute is part of a previous Amazon Location Service Routes API (version 1) which has been superseded by a more intuitive, powerful, and complete API (version 2).CalculateRoutes operation gives better results for point-to-point routing, while the version 2 CalculateIsolines operation adds support for calculating service areas and travel time envelopes.geo-routes or geo_routes, not under location.
Calculates a route given the following required parameters: DeparturePosition and DestinationPosition. Requires that you first create a route calculator resource.
By default, a request that doesn't specify a departure time uses the best time of day to travel with the best traffic conditions when calculating the route.
Additional options include:
-
Specifying a departure time using either
DepartureTimeorDepartNow. This calculates a route based on predictive traffic data at the given time.You can't specify both
DepartureTimeandDepartNowin a single request. Specifying both parameters returns a validation error. -
Specifying a travel mode using TravelMode sets the transportation mode used to calculate the routes. This also lets you specify additional route preferences in
CarModeOptionsif traveling byCar, orTruckModeOptionsif traveling byTruck.If you specify
walkingfor the travel mode and your data provider is Esri, the start and destination must be within 40km.
Parameters:
-
calculator_name(ResourceName) –The name of the route calculator resource that you want to use to calculate the route.
-
departure_position(Position) –The start position for the route. Defined in World Geodetic System (WGS 84) format:
[longitude, latitude].-
For example,
[-123.115, 49.285]
If you specify a departure that's not located on a road, Amazon Location moves the position to the nearest road. If Esri is the provider for your route calculator, specifying a route that is longer than 400 km returns a
400 RoutesValidationExceptionerror.Valid Values:
[-180 to 180,-90 to 90] -
-
destination_position(Position) –The finish position for the route. Defined in World Geodetic System (WGS 84) format:
[longitude, latitude].-
For example,
[-122.339, 47.615]
If you specify a destination that's not located on a road, Amazon Location moves the position to the nearest road.
Valid Values:
[-180 to 180,-90 to 90] -
-
waypoint_positions(Optional[WaypointPositionList], default:None) –Specifies an ordered list of up to 23 intermediate positions to include along a route between the departure position and destination position.
-
For example, from the
DeparturePosition[-123.115, 49.285], the route follows the order that the waypoint positions are given[[-122.757, 49.0021],[-122.349, 47.620]]
If you specify a waypoint position that's not located on a road, Amazon Location moves the position to the nearest road.
Specifying more than 23 waypoints returns a
400 ValidationExceptionerror.If Esri is the provider for your route calculator, specifying a route that is longer than 400 km returns a
400 RoutesValidationExceptionerror.Valid Values:
[-180 to 180,-90 to 90] -
-
travel_mode(Optional[TravelMode], default:None) –Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. You can choose
Car,Truck,Walking,BicycleorMotorcycleas options for theTravelMode.BicycleandMotorcycleare only valid when using Grab as a data provider, and only within Southeast Asia.Truckis not available for Grab.For more details on the using Grab for routing, including areas of coverage, see GrabMaps in the Amazon Location Service Developer Guide.
The
TravelModeyou specify also determines how you specify route preferences:-
If traveling by
Caruse theCarModeOptionsparameter. -
If traveling by
Truckuse theTruckModeOptionsparameter.
Default Value:
Car -
-
departure_time(Optional[Timestamp], default:None) –Specifies the desired time of departure. Uses the given time to calculate the route. Otherwise, the best time of day to travel with the best traffic conditions is used to calculate the route.
-
In ISO 8601 format:
YYYY-MM-DDThh:mm:ss.sssZ. For example,2020–07-2T12:15:20.000Z+01:00
-
-
depart_now(Optional[SensitiveBoolean], default:None) –Sets the time of departure as the current time. Uses the current time to calculate a route. Otherwise, the best time of day to travel with the best traffic conditions is used to calculate the route.
Default Value:
falseValid Values:
false|true -
distance_unit(Optional[DistanceUnit], default:None) –Set the unit system to specify the distance.
Default Value:
Kilometers -
include_leg_geometry(Optional[SensitiveBoolean], default:None) –Set to include the geometry details in the result for each path between a pair of positions.
Default Value:
falseValid Values:
false|true -
car_mode_options(Optional[CalculateRouteCarModeOptions], default:None) –Specifies route preferences when traveling by
Car, such as avoiding routes that use ferries or tolls.Requirements:
TravelModemust be specified asCar. -
truck_mode_options(Optional[CalculateRouteTruckModeOptions], default:None) –Specifies route preferences when traveling by
Truck, such as avoiding routes that use ferries or tolls, and truck specifications to consider when choosing an optimal road.Requirements:
TravelModemust be specified asTruck. -
arrival_time(Optional[Timestamp], default:None) –Specifies the desired time of arrival. Uses the given time to calculate the route. Otherwise, the best time of day to travel with the best traffic conditions is used to calculate the route.
ArrivalTime is not supported Esri.
-
optimize_for(Optional[OptimizationMode], default:None) –Specifies the distance to optimize for when calculating a route.
-
key(Optional[ApiKey], default:None) –The optional API key to authorize the request.
Raises:
-
AccessDeniedException–The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions.
-
InternalServerException–The request has failed to process because of an unknown server error, exception, or failure.
-
ResourceNotFoundException–The resource that you've entered was not found in your AWS account.
-
ThrottlingException–The request was denied because of request throttling.
-
ValidationException–The input failed to meet the constraints specified by the AWS service.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_location/_services/location.py
3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 | |