Distance Matrix

The Distance Matrix service takes a set of locations and provides estimates for the travel times and distances between each pair. Specifically, it returns detailed travel time estimates that account for predicted traffic based on years of historical data. The travel times are returned for multiple “traffic windows,” time periods during which predicted traffic remains roughly constant. The Distance Matrix service has been engineered using patented methods for hyper-efficiency in handling unprecedentedly large requests: up to 7,500 locations at once. The current performance is orders of magnitude faster than competing services, and vastly less expensive.

Concepts

As a reminder, a distance matrix describes the distances between all sets of points in a collection. For example, if we have locations A, B, and C, then the figure below represents the distance matrix:

Distance Matrix

Take note that the diagonals of the distance matrix have value zero (0) since the distance from a location to itself is zero. Also, notice that the matrix is symmetric, that is, the distance from A-to-B is the same as B-to-A and so on. This is not always true in the real world road network due to one-way streets, variations in traffic patterns, and other subtleties that our backend services take into consideration.

When supplied latitudes and longitudes for locations of interest, our backend services calculate travel times and distances between each location pair using predicted traffic. The estimated travel times are returned for multiple traffic windows: time periods during which predicted traffic remains roughly constant. We provide a visual example of traffic windows in the figure below using simulated data.

Traffic Windows

In this exaggerated cartoon, notice that there are distinct periods during which the travel time is constant (colored, horizontal lines) that separate into unique travel time windows (vertical blue lines). Our backend services take the same approach, and in each distance matrix response, there are eight unique time windows all with their own travel times.

Behavior

When passed a set of n locations (A, B, C in the example above), the returned matrix defaults to a square n x n matrix where each entry in the matrix represents the time and distance of traveling between a pair of locations in different time windows. The Distance Matrix service allows users to filter the results based on the specifics of the use case. For example, users can designate that some locations are only sources and others are only destinations so that the result contains only information about traveling from a source location to a destination location, thus saving calculation time and calls. This is illustrated below, note the direction of the arrows.

Distance Matrix Source-Destination

The Distance Matrix service supports a variety of other options that allow users to further filter results. By default, the Distance Matrix service assumes the vehicle type to be a car. However, the Distance Matrix service allows users to specify types such as bicycle, pedestrian, and truck. Trucks are a special vehicle type that takes additional parameters such as weight and height. Details are provided below.

Combining the above behaviors, the response from the Distance Matrix service is simple to understand, yet complex to describe syntactically. Other companies that provide a distance matrix service do not offer the traffic time window and filtering options, hence MapAnything’s richer Distance Matrix service has a slightly denser response format. This is detailed below. Represented graphically, a source-destination pair in our distance matrix will be an array of distance and travel times for each traffic window as shown below.

Distance Matrix Source-Destination