Distance Matrix

List of parameters

Mandatory parameters

  • calculationMode – Indicates the calculation mode for the route. Supports types:
    • THE_FASTEST – Consider it the fastest way.
    • THE_SHORTEST – Consider the route with the lowest mileage.
  • destinations – Description of destination points with:
    • siteId – Stop point identifier.
    • latitude – Latitude coordinate in decimal degrees.
    • longitude – Longitude coordinate in decimal degrees.
  • origins – Description of points of origin with:
    • siteId – Stop point identifier.
    • latitude – Latitude coordinate in decimal degrees.
    • longitude – Longitude coordinate in decimal degrees.

Example with mandatory parameters

{
    "calculationMode": "THE_FASTEST",
    "destinations": [
        {
            "latitude": -23.561402303338195, 
            "longitude": -46.63862145421187,
            "siteId": "destination1Liberdade"
        }
    ],
    "origins": [
        {
            "latitude": -23.55363650451996,
            "longitude": -46.620810158377516,
            "siteId": "origin1Mooca"
        }
    ]
}

Optional parameters

  • linearThreshold – Numeric value. Maximum distance, in kilometers, for taking roads into account in the distance matrix calculation. First, all distances are calculated in a straight line. Then, those below this limit are recalculated along roads. This prevents points that are very far apart from increasing processing time. The default value is 1000 (1,000 km).
  • avoidanceTypes – Indicates that the route will have to deviate from certain types of road system elements. Allowed values are:
    • TUNNELS – The route will bypass tunnels;
    • BRIDGES – The route will bypass bridges;
    • CITY – The route will bypass urban areas;
    • UNPAVED – The route will bypass unpaved roads;
    • FERRIES – The route will bypass ferries.
  • callback – Object that contains the webhook data that will be used to receive the problem calculation events. This way, it will not be necessary to check the status of the problem to check if it has been processed. The API will notify the webhook when the solution is available for query. For more details, see: How to receive the current status of the problem via webhook?
    • url – URL with the address that will receive the callback.
    • user – (Optional) Text with the user name if the endpoint requires authentication.
    • password – (Optional) Password text if the endpoint requires authentication.
  • restrictionZones – Array with the text of the name of the restriction area previously registered in the Restriction Zone API.

Example with optional parameters

{
    "avoidanceTypes": [
        "TUNNELS",
        "BRIDGES",
        "FERRIES"
    ],
    "calculationMode": "THE_FASTEST",
    "destinations": [
        {
            "latitude": -23.682211,
            "longitude": -46.546867,
            "siteId": "SantoAndre"
        }
    ],
    "origins": [
        {
            "latitude": -23.337132,
            "longitude": -46.835427,
            "siteId": "Cajamar"
        }
    ],
    "linearThreshold": 500,
    "restrictionZones": []
}