Know About Distance Matrix API And Their Benefits

Date:

A great variety of online products are functioning in the information space, and almost always they contain tasks that cannot be solved without using different services which include geographic data and their processing methods.

Let’s imagine that we need to make some deliveries by car from a starting location to three different destinations. Of course, we are interested in making the delivery route as convenient, fast and economical as possible, while taking into account the peculiarities of traffic on the roads. A similar task is accomplished easily using the distancematrix api service. 

This service is able to solve different tasks, it can calculate the route not only for cars but also for motorcycles, bicycles, trucks, and even pedestrians. Of course, in this case, the results will differ, and this is very important, as it will allow you to plan any route correctly. Equally important is the fact that routing by using the distance matrix is carried out combinatorially, that is, all combinations of outgoing and final locations of the route are taken into account. And that’s not all, because, in parallel with this, the current situation on the roads is taken into account, for example, traffic congestion, the actual and predicted situation with traffic jams. It should be mentioned that the work of the service is carried out using the HTTP protocol.

In addition, it will not be superfluous for users to find out that the API distance matrix can also be used in cases where there is no need to calculate optimal traffic when planning movements. For this purpose, there are other versions of the API distance matrix, which you can also find on this service.

And one more important clarification. API distance matrix developers provided the identity of the request form of their service and the Google API distance matrix service. This greatly simplifies the user experience.

API distance matrix – simple and clear

Using the API distance matrix is not difficult and intuitively clear. The process starts after the user enters information about the required start and end locations. 

For example, the parents of a child have information about several nearby schools in their residential area. In order to choose a school with the most convenient and shortest route, they need to use the API distance matrix service and enter information about the location of their home and selected schools in the form of geo-coordinates or a regular postal address.

The service will generate a response using the Jason programming language and the following default units of measurement: for distances – meters, for time – seconds. In this case, the response will not contain a geometric picture of the route. It is also very important that the service takes into account the fact of possible asymmetry of routes and roads. It means that the roads to school and from school may differ due to the peculiarity of traffic – one-way or two-way traffic, the presence of additional turns and detours, etc.

So, the necessary information that the user must include in the request is the following:

  • an indication of the place where the movement started, preferably in the form of geo-coordinates, but it is also possible in the form of a postal address (in our example, this is the location of the house from where the child will go to school);
  • an indication of the place of the end of the movement, also preferably in the form of geo-coordinates, but it is also possible in the form of a postal address (in our example, this is the location of several selected schools);
  • your unique access code in the form of a so-called API key.

As a minimum, this information will be enough to calculate the route, since the service will take into account some parameters when calculating by default. However, if possible, additional characteristics can be added to the request. Further, we list some of the optional parameters, and in detail, they can be found in one of the sections of the API distance matrix documentation, guided by the corresponding links in the “Guide for Developers”.

So, optionally (but not limited to the following), the next data can be entered into the request: mode of transportation, preferred language of the response, restrictions on the route (only one can be specified), preferred time of arrival (as an integer), preferred time of departure (only in the future tense), etc. As you can see, the more complete information was included in the request, the more accurate and informative the result generated in the service response will be.

Conclusion

Distance Matrix API

And in conclusion, let’s say a few words about the format of the API distance matrix response.

Returning to our example about finding the most convenient route for the child from home to school, we have to note that, based on the results of the information included in the request, the API distance matrix service will calculate all route options. In the lines, it will connect the source location (home) with each requested destination (schools). In this case, the API distance matrix columns will indicate the distance of each route and the time to overcome this distance in the appropriate units of measurement.

In addition to a direct response to the request with distances and times, the response must contain information clarifying the status of the request. For example, if a request was accepted for processing and a response was generated on it, then the status of the request will be indicated by the abbreviation “OK”. In other cases, the service will indicate other status designations. You can learn more about them in the “Guide for Developers”.

Popular

More like this
Related