Retrieving Travel Times from a Multiple Travel Times Distance Matrix

A multiple travel times distance matrix is an extended version of the distance matrix where a travel time profileClosed A profile is a collection of parameters used to configure the request. Full profiles consist of a number of specialized sub-profiles like the VehicleProfile which describes the properties of a vehicle. is stored between two locations.

Benefits

  • The travel times can be requested for a specific point in time in the horizon.
  • The travel time profiles can also be retrieved efficiently with one call to the service.

Prerequisites

Please ensure following prerequisites are fulfilled before you start with the use case:

  • Installed and licensed PTV xDima service

Concepts

Programming Guide

The creation of a multiple travel times distance matrix is performed using the matrix call createDistanceMatrix by passing the origin and destination coordinates and the multiple travel times consideration scenario with a horizon.

var request = {
    "distanceMatrixOptions": {
        "timeConsideration": {
            "$type": "MultipleTravelTimesConsideration",
            "horizon": {
                "$type": "StartEndInterval",
                "start": "2023-03-09T00:00:00+01:00",
                "end": "2023-03-10T00:00:00+01:00"
            }
        }
    },
    "startLocations": [
    {
        "$type": "OffRoadRouteLocation",
        "offRoadCoordinate": {"x": 6.13565, "y": 49.4806576}
    },
    {
        "$type": "OffRoadRouteLocation",
        "offRoadCoordinate": {"x": 6.06479, "y": 49.62127}
    }
    ],
    "destinationLocations": [
    {
        "$type": "OffRoadRouteLocation",
        "offRoadCoordinate": {"x": 6.125657, "y": 49.4816576}
    },
    {
        "$type": "OffRoadRouteLocation",
        "offRoadCoordinate": {"x": 6.16678, "y": 49.455127}
    }
    ]
};

xdima.createDistanceMatrix(request, responseCallback);
            

Once the distance matrix is created it is possible to request the travel times at a specific point in time included in the horizon used for the calculation.

var request = {
    "$type": "GetDistanceMatrixByRelationsRequest",
    "id": response.summary.id,
    "resultFields": {
        "distanceMatrixContentsResultFields": {
            "travelTimes": true
        }
    },
    "relations": [{
        "startLocation": 
        {
            "$type": "OffRoadRouteLocation",
            "offRoadCoordinate": {"x": 6.13565, "y": 49.4806576}
        },
        "destinationLocation": 
        {
            "$type": "OffRoadRouteLocation",
            "offRoadCoordinate": {"x": 6.125657, "y": 49.4816576}
        }
    }],
    "contentsOptions": {
        "startTime": "2023-03-09T12:00:00+01:00"
    }
};
xdima.getDistanceMatrix(request, responseCallback);
            

or even requesting the complete travel time profile through the encoded arrays content options (please note that the travelTimes result field should be disabled explicitly as it is not compatible).

var request = {
    "$type": "GetDistanceMatrixByRelationsRequest",
    "id": response.summary.id,
    "resultFields": {
        "distanceMatrixContentsResultFields": {
            "travelTimes": false,
            "travelTimeProfiles":true
        }
    },
    "relations": [{
        "startLocation": 
        {
            "$type": "OffRoadRouteLocation",
            "offRoadCoordinate": {"x": 6.13565, "y": 49.4806576}
        },
        "destinationLocation": 
        {
            "$type": "OffRoadRouteLocation",
            "offRoadCoordinate": {"x": 6.125657, "y": 49.4816576}
        }
    }],
    "contentsOptions": {
        "returnEncodedArrays": true
    }
};
xdima.getDistanceMatrix(request, responseCallback);
            

The following example shows to create and calculate a multiple travel times distance matrix, retrieve the travel time for a specific start time and delete the dima afterwards:

The following example shows to create and calculate a multiple travel times distance matrix, retrieve the travel time profiles with encoded binary arrays and delete the dima afterwards:

Related Topics

The following topics might be relevant for this use case.