{"id":2700,"date":"2023-12-20T20:21:02","date_gmt":"2023-12-20T20:21:02","guid":{"rendered":"https:\/\/developers.maplink.global\/example-2-finding-the-nearest-vehicle-assistance\/"},"modified":"2024-03-01T20:36:05","modified_gmt":"2024-03-01T20:36:05","slug":"example-2-finding-the-nearest-vehicle-assistance","status":"publish","type":"post","link":"https:\/\/developers.maplink.global\/en\/example-2-finding-the-nearest-vehicle-assistance\/","title":{"rendered":"Example 2 &#8211; Finding the nearest vehicle assistance"},"content":{"rendered":"\n<p>In the vehicle insurance industry, it is very common to use the Distance Matrix API to reduce vehicle assistance service times.<\/p>\n\n<p>Since the broken-down vehicle and the tow trucks share a latitude\/longitude location, when the broken-down vehicle calls for assistance, the system can use the Distance Matrix API to decide which tow truck will arrive first.<\/p>\n\n<p>In this example, the destination is two broken-down vehicles and the origin is five tow trucks:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"calculationMode\": \"THE_FASTEST\",\n    \"destinations\": [\n        {\n            \"latitude\": -23.5654032,\n            \"longitude\": -46.62117004,\n            \"siteId\": \"veiculo1-Cambuci\"\n        },\n        {\n            \"latitude\": -23.574136,\n            \"longitude\": -46.655844,\n            \"siteId\": \"veiculo2-Jardins\"\n        }\n    ],\n    \"origins\": [\n        {\n            \"latitude\": -23.58664317,\n            \"longitude\": -46.63833618,\n            \"siteId\": \"guincho1-VilaMariana\"\n        },\n        {\n            \"latitude\": -23.562412,\n            \"longitude\": -46.638788,\n            \"siteId\": \"guincho2-Liberdade\"\n        },\n        {\n            \"latitude\": -23.55363650451996,\n            \"longitude\": -46.620810158377516,\n            \"siteId\": \"guincho3-Mooca\"\n        },\n        {\n            \"latitude\": -23.561603,\n            \"longitude\": -46.655840,\n            \"siteId\": \"guincho4-MASP\"\n        },\n        {\n            \"latitude\": -23.535016,\n            \"longitude\": -46.735701,\n            \"siteId\": \"guincho5-CEAGESP\"\n        }\n    ],\n    \"tripProfile\": \"MAPLINK\"\n}<\/pre>\n\n<p>The response returns the array of objects <code>elements<\/code>, where each object represents the relationship between each source and destination pair. <\/p>\n\n<p>In this case, the distance between each winch and vehicle will be returned. This way you can identify which tow truck will be able to provide assistance quickly.  <\/p>\n\n<p>Each object on <code>elements<\/code> will have the following information:<\/p>\n\n<ul class=\"wp-block-list\">\n<li><code>origin<\/code>  &#8211; Origin point identifier;<\/li>\n\n\n\n<li><code>destination<\/code>  &#8211; Identifier of the destination point;<\/li>\n\n\n\n<li><code>distance<\/code>  &#8211; Total distance in meters;<\/li>\n\n\n\n<li><code>nominalDuration<\/code>  &#8211; Total duration in seconds;<\/li>\n\n\n\n<li><code>averageSpeed<\/code>  &#8211; Average speed of the route between origin and destination in km\/h.<\/li>\n<\/ul>\n\n<p>The full response can be found below:<\/p>\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"id\": \"60761bd2b966b04b48d1019c\",\n    \"clientId\": \"maplink\",\n    \"elements\": [\n        {\n            \"origin\": \"guincho1-VilaMariana\",\n            \"destination\": \"veiculo1-Cambuci\",\n            \"distance\": 3569,\n            \"nominalDuration\": 643,\n            \"averageSpeed\": 19.98\n        },\n        {\n            \"origin\": \"guincho1-VilaMariana\",\n            \"destination\": \"veiculo2-Jardins\",\n            \"distance\": 3711,\n            \"nominalDuration\": 365,\n            \"averageSpeed\": 36.6\n        },\n        {\n            \"origin\": \"guincho2-Liberdade\",\n            \"destination\": \"veiculo1-Cambuci\",\n            \"distance\": 4209,\n            \"nominalDuration\": 514,\n            \"averageSpeed\": 29.48\n        },\n        {\n            \"origin\": \"guincho2-Liberdade\",\n            \"destination\": \"veiculo2-Jardins\",\n            \"distance\": 3710,\n            \"nominalDuration\": 336,\n            \"averageSpeed\": 39.75\n        },\n        {\n            \"origin\": \"guincho3-Mooca\",\n            \"destination\": \"veiculo1-Cambuci\",\n            \"distance\": 2787,\n            \"nominalDuration\": 426,\n            \"averageSpeed\": 23.55\n        },\n        {\n            \"origin\": \"guincho3-Mooca\",\n            \"destination\": \"veiculo2-Jardins\",\n            \"distance\": 5265,\n            \"nominalDuration\": 490,\n            \"averageSpeed\": 38.68\n        },\n        {\n            \"origin\": \"guincho4-MASP\",\n            \"destination\": \"veiculo1-Cambuci\",\n            \"distance\": 6842,\n            \"nominalDuration\": 859,\n            \"averageSpeed\": 28.67\n        },\n        {\n            \"origin\": \"guincho4-MASP\",\n            \"destination\": \"veiculo2-Jardins\",\n            \"distance\": 2082,\n            \"nominalDuration\": 305,\n            \"averageSpeed\": 24.57\n        },\n        {\n            \"origin\": \"guincho5-CEAGESP\",\n            \"destination\": \"veiculo1-Cambuci\",\n            \"distance\": 15608,\n            \"nominalDuration\": 1588,\n            \"averageSpeed\": 35.38\n        },\n        {\n            \"origin\": \"guincho5-CEAGESP\",\n            \"destination\": \"veiculo2-Jardins\",\n            \"distance\": 11217,\n            \"nominalDuration\": 1057,\n            \"averageSpeed\": 38.2\n        }\n    ],\n    \"createdAt\": 1618353108108\n}<\/pre>\n\n<p>In a tabular view of the result, it is possible to conclude the following:<\/p>\n\n<ol class=\"wp-block-list\">\n<li>The vehicle <code>\"veiculo1-Cambuci\"<\/code> will receive faster and closer service from the tow truck <code>\"guincho3-Mooca\"<\/code>;<\/li>\n\n\n\n<li>The vehicle <code>\"veiculo2-Jardins\"<\/code> will receive faster and closer service from the tow truck <code>\"guincho4-MASP\"<\/code>.<\/li>\n<\/ol>\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>origin<\/strong><\/td><td><strong>destination<\/strong><\/td><td><strong>distance<\/strong><\/td><td><strong>nominalDuration<\/strong><\/td><td><strong>averageSpeed<\/strong><\/td><\/tr><tr><td><code>guincho1-VilaMariana<\/code><\/td><td><code>veiculo1-Cambuci<\/code><\/td><td>3569<\/td><td>643<\/td><td>19.98<\/td><\/tr><tr><td><code>guincho2-Liberdade<\/code><\/td><td><code>veiculo1-Cambuci<\/code><\/td><td>4209<\/td><td>514<\/td><td>29.48<\/td><\/tr><tr><td><code>guincho3-Mooca<\/code><\/td><td><code>veiculo1-Cambuci<\/code><\/td><td>2787<\/td><td>426<\/td><td>23.55<\/td><\/tr><tr><td><code>guincho4-MASP<\/code><\/td><td><code>veiculo1-Cambuci<\/code><\/td><td>6842<\/td><td>859<\/td><td>28.67<\/td><\/tr><tr><td><code>guincho5-CEAGESP<\/code><\/td><td><code>veiculo1-Cambuci<\/code><\/td><td>15608<\/td><td>1588<\/td><td>35.38<\/td><\/tr><tr><td><code>guincho1-VilaMariana<\/code><\/td><td><code>veiculo1-Jardins<\/code><\/td><td>3711<\/td><td>365<\/td><td>36.6<\/td><\/tr><tr><td><code>guincho2-Liberdade<\/code><\/td><td><code>veiculo1-Jardins<\/code><\/td><td>3710<\/td><td>336<\/td><td>39.75<\/td><\/tr><tr><td><code>guincho3-Mooca<\/code><\/td><td><code>veiculo1-Jardins<\/code><\/td><td>5265<\/td><td>490<\/td><td>38.68<\/td><\/tr><tr><td><code>guincho4-MASP<\/code><\/td><td><code>veiculo1-Jardins<\/code><\/td><td>2082<\/td><td>305<\/td><td>24.57<\/td><\/tr><tr><td><code>guincho5-CEAGESP<\/code><\/td><td><code>veiculo1-Jardins<\/code><\/td><td>11217<\/td><td>1057<\/td><td>38.2<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">Result of the request organized in a table<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In the vehicle insurance industry, it is very common to use the Distance Matrix API to reduce vehicle assistance service times. Since the broken-down vehicle and the tow trucks share a latitude\/longitude location, when the broken-down vehicle calls for assistance, the system can use the Distance Matrix API to decide which tow truck will arrive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[165],"tags":[],"class_list":["post-2700","post","type-post","status-publish","format-standard","hentry","category-distance-matrix-en"],"acf":[],"_links":{"self":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2700","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/comments?post=2700"}],"version-history":[{"count":4,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2700\/revisions"}],"predecessor-version":[{"id":2706,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/posts\/2700\/revisions\/2706"}],"wp:attachment":[{"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/media?parent=2700"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/categories?post=2700"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/developers.maplink.global\/en\/wp-json\/wp\/v2\/tags?post=2700"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}