/AWS1/IF_LOC=>CALCULATEROUTE()¶
About CalculateRoute¶
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.
Method Signature¶
METHODS /AWS1/IF_LOC~CALCULATEROUTE
IMPORTING
!IV_CALCULATORNAME TYPE /AWS1/LOCRESOURCENAME OPTIONAL
!IT_DEPARTUREPOSITION TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITION OPTIONAL
!IT_DESTINATIONPOSITION TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITION OPTIONAL
!IT_WAYPOINTPOSITIONS TYPE /AWS1/CL_LOCPOSITION_W=>TT_WAYPOINTPOSITIONLIST OPTIONAL
!IV_TRAVELMODE TYPE /AWS1/LOCTRAVELMODE OPTIONAL
!IV_DEPARTURETIME TYPE /AWS1/LOCTIMESTAMP OPTIONAL
!IV_DEPARTNOW TYPE /AWS1/LOCSENSITIVEBOOLEAN OPTIONAL
!IV_DISTANCEUNIT TYPE /AWS1/LOCDISTANCEUNIT OPTIONAL
!IV_INCLUDELEGGEOMETRY TYPE /AWS1/LOCSENSITIVEBOOLEAN OPTIONAL
!IO_CARMODEOPTIONS TYPE REF TO /AWS1/CL_LOCCALCULATEROUTECA00 OPTIONAL
!IO_TRUCKMODEOPTIONS TYPE REF TO /AWS1/CL_LOCCALCULATEROUTETR00 OPTIONAL
!IV_ARRIVALTIME TYPE /AWS1/LOCTIMESTAMP OPTIONAL
!IV_OPTIMIZEFOR TYPE /AWS1/LOCOPTIMIZATIONMODE OPTIONAL
!IV_KEY TYPE /AWS1/LOCAPIKEY OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_loccalculateroutersp
RAISING
/AWS1/CX_LOCACCESSDENIEDEX
/AWS1/CX_LOCINTERNALSERVEREX
/AWS1/CX_LOCRESOURCENOTFOUNDEX
/AWS1/CX_LOCTHROTTLINGEX
/AWS1/CX_LOCVALIDATIONEX
/AWS1/CX_LOCCLIENTEXC
/AWS1/CX_LOCSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_calculatorname TYPE /AWS1/LOCRESOURCENAME /AWS1/LOCRESOURCENAME¶
The name of the route calculator resource that you want to use to calculate the route.
it_departureposition TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITION TT_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]
it_destinationposition TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITION TT_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]
Optional arguments:¶
it_waypointpositions TYPE /AWS1/CL_LOCPOSITION_W=>TT_WAYPOINTPOSITIONLIST TT_WAYPOINTPOSITIONLIST¶
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]
iv_travelmode TYPE /AWS1/LOCTRAVELMODE /AWS1/LOCTRAVELMODE¶
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
iv_departuretime TYPE /AWS1/LOCTIMESTAMP /AWS1/LOCTIMESTAMP¶
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
iv_departnow TYPE /AWS1/LOCSENSITIVEBOOLEAN /AWS1/LOCSENSITIVEBOOLEAN¶
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
iv_distanceunit TYPE /AWS1/LOCDISTANCEUNIT /AWS1/LOCDISTANCEUNIT¶
Set the unit system to specify the distance.
Default Value:
Kilometers
iv_includeleggeometry TYPE /AWS1/LOCSENSITIVEBOOLEAN /AWS1/LOCSENSITIVEBOOLEAN¶
Set to include the geometry details in the result for each path between a pair of positions.
Default Value:
falseValid Values:
false|true
io_carmodeoptions TYPE REF TO /AWS1/CL_LOCCALCULATEROUTECA00 /AWS1/CL_LOCCALCULATEROUTECA00¶
Specifies route preferences when traveling by
Car, such as avoiding routes that use ferries or tolls.Requirements:
TravelModemust be specified asCar.
io_truckmodeoptions TYPE REF TO /AWS1/CL_LOCCALCULATEROUTETR00 /AWS1/CL_LOCCALCULATEROUTETR00¶
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.
iv_arrivaltime TYPE /AWS1/LOCTIMESTAMP /AWS1/LOCTIMESTAMP¶
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.
iv_optimizefor TYPE /AWS1/LOCOPTIMIZATIONMODE /AWS1/LOCOPTIMIZATIONMODE¶
Specifies the distance to optimize for when calculating a route.
iv_key TYPE /AWS1/LOCAPIKEY /AWS1/LOCAPIKEY¶
The optional API key to authorize the request.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_loccalculateroutersp /AWS1/CL_LOCCALCULATEROUTERSP¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->calculateroute(
io_carmodeoptions = new /aws1/cl_loccalculaterouteca00(
iv_avoidferries = ABAP_TRUE
iv_avoidtolls = ABAP_TRUE
)
io_truckmodeoptions = new /aws1/cl_loccalculateroutetr00(
io_dimensions = new /aws1/cl_loctruckdimensions(
iv_height = '0.1'
iv_length = '0.1'
iv_unit = |string|
iv_width = '0.1'
)
io_weight = new /aws1/cl_loctruckweight(
iv_total = '0.1'
iv_unit = |string|
)
iv_avoidferries = ABAP_TRUE
iv_avoidtolls = ABAP_TRUE
)
it_departureposition = VALUE /aws1/cl_locposition_w=>tt_position(
( new /aws1/cl_locposition_w( |0.1| ) )
)
it_destinationposition = VALUE /aws1/cl_locposition_w=>tt_position(
( new /aws1/cl_locposition_w( |0.1| ) )
)
it_waypointpositions = VALUE /aws1/cl_locposition_w=>tt_waypointpositionlist(
(
VALUE /aws1/cl_locposition_w=>tt_position(
( new /aws1/cl_locposition_w( |0.1| ) )
)
)
)
iv_arrivaltime = '20150101000000.0000000'
iv_calculatorname = |string|
iv_departnow = ABAP_TRUE
iv_departuretime = '20150101000000.0000000'
iv_distanceunit = |string|
iv_includeleggeometry = ABAP_TRUE
iv_key = |string|
iv_optimizefor = |string|
iv_travelmode = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
LOOP AT lo_result->get_legs( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
LOOP AT lo_row_1->get_startposition( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
LOOP AT lo_row_1->get_endposition( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
lv_sensitivedouble = lo_row_1->get_distance( ).
lv_sensitivedouble = lo_row_1->get_durationseconds( ).
lo_leggeometry = lo_row_1->get_geometry( ).
IF lo_leggeometry IS NOT INITIAL.
LOOP AT lo_leggeometry->get_linestring( ) into lt_row_4.
LOOP AT lt_row_4 into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
LOOP AT lo_row_1->get_steps( ) into lo_row_5.
lo_row_6 = lo_row_5.
IF lo_row_6 IS NOT INITIAL.
LOOP AT lo_row_6->get_startposition( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
LOOP AT lo_row_6->get_endposition( ) into lo_row_2.
lo_row_3 = lo_row_2.
IF lo_row_3 IS NOT INITIAL.
lv_double = lo_row_3->get_value( ).
ENDIF.
ENDLOOP.
lv_sensitivedouble = lo_row_6->get_distance( ).
lv_sensitivedouble = lo_row_6->get_durationseconds( ).
lv_integer = lo_row_6->get_geometryoffset( ).
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
lo_calculateroutesummary = lo_result->get_summary( ).
IF lo_calculateroutesummary IS NOT INITIAL.
LOOP AT lo_calculateroutesummary->get_routebbox( ) into lo_row_7.
lo_row_8 = lo_row_7.
IF lo_row_8 IS NOT INITIAL.
lv_double = lo_row_8->get_value( ).
ENDIF.
ENDLOOP.
lv_string = lo_calculateroutesummary->get_datasource( ).
lv_sensitivedouble = lo_calculateroutesummary->get_distance( ).
lv_sensitivedouble = lo_calculateroutesummary->get_durationseconds( ).
lv_distanceunit = lo_calculateroutesummary->get_distanceunit( ).
ENDIF.
ENDIF.