Skip to content

calculate_route_matrix async

calculate_route_matrix(
    destinations: RouteMatrixDestinationList,
    origins: RouteMatrixOriginList,
    *,
    config_overrides: Optional[AsyncGeoRoutesClientConfig] = None,
    allow: Optional[RouteMatrixAllowOptions] = None,
    avoid: Optional[RouteMatrixAvoidanceOptions] = None,
    depart_now: Optional[SensitiveBoolean] = None,
    departure_time: Optional[TimestampWithTimezoneOffset] = None,
    exclude: Optional[RouteMatrixExclusionOptions] = None,
    key: Optional[ApiKey] = None,
    optimize_routing_for: Optional[RoutingObjective] = None,
    routing_boundary: Optional[RouteMatrixBoundary] = None,
    traffic: Optional[RouteMatrixTrafficOptions] = None,
    travel_mode: Optional[RouteMatrixTravelMode] = None,
    travel_mode_options: Optional[RouteMatrixTravelModeOptions] = None,
) -> CalculateRouteMatrixResponse

Use CalculateRouteMatrix to compute results for all pairs of Origins to Destinations. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destinations positions.

For more information, see Calculate route matrix in the Amazon Location Service Developer Guide.

Parameters:

  • allow (Optional[RouteMatrixAllowOptions], default: None ) –

    Features that are allowed while calculating a route.

  • avoid (Optional[RouteMatrixAvoidanceOptions], default: None ) –

    Features that are avoided while calculating a route. Avoidance is on a best-case basis. If an avoidance can't be satisfied for a particular case, it violates the avoidance and the returned response produces a notice for the violation. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only TollRoads, Ferries, and ControlledAccessHighways.

  • depart_now (Optional[SensitiveBoolean], default: None ) –

    Uses the current time as the time of departure.

  • departure_time (Optional[TimestampWithTimezoneOffset], default: None ) –

    Time of departure from the origin.

    Time format:YYYY-MM-DDThh:mm:ss.sssZ | YYYY-MM-DDThh:mm:ss.sss+hh:mm

    Examples:

    2020-04-22T17:57:24Z

    2020-04-22T17:57:24+02:00

  • destinations (RouteMatrixDestinationList) –

    List of destinations for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

    Route calculations are billed for each origin and destination pair. If you use a large matrix of origins and destinations, your costs will increase accordingly. For more information, see Routes pricing in the Amazon Location Service Developer Guide.

    The maximum number of destinations depends on the routing boundary configuration:

    • With RoutingBoundary.Geometry set: maximum 500 destinations

    • With RoutingBoundary.Unbounded set to true: maximum 100 destinations

    • For GrabMaps customers in ap-southeast-1 and ap-southeast-5: maximum 350 destinations

    The total matrix size (origins × destinations) must not exceed:

    • With RoutingBoundary.Geometry: 160,000

    • With RoutingBoundary.Unbounded: 100

    • For GrabMaps customers in ap-southeast-1 and ap-southeast-5: 122,500

  • exclude (Optional[RouteMatrixExclusionOptions], default: None ) –

    Features to be strictly excluded while calculating the route. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • key (Optional[ApiKey], default: None ) –

    Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • optimize_routing_for (Optional[RoutingObjective], default: None ) –

    Controls the trade-off between finding the shortest travel time (FastestRoute) and the shortest distance (ShortestRoute) when calculating reachable areas.

    Default value: FastestRoute

  • origins (RouteMatrixOriginList) –

    List of origins for the route in World Geodetic System (WGS 84) format: [longitude, latitude].

    Route calculations are billed for each origin and destination pair. Using a large amount of Origins in a request can lead you to incur unexpected charges. For more information, see Routes pricing in the Amazon Location Service Developer Guide.

    The maximum number of origins depends on the routing boundary configuration:

    • With RoutingBoundary.Geometry set: maximum 500 origins

    • With RoutingBoundary.Unbounded set to true: maximum 15 origins

    • For GrabMaps customers in ap-southeast-1 and ap-southeast-5: maximum 350 origins

    The total matrix size (origins × destinations) must not exceed:

    • With RoutingBoundary.Geometry: 160,000

    • With RoutingBoundary.Unbounded: 100

    • For GrabMaps customers in ap-southeast-1 and ap-southeast-5: 122,500

  • routing_boundary (Optional[RouteMatrixBoundary], default: None ) –

    Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Unbounded set to true.

    Default value: Unbounded set to true

    When AutoCircle is set in the request, the response routing boundary will return Circle derived from the AutoCircle settings.

  • traffic (Optional[RouteMatrixTrafficOptions], default: None ) –

    Traffic related options. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

  • travel_mode (Optional[RouteMatrixTravelMode], default: None ) –

    Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. For GrabMaps customers, ap-southeast-1 and ap-southeast-5 regions support only Car, Pedestrian, and Scooter.

    Default value: Car

  • travel_mode_options (Optional[RouteMatrixTravelModeOptions], default: None ) –

    Travel mode related options for the provided travel mode. Not supported in ap-southeast-1 and ap-southeast-5 regions for GrabMaps customers.

Raises:

Source code in docs_src/capo_geo_routes/_services/async_geo_routes.py
async def calculate_route_matrix(
    self,
    destinations: "capo_geo_routes.types.route_matrix_destination_list.RouteMatrixDestinationList",
    origins: "capo_geo_routes.types.route_matrix_origin_list.RouteMatrixOriginList",
    *,
    config_overrides: Optional[AsyncGeoRoutesClientConfig] = None,
    allow: Optional[
        "capo_geo_routes.types.route_matrix_allow_options.RouteMatrixAllowOptions"
    ] = None,
    avoid: Optional[
        "capo_geo_routes.types.route_matrix_avoidance_options.RouteMatrixAvoidanceOptions"
    ] = None,
    depart_now: Optional[
        "capo_geo_routes.types.sensitive_boolean.SensitiveBoolean"
    ] = None,
    departure_time: Optional[
        "capo_geo_routes.types.timestamp_with_timezone_offset.TimestampWithTimezoneOffset"
    ] = None,
    exclude: Optional[
        "capo_geo_routes.types.route_matrix_exclusion_options.RouteMatrixExclusionOptions"
    ] = None,
    key: Optional["capo_geo_routes.types.api_key.ApiKey"] = None,
    optimize_routing_for: Optional[
        "capo_geo_routes.types.routing_objective.RoutingObjective"
    ] = None,
    routing_boundary: Optional[
        "capo_geo_routes.types.route_matrix_boundary.RouteMatrixBoundary"
    ] = None,
    traffic: Optional[
        "capo_geo_routes.types.route_matrix_traffic_options.RouteMatrixTrafficOptions"
    ] = None,
    travel_mode: Optional[
        "capo_geo_routes.types.route_matrix_travel_mode.RouteMatrixTravelMode"
    ] = None,
    travel_mode_options: Optional[
        "capo_geo_routes.types.route_matrix_travel_mode_options.RouteMatrixTravelModeOptions"
    ] = None,
) -> "capo_geo_routes.types.calculate_route_matrix_response.CalculateRouteMatrixResponse":
    """<p> Use <code>CalculateRouteMatrix</code> to compute results for all pairs of Origins to Destinations. Each row corresponds to one entry in Origins. Each entry in the row corresponds to the route from that entry in Origins to an entry in Destinations positions.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/calculate-route-matrix.html">Calculate route matrix</a> in the <i>Amazon Location Service Developer Guide</i>.</p>

    Args:
        allow: <p>Features that are allowed while calculating a route.</p>
        avoid: <p> Features that are avoided while calculating a route. Avoidance is on a best-case basis. If an avoidance can't be satisfied for a particular case, it violates the avoidance and the returned response produces a notice for the violation. For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers, <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions support only <code>TollRoads</code>, <code>Ferries</code>, and <code>ControlledAccessHighways</code>. </p>
        depart_now: <p>Uses the current time as the time of departure.</p>
        departure_time: <p>Time of departure from the origin.</p> <p>Time format:<code>YYYY-MM-DDThh:mm:ss.sssZ | YYYY-MM-DDThh:mm:ss.sss+hh:mm</code> </p> <p>Examples:</p> <p> <code>2020-04-22T17:57:24Z</code> </p> <p> <code>2020-04-22T17:57:24+02:00</code> </p>
        destinations: <p>List of destinations for the route in World Geodetic System (WGS 84) format: [longitude, latitude].</p> <note> <p>Route calculations are billed for each origin and destination pair. If you use a large matrix of origins and destinations, your costs will increase accordingly. For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/routes-pricing.html">Routes pricing</a> in the <i>Amazon Location Service Developer Guide</i>.</p> </note> <p>The maximum number of destinations depends on the routing boundary configuration:</p> <ul> <li> <p>With <code>RoutingBoundary.Geometry</code> set: maximum 500 destinations</p> </li> <li> <p>With <code>RoutingBoundary.Unbounded</code> set to <code>true</code>: maximum 100 destinations</p> </li> <li> <p>For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers in <code>ap-southeast-1</code> and <code>ap-southeast-5</code>: maximum 350 destinations</p> </li> </ul> <p>The total matrix size (origins × destinations) must not exceed:</p> <ul> <li> <p>With <code>RoutingBoundary.Geometry</code>: 160,000</p> </li> <li> <p>With <code>RoutingBoundary.Unbounded</code>: 100</p> </li> <li> <p>For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers in <code>ap-southeast-1</code> and <code>ap-southeast-5</code>: 122,500</p> </li> </ul>
        exclude: <p> Features to be strictly excluded while calculating the route. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers. </p>
        key: <p>Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request. </p>
        optimize_routing_for: <p>Controls the trade-off between finding the shortest travel time (<code>FastestRoute</code>) and the shortest distance (<code>ShortestRoute</code>) when calculating reachable areas.</p> <p>Default value: <code>FastestRoute</code> </p>
        origins: <p>List of origins for the route in World Geodetic System (WGS 84) format: [longitude, latitude].</p> <note> <p>Route calculations are billed for each origin and destination pair. Using a large amount of Origins in a request can lead you to incur unexpected charges. For more information, see <a href="https://docs.aws.amazon.com/location/latest/developerguide/routes-pricing.html">Routes pricing</a> in the <i>Amazon Location Service Developer Guide</i>.</p> </note> <p>The maximum number of origins depends on the routing boundary configuration:</p> <ul> <li> <p>With <code>RoutingBoundary.Geometry</code> set: maximum 500 origins</p> </li> <li> <p>With <code>RoutingBoundary.Unbounded</code> set to <code>true</code>: maximum 15 origins</p> </li> <li> <p>For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers in <code>ap-southeast-1</code> and <code>ap-southeast-5</code>: maximum 350 origins</p> </li> </ul> <p>The total matrix size (origins × destinations) must not exceed:</p> <ul> <li> <p>With <code>RoutingBoundary.Geometry</code>: 160,000</p> </li> <li> <p>With <code>RoutingBoundary.Unbounded</code>: 100</p> </li> <li> <p>For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers in <code>ap-southeast-1</code> and <code>ap-southeast-5</code>: 122,500</p> </li> </ul>
        routing_boundary: <p> Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid. For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers, <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions support only <code>Unbounded</code> set to <code>true</code>. </p> <p>Default value: <code>Unbounded set to true</code> </p> <note> <p>When <code>AutoCircle</code> is set in the request, the response routing boundary will return <code>Circle</code> derived from the <code>AutoCircle</code> settings.</p> </note>
        traffic: <p> Traffic related options. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers. </p>
        travel_mode: <p> Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility. For <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers, <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions support only <code>Car</code>, <code>Pedestrian</code>, and <code>Scooter</code>. </p> <p>Default value: <code>Car</code> </p>
        travel_mode_options: <p> Travel mode related options for the provided travel mode. Not supported in <code>ap-southeast-1</code> and <code>ap-southeast-5</code> regions for <a href="https://docs.aws.amazon.com/location/latest/developerguide/GrabMaps.html">GrabMaps</a> customers. </p>

    Raises:
        capo_geo_routes.errors.access_denied_exception.AccessDeniedException: <p>You don't have sufficient access to perform this action.</p>
        capo_geo_routes.errors.internal_server_exception.InternalServerException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
        capo_geo_routes.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_geo_routes.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an AWS service.</p>
        capo_geo_routes.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_geo_routes.types.calculate_route_matrix_request.CalculateRouteMatrixRequest]",
    ) -> AsyncOperationResponse[
        "capo_geo_routes.types.calculate_route_matrix_response.CalculateRouteMatrixResponse"
    ]:
        import capo_geo_routes._operations.routes_service.calculate_route_matrix

        (
            output,
            http_response,
        ) = await capo_geo_routes._operations.routes_service.calculate_route_matrix.async_calculate_route_matrix(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_geo_routes.types.calculate_route_matrix_request.CalculateRouteMatrixRequest",
    ) -> dict[str, Any]:
        import capo_geo_routes.types.calculate_route_matrix_request

        return (
            capo_geo_routes.types.calculate_route_matrix_request.redact_sensitive(
                input_
            )
        )

    def _redact_output(
        output: "capo_geo_routes.types.calculate_route_matrix_response.CalculateRouteMatrixResponse",
    ) -> dict[str, Any]:
        import capo_geo_routes.types.calculate_route_matrix_response

        return (
            capo_geo_routes.types.calculate_route_matrix_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CalculateRouteMatrix",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_geo_routes.types.calculate_route_matrix_request.CalculateRouteMatrixRequest = {
        "destinations": destinations,
        "origins": origins,
    }
    if allow is not None:
        input_["allow"] = allow
    if avoid is not None:
        input_["avoid"] = avoid
    if depart_now is not None:
        input_["depart_now"] = depart_now
    if departure_time is not None:
        input_["departure_time"] = departure_time
    if exclude is not None:
        input_["exclude"] = exclude
    if key is not None:
        input_["key"] = key
    if optimize_routing_for is not None:
        input_["optimize_routing_for"] = optimize_routing_for
    if routing_boundary is not None:
        input_["routing_boundary"] = routing_boundary
    if traffic is not None:
        input_["traffic"] = traffic
    if travel_mode is not None:
        input_["travel_mode"] = travel_mode
    if travel_mode_options is not None:
        input_["travel_mode_options"] = travel_mode_options

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output