LocationServiceRoutesV2 / Client / calculate_route_matrix

calculate_route_matrix#

LocationServiceRoutesV2.Client.calculate_route_matrix(**kwargs)#

Calculates route matrix containing the 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.

See also: AWS API Documentation

Request Syntax

response = client.calculate_route_matrix(
    Allow={
        'Hot': True|False,
        'Hov': True|False
    },
    Avoid={
        'Areas': [
            {
                'Geometry': {
                    'BoundingBox': [
                        123.0,
                    ],
                    'Polygon': [
                        [
                            [
                                123.0,
                            ],
                        ],
                    ],
                    'PolylinePolygon': [
                        'string',
                    ]
                }
            },
        ],
        'CarShuttleTrains': True|False,
        'ControlledAccessHighways': True|False,
        'DirtRoads': True|False,
        'Ferries': True|False,
        'TollRoads': True|False,
        'TollTransponders': True|False,
        'TruckRoadTypes': [
            'string',
        ],
        'Tunnels': True|False,
        'UTurns': True|False,
        'ZoneCategories': [
            {
                'Category': 'CongestionPricing'|'Environmental'|'Vignette'
            },
        ]
    },
    DepartNow=True|False,
    DepartureTime='string',
    Destinations=[
        {
            'Options': {
                'AvoidActionsForDistance': 123,
                'Heading': 123.0,
                'Matching': {
                    'NameHint': 'string',
                    'OnRoadThreshold': 123,
                    'Radius': 123,
                    'Strategy': 'MatchAny'|'MatchMostSignificantRoad'
                },
                'SideOfStreet': {
                    'Position': [
                        123.0,
                    ],
                    'UseWith': 'AnyStreet'|'DividedStreetOnly'
                }
            },
            'Position': [
                123.0,
            ]
        },
    ],
    Exclude={
        'Countries': [
            'string',
        ]
    },
    Key='string',
    OptimizeRoutingFor='FastestRoute'|'ShortestRoute',
    Origins=[
        {
            'Options': {
                'AvoidActionsForDistance': 123,
                'Heading': 123.0,
                'Matching': {
                    'NameHint': 'string',
                    'OnRoadThreshold': 123,
                    'Radius': 123,
                    'Strategy': 'MatchAny'|'MatchMostSignificantRoad'
                },
                'SideOfStreet': {
                    'Position': [
                        123.0,
                    ],
                    'UseWith': 'AnyStreet'|'DividedStreetOnly'
                }
            },
            'Position': [
                123.0,
            ]
        },
    ],
    RoutingBoundary={
        'Geometry': {
            'AutoCircle': {
                'Margin': 123,
                'MaxRadius': 123
            },
            'Circle': {
                'Center': [
                    123.0,
                ],
                'Radius': 123.0
            },
            'BoundingBox': [
                123.0,
            ],
            'Polygon': [
                [
                    [
                        123.0,
                    ],
                ],
            ]
        },
        'Unbounded': True|False
    },
    Traffic={
        'FlowEventThresholdOverride': 123,
        'Usage': 'IgnoreTrafficData'|'UseTrafficData'
    },
    TravelMode='Car'|'Pedestrian'|'Scooter'|'Truck',
    TravelModeOptions={
        'Car': {
            'LicensePlate': {
                'LastCharacter': 'string'
            },
            'MaxSpeed': 123.0,
            'Occupancy': 123
        },
        'Scooter': {
            'LicensePlate': {
                'LastCharacter': 'string'
            },
            'MaxSpeed': 123.0,
            'Occupancy': 123
        },
        'Truck': {
            'AxleCount': 123,
            'GrossWeight': 123,
            'HazardousCargos': [
                'Combustible'|'Corrosive'|'Explosive'|'Flammable'|'Gas'|'HarmfulToWater'|'Organic'|'Other'|'Poison'|'PoisonousInhalation'|'Radioactive',
            ],
            'Height': 123,
            'KpraLength': 123,
            'Length': 123,
            'LicensePlate': {
                'LastCharacter': 'string'
            },
            'MaxSpeed': 123.0,
            'Occupancy': 123,
            'PayloadCapacity': 123,
            'Trailer': {
                'TrailerCount': 123
            },
            'TruckType': 'LightTruck'|'StraightTruck'|'Tractor',
            'TunnelRestrictionCode': 'string',
            'WeightPerAxle': 123,
            'WeightPerAxleGroup': {
                'Single': 123,
                'Tandem': 123,
                'Triple': 123,
                'Quad': 123,
                'Quint': 123
            },
            'Width': 123
        }
    }
)
Parameters:
  • Allow (dict) –

    Features that are allowed while calculating. a route

    • Hot (boolean) –

      Allow Hot (High Occupancy Toll) lanes while calculating the route.

    • Hov (boolean) –

      Allow Hov (High Occupancy vehicle) lanes while calculating the route.

  • Avoid (dict) –

    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.

    • Areas (list) –

      Areas to be avoided.

      • (dict) –

        Area to be avoided.

        • Geometry (dict) – [REQUIRED]

          Geometry of the area to be avoided.

          • BoundingBox (list) –

            Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.

            • (float) –

          • Polygon (list) –

            Geometry defined as a polygon with only one linear ring.

            • (list) –

              • (list) –

                • (float) –

          • PolylinePolygon (list) –

            A list of Isoline PolylinePolygon, for each isoline PolylinePolygon, it contains PolylinePolygon of the first linear ring (the outer ring) and from second item to the last item (the inner rings). For more information on polyline encoding, see https://github.com/heremaps/flexiblepolyline/blob/master/README.md.

            • (string) –

    • CarShuttleTrains (boolean) –

      Avoid car-shuttle-trains while calculating the route.

    • ControlledAccessHighways (boolean) –

      Avoid controlled access highways while calculating the route.

    • DirtRoads (boolean) –

      Avoid dirt roads while calculating the route.

    • Ferries (boolean) –

      Avoid ferries while calculating the route.

    • TollRoads (boolean) –

      Avoids roads where the specified toll transponders are the only mode of payment.

    • TollTransponders (boolean) –

      Avoids roads where the specified toll transponders are the only mode of payment.

    • TruckRoadTypes (list) –

      Truck road type identifiers. BK1 through BK4 apply only to Sweden. A2,A4,B2,B4,C,D,ET2,ET4 apply only to Mexico.

      Note

      There are currently no other supported values as of 26th April 2024.

      • (string) –

    • Tunnels (boolean) –

      Avoid tunnels while calculating the route.

    • UTurns (boolean) –

      Avoid U-turns for calculation on highways and motorways.

    • ZoneCategories (list) –

      Zone categories to be avoided.

      • (dict) –

        Zone categories to be avoided.

        • Category (string) –

          Zone category to be avoided.

  • DepartNow (boolean) – Uses the current time as the time of departure.

  • DepartureTime (string) –

    Time of departure from thr 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 (list) –

    [REQUIRED]

    List of destinations for the route.

    • (dict) –

      The route destination.

      • Options (dict) –

        Destination related options.

        • AvoidActionsForDistance (integer) –

          Avoids actions for the provided distance. This is typically to consider for users in moving vehicles who may not have sufficient time to make an action at an origin or a destination.

        • Heading (float) –

          GPS Heading at the position.

        • Matching (dict) –

          Options to configure matching the provided position to the road network.

          • NameHint (string) –

            Attempts to match the provided position to a road similar to the provided name.

          • OnRoadThreshold (integer) –

            If the distance to a highway/bridge/tunnel/sliproad is within threshold, the waypoint will be snapped to the highway/bridge/tunnel/sliproad.

            Unit: meters

          • Radius (integer) –

            Considers all roads within the provided radius to match the provided destination to. The roads that are considered are determined by the provided Strategy.

            Unit: Meters

          • Strategy (string) –

            Strategy that defines matching of the position onto the road network. MatchAny considers all roads possible, whereas MatchMostSignificantRoad matches to the most significant road.

        • SideOfStreet (dict) –

          Options to configure matching the provided position to a side of the street.

          • Position (list) – [REQUIRED]

            Position defined as [longitude, latitude].

            • (float) –

          • UseWith (string) –

            Strategy that defines when the side of street position should be used. AnyStreet will always use the provided position.

            Default Value: DividedStreetOnly

      • Position (list) – [REQUIRED]

        Position defined as [longitude, latitude].

        • (float) –

  • Exclude (dict) –

    Features to be strictly excluded while calculating the route.

    • Countries (list) – [REQUIRED]

      List of countries to be avoided defined by two-letter or three-letter country codes.

      • (string) –

  • Key (string) – Optional: The API key to be used for authorization. Either an API key or valid SigV4 signature must be provided when making a request.

  • OptimizeRoutingFor (string) –

    Specifies the optimization criteria for calculating a route.

    Default Value: FastestRoute

  • Origins (list) –

    [REQUIRED]

    The position in longitude and latitude for the origin.

    • (dict) –

      The start position for the route.

      • Options (dict) –

        Origin related options.

        • AvoidActionsForDistance (integer) –

          Avoids actions for the provided distance. This is typically to consider for users in moving vehicles who may not have sufficient time to make an action at an origin or a destination.

        • Heading (float) –

          GPS Heading at the position.

        • Matching (dict) –

          Options to configure matching the provided position to the road network.

          • NameHint (string) –

            Attempts to match the provided position to a road similar to the provided name.

          • OnRoadThreshold (integer) –

            If the distance to a highway/bridge/tunnel/sliproad is within threshold, the waypoint will be snapped to the highway/bridge/tunnel/sliproad.

            Unit: meters

          • Radius (integer) –

            Considers all roads within the provided radius to match the provided destination to. The roads that are considered are determined by the provided Strategy.

            Unit: Meters

          • Strategy (string) –

            Strategy that defines matching of the position onto the road network. MatchAny considers all roads possible, whereas MatchMostSignificantRoad matches to the most significant road.

        • SideOfStreet (dict) –

          Options to configure matching the provided position to a side of the street.

          • Position (list) – [REQUIRED]

            Position defined as [longitude, latitude].

            • (float) –

          • UseWith (string) –

            Strategy that defines when the side of street position should be used. AnyStreet will always use the provided position.

            Default Value: DividedStreetOnly

      • Position (list) – [REQUIRED]

        Position defined as [longitude, latitude].

        • (float) –

  • RoutingBoundary (dict) –

    [REQUIRED]

    Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid.

    Note

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

    • Geometry (dict) –

      Geometry of the area to be avoided.

      • AutoCircle (dict) –

        Provides the circle that was used while calculating the route.

        • Margin (integer) –

          The margin provided for the calculation.

        • MaxRadius (integer) –

          The maximum size of the radius provided for the calculation.

      • Circle (dict) –

        Geometry defined as a circle. When request routing boundary was set as AutoCircle, the response routing boundary will return Circle derived from the AutoCircle settings.

        • Center (list) – [REQUIRED]

          Center of the Circle defined in longitude and latitude coordinates.

          Example: [-123.1174, 49.2847] represents the position with longitude -123.1174 and latitude 49.2847.

          • (float) –

        • Radius (float) – [REQUIRED]

          Radius of the Circle.

          Unit: meters

      • BoundingBox (list) –

        Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.

        • (float) –

      • Polygon (list) –

        Geometry defined as a polygon with only one linear ring.

        • (list) –

          • (list) –

            • (float) –

    • Unbounded (boolean) –

      No restrictions in terms of a routing boundary, and is typically used for longer routes.

  • Traffic (dict) –

    Traffic related options.

    • FlowEventThresholdOverride (integer) –

      Duration for which flow traffic is considered valid. For this period, the flow traffic is used over historical traffic data. Flow traffic refers to congestion, which changes very quickly. Duration in seconds for which flow traffic event would be considered valid. While flow traffic event is valid it will be used over the historical traffic data.

    • Usage (string) –

      Determines if traffic should be used or ignored while calculating the route.

      Default Value: UseTrafficData

  • TravelMode (string) –

    Specifies the mode of transport when calculating a route. Used in estimating the speed of travel and road compatibility.

    Default Value: Car

  • TravelModeOptions (dict) –

    Travel mode related options for the provided travel mode.

    • Car (dict) –

      Travel mode options when the provided travel mode is “Car”

      • LicensePlate (dict) –

        The vehicle License Plate.

        • LastCharacter (string) –

          The last character of the License Plate.

      • MaxSpeed (float) –

        Maximum speed

        Unit: KilometersPerHour

      • Occupancy (integer) –

        The number of occupants in the vehicle.

        Default Value: 1

    • Scooter (dict) –

      Travel mode options when the provided travel mode is “Scooter”

      • LicensePlate (dict) –

        The vehicle License Plate.

        • LastCharacter (string) –

          The last character of the License Plate.

      • MaxSpeed (float) –

        Maximum speed.

        Unit: KilometersPerHour

      • Occupancy (integer) –

        The number of occupants in the vehicle.

        Default Value: 1

    • Truck (dict) –

      Travel mode options when the provided travel mode is “Truck”

      • AxleCount (integer) –

        Total number of axles of the vehicle.

      • GrossWeight (integer) –

        Gross weight of the vehicle including trailers, and goods at capacity.

        Unit: Kilograms

      • HazardousCargos (list) –

        List of Hazardous cargo contained in the vehicle.

        • (string) –

      • Height (integer) –

        Height of the vehicle.

        Unit: centimeters

      • KpraLength (integer) –

        Kingpin to rear axle length of the vehicle

        Unit: centimeters

      • Length (integer) –

        Length of the vehicle.

        Unit: centimeters

      • LicensePlate (dict) –

        The vehicle License Plate.

        • LastCharacter (string) –

          The last character of the License Plate.

      • MaxSpeed (float) –

        Maximum speed

        Unit: KilometersPerHour

      • Occupancy (integer) –

        The number of occupants in the vehicle.

        Default Value: 1

      • PayloadCapacity (integer) –

        Payload capacity of the vehicle and trailers attached.

        Unit: kilograms

      • Trailer (dict) –

        Trailer options corresponding to the vehicle.

        • TrailerCount (integer) –

          Number of trailers attached to the vehicle.

          Default Value: 0

      • TruckType (string) –

        Type of the truck.

      • TunnelRestrictionCode (string) –

        The tunnel restriction code.

        Tunnel categories in this list indicate the restrictions which apply to certain tunnels in Great Britain. They relate to the types of dangerous goods that can be transported through them.

        • Tunnel Category B

          • Risk Level: Limited risk

          • Restrictions: Few restrictions

        • Tunnel Category C

          • Risk Level: Medium risk

          • Restrictions: Some restrictions

        • Tunnel Category D

          • Risk Level: High risk

          • Restrictions: Many restrictions occur

        • Tunnel Category E

          • Risk Level: Very high risk

          • Restrictions: Restricted tunnel

      • WeightPerAxle (integer) –

        Heaviest weight per axle irrespective of the axle type or the axle group. Meant for usage in countries where the differences in axle types or axle groups are not distinguished.

        Unit: Kilograms

      • WeightPerAxleGroup (dict) –

        Specifies the total weight for the specified axle group. Meant for usage in countries that have different regulations based on the axle group type.

        • Single (integer) –

          Weight for single axle group.

          Unit: Kilograms

        • Tandem (integer) –

          Weight for tandem axle group.

          Unit: Kilograms

        • Triple (integer) –

          Weight for triple axle group.

          Unit: Kilograms

        • Quad (integer) –

          Weight for quad axle group.

          Unit: Kilograms

        • Quint (integer) –

          Weight for quad quint group.

          Unit: Kilograms

      • Width (integer) –

        Width of the vehicle.

        Unit: centimeters

Return type:

dict

Returns:

Response Syntax

{
    'ErrorCount': 123,
    'PricingBucket': 'string',
    'RouteMatrix': [
        [
            {
                'Distance': 123,
                'Duration': 123,
                'Error': 'NoMatch'|'NoMatchDestination'|'NoMatchOrigin'|'NoRoute'|'OutOfBounds'|'OutOfBoundsDestination'|'OutOfBoundsOrigin'|'Other'|'Violation'
            },
        ],
    ],
    'RoutingBoundary': {
        'Geometry': {
            'AutoCircle': {
                'Margin': 123,
                'MaxRadius': 123
            },
            'Circle': {
                'Center': [
                    123.0,
                ],
                'Radius': 123.0
            },
            'BoundingBox': [
                123.0,
            ],
            'Polygon': [
                [
                    [
                        123.0,
                    ],
                ],
            ]
        },
        'Unbounded': True|False
    }
}

Response Structure

  • (dict) –

    • ErrorCount (integer) –

      The count of error results in the route matrix. If this number is 0, all routes were calculated successfully.

    • PricingBucket (string) –

      The pricing bucket for which the query is charged at.

    • RouteMatrix (list) –

      The calculated route matrix containing the results for all pairs of Origins to Destination positions. 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 Destination positions.

      • (list) –

        • (dict) –

          The calculated route matrix containing the results for all pairs of Origins to Destination positions. 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 Destination positions.

          • Distance (integer) –

            The total distance of travel for the route.

          • Duration (integer) –

            The expected duration of travel for the route.

            Unit: seconds

          • Error (string) –

            Error code that occurred during calculation of the route.

    • RoutingBoundary (dict) –

      Boundary within which the matrix is to be calculated. All data, origins and destinations outside the boundary are considered invalid.

      Note

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

      • Geometry (dict) –

        Geometry of the area to be avoided.

        • AutoCircle (dict) –

          Provides the circle that was used while calculating the route.

          • Margin (integer) –

            The margin provided for the calculation.

          • MaxRadius (integer) –

            The maximum size of the radius provided for the calculation.

        • Circle (dict) –

          Geometry defined as a circle. When request routing boundary was set as AutoCircle, the response routing boundary will return Circle derived from the AutoCircle settings.

          • Center (list) –

            Center of the Circle defined in longitude and latitude coordinates.

            Example: [-123.1174, 49.2847] represents the position with longitude -123.1174 and latitude 49.2847.

            • (float) –

          • Radius (float) –

            Radius of the Circle.

            Unit: meters

        • BoundingBox (list) –

          Geometry defined as a bounding box. The first pair represents the X and Y coordinates (longitude and latitude,) of the southwest corner of the bounding box; the second pair represents the X and Y coordinates (longitude and latitude) of the northeast corner.

          • (float) –

        • Polygon (list) –

          Geometry defined as a polygon with only one linear ring.

          • (list) –

            • (list) –

              • (float) –

      • Unbounded (boolean) –

        No restrictions in terms of a routing boundary, and is typically used for longer routes.

Exceptions

  • LocationServiceRoutesV2.Client.exceptions.InternalServerException

  • LocationServiceRoutesV2.Client.exceptions.AccessDeniedException

  • LocationServiceRoutesV2.Client.exceptions.ValidationException

  • LocationServiceRoutesV2.Client.exceptions.ThrottlingException