/AWS1/IF_LOC=>CALCULATEROUTEMATRIX()¶
About CalculateRouteMatrix¶
This operation is no longer current and may be deprecated in the future. We recommend you upgrade to the V2 This version of 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. Start your version 2 API journey with the Routes V2 API Reference or the Developer Guide.CalculateRouteMatrix unless you require Grab data.
CalculateRouteMatrix 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).CalculateRouteMatrix operation gives better results for matrix routing calculations.geo-routes or geo_routes, not under location.
Calculates a route matrix given the following required parameters: DeparturePositions and DestinationPositions. CalculateRouteMatrix calculates routes and returns the travel time and travel distance from each departure position to each destination position in the request. For example, given departure positions A and B, and destination positions X and Y, CalculateRouteMatrix will return time and distance for routes from A to X, A to Y, B to X, and B to Y (in that order). The number of results returned (and routes calculated) will be the number of DeparturePositions times the number of DestinationPositions.
Your account is charged for each route calculated, not the number of requests.
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 routes.
Additional options include:
-
Specifying a departure time using either
DepartureTimeorDepartNow. This calculates routes 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.
Method Signature¶
METHODS /AWS1/IF_LOC~CALCULATEROUTEMATRIX
IMPORTING
!IV_CALCULATORNAME TYPE /AWS1/LOCRESOURCENAME OPTIONAL
!IT_DEPARTUREPOSITIONS TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITIONLIST OPTIONAL
!IT_DESTINATIONPOSITIONS TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITIONLIST 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
!IO_CARMODEOPTIONS TYPE REF TO /AWS1/CL_LOCCALCULATEROUTECA00 OPTIONAL
!IO_TRUCKMODEOPTIONS TYPE REF TO /AWS1/CL_LOCCALCULATEROUTETR00 OPTIONAL
!IV_KEY TYPE /AWS1/LOCAPIKEY OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_loccalculateroutema01
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 matrix.
it_departurepositions TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITIONLIST TT_POSITIONLIST¶
The list of departure (origin) positions for the route matrix. An array of points, each of which is itself a 2-value array defined in WGS 84 format:
[longitude, latitude]. For example,[-123.115, 49.285].Depending on the data provider selected in the route calculator resource there may be additional restrictions on the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
For route calculators that use Esri as the data provider, if you specify a departure that's not located on a road, Amazon Location moves the position to the nearest road. The snapped value is available in the result in
SnappedDeparturePositions.Valid Values:
[-180 to 180,-90 to 90]
it_destinationpositions TYPE /AWS1/CL_LOCPOSITION_W=>TT_POSITIONLIST TT_POSITIONLIST¶
The list of destination positions for the route matrix. An array of points, each of which is itself a 2-value array defined in WGS 84 format:
[longitude, latitude]. For example,[-122.339, 47.615]Depending on the data provider selected in the route calculator resource there may be additional restrictions on the inputs you can choose. See Position restrictions in the Amazon Location Service Developer Guide.
For route calculators that use Esri as the data provider, if you specify a destination that's not located on a road, Amazon Location moves the position to the nearest road. The snapped value is available in the result in
SnappedDestinationPositions.Valid Values:
[-180 to 180,-90 to 90]
Optional arguments:¶
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.
The
TravelModeyou specify also determines how you specify route preferences:
If traveling by
Caruse theCarModeOptionsparameter.If traveling by
Truckuse theTruckModeOptionsparameter.
BicycleorMotorcycleare only valid when usingGrabas a data provider, and only within Southeast Asia.
Truckis not available for Grab.For more information about using Grab as a data provider, see GrabMaps in the Amazon Location Service Developer Guide.
Default Value:
Car
iv_departuretime TYPE /AWS1/LOCTIMESTAMP /AWS1/LOCTIMESTAMP¶
Specifies the desired time of departure. Uses the given time to calculate the route matrix. You can't set both
DepartureTimeandDepartNow. If neither is set, the best time of day to travel with the best traffic conditions is used to calculate the route matrix.Setting a departure time in the past returns a
400 ValidationExceptionerror.
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 the route matrix. You can't set both
DepartureTimeandDepartNow. If neither is set, the best time of day to travel with the best traffic conditions is used to calculate the route matrix.Default Value:
falseValid Values:
false|true
iv_distanceunit TYPE /AWS1/LOCDISTANCEUNIT /AWS1/LOCDISTANCEUNIT¶
Set the unit system to specify the distance.
Default Value:
Kilometers
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_key TYPE /AWS1/LOCAPIKEY /AWS1/LOCAPIKEY¶
The optional API key to authorize the request.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_loccalculateroutema01 /AWS1/CL_LOCCALCULATEROUTEMA01¶
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->calculateroutematrix(
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_departurepositions = VALUE /aws1/cl_locposition_w=>tt_positionlist(
(
VALUE /aws1/cl_locposition_w=>tt_position(
( new /aws1/cl_locposition_w( |0.1| ) )
)
)
)
it_destinationpositions = VALUE /aws1/cl_locposition_w=>tt_positionlist(
(
VALUE /aws1/cl_locposition_w=>tt_position(
( new /aws1/cl_locposition_w( |0.1| ) )
)
)
)
iv_calculatorname = |string|
iv_departnow = ABAP_TRUE
iv_departuretime = '20150101000000.0000000'
iv_distanceunit = |string|
iv_key = |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_routematrix( ) into lt_row.
LOOP AT lt_row into lo_row_1.
lo_row_2 = lo_row_1.
IF lo_row_2 IS NOT INITIAL.
lv_sensitivedouble = lo_row_2->get_distance( ).
lv_sensitivedouble = lo_row_2->get_durationseconds( ).
lo_routematrixentryerror = lo_row_2->get_error( ).
IF lo_routematrixentryerror IS NOT INITIAL.
lv_routematrixerrorcode = lo_routematrixentryerror->get_code( ).
lv_string = lo_routematrixentryerror->get_message( ).
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT lo_result->get_snappeddeparturepositi00( ) into lt_row_3.
LOOP AT lt_row_3 into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_double = lo_row_5->get_value( ).
ENDIF.
ENDLOOP.
ENDLOOP.
LOOP AT lo_result->get_snappeddstpositions( ) into lt_row_3.
LOOP AT lt_row_3 into lo_row_4.
lo_row_5 = lo_row_4.
IF lo_row_5 IS NOT INITIAL.
lv_double = lo_row_5->get_value( ).
ENDIF.
ENDLOOP.
ENDLOOP.
lo_calculateroutematrixsum = lo_result->get_summary( ).
IF lo_calculateroutematrixsum IS NOT INITIAL.
lv_string = lo_calculateroutematrixsum->get_datasource( ).
lv_integer = lo_calculateroutematrixsum->get_routecount( ).
lv_integer = lo_calculateroutematrixsum->get_errorcount( ).
lv_distanceunit = lo_calculateroutematrixsum->get_distanceunit( ).
ENDIF.
ENDIF.