API

Forecast Routing API | คาดการณ์เส้นทางที่ดีที่สุดในอนาคต จากข้อมูลในอดีต

การค้นหาเส้นทางที่ดีที่สุด (Routing API) ของ Longdo Map ได้ปล่อย service สำหรับการคาดการณ์ระยะเวลาเดินทางในอนาคต หรือที่เรียกว่า Forecast routing API ให้นักพัฒนา หรือธุรกิจที่เกี่ยวข้อง เช่น ธุรกิจหรือ Startup ที่ใช้การวางแผนการเดินรถ, การเดินทางขนส่ง หรือ Delivery ต่างๆ นำไปต่อยอด เสริมความแม่นยำในการวางแผน ตามตัวอย่างภาพด้านล่างนี้

Forecast Routing API
การค้นหาระยะทางที่ดีที่สุด ในอนาคต จากเว็บไซต์ https://traffic.longdo.com/

โดยบทความนี้ จะอธิบายให้นักพัฒนาที่สนใจ เข้าใจถึงวิธีการใช้งานเบื้องต้นกันครับ

วิธีการใช้งาน Forecast Routing API

Forecast Routing API:

https://mmmap15.longdo.com/mmroute/json/route/guide?flon=100.48489585518837&flat=13.746034127241094&tlon=100.53901210427284&tlat=13.7466177331074&mode=t&type=127&restrict=0&locale=th&time=1575572400&key=[YOUR-KEY-API]&maxresult=1

คำอธิบายของ Parameter

[Number]flon: Lontitude of the starting point, up to 25 coordinates
[Number]flat: Latitude of the starting point, up to 25 coordinates
[Number]tlon: Lontitude of the destination, up to 25 coordinates
[Number]tlat: Latitude of the destination, up to 25 coordinates
RouteNotemode: Search mode (Default: Avoid traffic)
RouteTypetype: Allow travel method, can combine (Default: All type)
LocaleCodelocale: Language in ISO 639-1 format (Default: th)
RouteRestrictrestrict: Vehicle restriction (Default: none)
Unix timetime: Departure time, use with avoid traffic mode
(Default: now, Past time is invalid)
stringkey: Longdo Map API Key
stringcallback: JSONP Callback function
(Default: Response in JSON)
[Number]timestamp: forecast time

อย่าลืมสมัครคีย์ API ด้วยนะครับ (ใช้ฟรีได้ 100,000 transactions/เดือน) วิธีการสมัคร Map API key ฟรี

สิ่งที่เราต้องสนใจก็คือ Parameter ที่ชื่อว่า timestamp ครับ ในส่วนนี้ให้เราใส่เป็นวันที่และเวลา ในอนาคต ที่ท่านต้องการ (Format ต้องเป็นเลข timestamp ด้วยนะครับ)

เช่น

12 ธันวาคม 2562 เวลา 10.00 น. => 1576119600
12 ธันวาคม 2562 เวลา 17.00 น. => 1576144800

อ้างอิงจากเว็บแปลงออนไลน์: https://www.timestampconvert.com/

ผลลัพธ์ที่ได้:

{
   "meta": {
     "from": {
       "lon": 100.49712672829628,
       "lat": 13.7213546061962
     },
     "to": {
       "lon": 100.53433433175087,
       "lat": 13.74586738244075
     },
     "config": "t119th0"
   },
   "data": [
     {
       "fdistance": 3.5873892,
       "tdistance": 29.747112,
       "id": 38630000,
       "guide": [
         {
           "turn": 4,
           "name": "ถนนกรุงธนบุรี",
           "distance": 1115,
           "interval": 125
         },
         ... // distance detail
       ],
       "distance": 7154,
       "interval": 711,
       "penalty": 150
     }
   ]
 }

distance คือ ระยะทางในหน่วยเมตร
interval คือ ระยะทางในหน่วยวินาที

สรุป

การคาดการณ์เส้นทางในอนาคตที่ได้มานั้น (ทั้งระยะทางและเวลา) ได้มาจากสถิติการจราจรย้อนหลังนำมาคิดเฉลี่ย และมีจากตัวแปรอื่นๆ ที่เกี่ยวข้อง ที่ Longdo Map ได้มีการเก็บบันทึกย้อนหลังไว้ กล่าวคือ เป็นเวลาโดยประมาณที่มีโอกาสเป็นไปได้มากที่สุดเท่านั้น อาจะไม่ใช่เวลาจริงๆ ที่จะเกิดขึ้นในช่วงเวลานั้นๆ ก็ได้

คุณก็รู้ ประเทศไทย เดายาก ;P


ยังมี Service API ที่เป็นประโยชน์อีกมาก ดูได้ที่นี่: https://map.longdo.com/docs
หรือหากมีข้อสงสัย สามารถติดต่อที่ sales@mm.co.th ได้ตลอดครับ