TrueWay Matrix

FREEMIUM
Verified
By TrueWay Team | Updated לפני שנתיים | Mapping
Popularity

9.5 / 10

Latency

391ms

Service Level

100%

TrueWay Matrix Overview

README

The API provides durations(in seconds) and distances(in meters) for a set of origins and destinations. The distances and times returned are based on the routes calculated by the TrueWay Directions API. Times are based on predictive or live traffic information, depending on the start time specified in the request. Distance matrices are used in several different types of applications. The most common applications include:

  • Solving the Traveling Salesman Problem (TSP).
  • Solving Vehicle Routing Problem (VRP).
  • Sorting search results by their actual travel distance or time.
  • Determine arrival times based on travel times.
  • Calculate the difference in commute times between locations.
  • Clustering data based on travel time and distances.

Features and capabilities:

  • Global road network coverage.
  • Calculate distances and durations between a set of origins and destinations.
  • Optionally calculate traffic based distance/duration matrices over a period of time.
  • Can avoid toll roads, highways or ferries.

Calculate distances and durations between a set of origins and destinations (CalculateDrivingDistanceMatrix).

A CalculateDrivingDistanceMatrix request takes a list of origins and destination locations and returns a matrix of distances and durations between them. The matrix element is the length/time of the optimal route between origin and destination points on the real road network.
Required parameters:

  • origins - List of origins described as semicolon-delimited coordinate pairs with latitudes and longitudes. Max: 25 per request.

Optional parameters:

  • destinations - List of destinations described as semicolon-delimited coordinate pairs with latitudes and longitudes. If not specified, an n x n matrix will be generated using the origins. Max: 25 per request.
  • start_time - Time when travel is expected to start. You can specify the time as an integer in seconds since midnight, January 1, 1970 UTC or you can use “now” to specify the current time.
  • avoid_highways - Avoid highways.
  • avoid_tolls - Avoid toll roads.
  • avoid_ferries - Avoid ferries.

Response

The response to the request returns a matrix of distances and durations between origins and destinations locations. Matrix rows correspond to origins and columns correspond to destinations. The response contains two-dimensional array of distances from origins to destinations “distances” and two-dimensional array of driving times(durations) from origins to destinations “durations”.

For example, for the matrix 4x4:

Request:

"origins":"40.629041,-74.025606;40.630099,-73.993521;40.644895,-74.013818;40.627177,-73.980853"
"destinations":"40.629041,-74.025606;40.630099,-73.993521;40.644895,-74.013818;40.627177,-73.980853"

Response:

{
"distances":[
  0:[
    0:0
    1:3939
    2:2077
    3:5418
    ]
  1:[
    0:4004
    1:0
    2:2609
    3:1480
    ]
  2:[
    0:2984
    1:2803
    2:0
    3:3646
    ]
  3:[
    0:5621
    1:2561
    2:5170
    3:0
    ]
]
"durations":[
  0:[
    0:0
    1:820
    2:476
    3:1092
    ]
  1:[
    0:867
    1:0
    2:736
    3:412
    ]
  2:[
    0:595
    1:752
    2:0
    3:1030
    ]
  3:[
    0:1134
    1:580
    2:1184
    3:0
    ]
]
}

From this response, we can see that the length of the route from the 2nd origin point to the 3rd destination point is 3646 m and time(duration) of the route is 1030 s.

Followers: 10
Resources:
Product Website
API Creator:
Rapid account: True Way Team
TrueWay Team
trueway
Log In to Rate API
Rating: 5 - Votes: 3