What is Distance Matrix API (DM API) Capable of?
Application Area
There is no doubt that constantly solving routing problems is serious intellectual work for professionals involved in traffic planning. This happens because the purpose of their activity is not only to determine the algorithms for moving between given locations on a particular type of transport or on foot. Trip planning should take into account their safety, and economic efficiency, as well as constant online monitoring of the situation on given routes.
Of course, there are many techniques and methods by which specialists can make analytics, find optimal distances, calculate the time to overcome these distances, etc. However, it will be much more efficient to use the distance matrix service product of our service. Using the HTTP protocol for generating requests and API capabilities for interaction between applications, the service provides calculation results for a wide variety of routes between combinations of their start and finish points.
Example of Using DM API
Suppose that some company XYZ serves a large population center by delivering goods to various locations in the region. The roads on which carriers move are quite difficult, not always of good quality, and include certain restrictions. There are many intersections, dead ends, and one-way roads. At the same time, the criteria for the effective operation of the company are the timely delivery of goods, effective planning of the use of vehicles, and the reduction of transport costs due to the optimal construction of routes and the calculation of the delivery time.
To correctly compose delivery routes, the manager generates an HTTP request to the service. We should mark that it does not matter from which point on the planet this request is sent, the response of the service will be almost instantaneous and accurate. At the same time, the quality of the response of the service will not be worse than the best world analogs of DM API. Despite the fact that the request form is standardized, the procedure for its formation is not complicated and after studying the relevant documentation on the service website, it will not present difficulties for users.
Like any such request, your content will include both constant attributes and variables. Naturally, the more complete the information in the request, the more detailed the response will be, however, in the absence of variable attributes, the service response will also be of high quality. Service response versions may vary depending on your goals. If we take our example with company XYZ, then for the purposes of this company, not only the calculations of distances and time are important, but also the current situation on the routes, taking into account the difficulties of roads, modes of transport junctions, etc. In this case, the distance matrix itself will not be symmetrical. If for the purposes of any other company, the influence of the nuances of movement, difficult interchanges, etc. is not critical, then you can request a simpler version of the DM API.
The “Request-response” Chain
So, what would company XYZ include in their HTTP request as persistent attributes? The first is an indication of the starting position (one or more). For example, vehicles start their movement from more than one location. We enumerate each of them in the query, placing a vertical separating line between the enumerations. The second is an indication of the finishing position, it can also be one or more. The format for specifying several finishing positions is similar to the starting ones. The third is the introduction of your personal access code, called the “key”. And this is the entire minimum, but an unchanged set of parameters that should be in the request.
And then variable attributes can be included in the request. There are many of them, and all of them, together with explanations of the format of their introduction, are listed in the corresponding section of the documentation on the service website.
Based on the results of the request, the service will generate a response with a json text string, which is quite easily perceived by users. And the first thing you need to pay attention to in the response to the service is the status of the response itself. If the response is assigned the status “ok”, then the request itself was correct, the result was generated, and you can plan the necessary route successfully. If you saw the entry “INVALID_REQUEST” in the response, then no results were provided for the request. The cause of such a situation can be shown in the special field of the response and you need to correct the request and resend it.