وب سرویس مسیریابی چند مقصده متد برنامه ریزی سفر
در مطلب قبل وب سرویس برنامه ریزی سفر را معرفی کردیم در این مطلب در مورد API مسیریابی جند مقصده را توضیح میدهیم.
این ابزار به شما کمک میکند تا بین یک مبدا و مقصد و یک یا چند نقطه بین آنها کوتاهترین مسیر را پیدا کنید. همچنین شروطی را برای رسیدن به هر یک از این نقاط داشته باشید. به عنوان مثال شما شاید بخواهید حتما یک ایستگاه خاص قبل یا بعد از یک ایستگاه دیگر بازدید شود و یا آن ایستگاه خاص حتما بین ساعت 4 تا 6 بعدظهر بازدید شود چون به دلایلی در ساعاتی غیر از آن ساعات کسی برای تحویل گرفتن بسته شما وجود ندارد.
در بدنه درخواست، مختصات جغرافیایی یک مبدا، یک مقصد و توقفگاههای بین آنها را مشخص کنید. سیستم میتواند جواب درخواست شما را به دو صورت اعلام کند.
شیوه اول به این صورت است که در جواب درخواست، برای شما یک شناسه وظیفه برمیگردد که میتوانید با رابط برنامه نویسی دیگری در هر زمان از وضعیت پردازش آن با خبر شوید، و روش دوم به این صورت است که با ست کردن آدرس یک وب هوک ما جواب را به محض آماده شدن برای شما ارسال کنیم.
Parameter | Type | Description |
origin.geo | Object | Location of origin in format : {lat, lng} |
origin.service_time Optional | Number | Waiting or processing time at the location, the time delay between arrival and departure (minutes) |
destination.geo | Object | Location of destination in format : {lat, lng} |
destination.service_time Optional | Number | Waiting or processing time at the location, the time delay between arrival and departure (minutes) |
waypoints | Array | An array of objects representing waypoints of your route, in format: {id: ‘string’, geo:{lat, lng}, restrictions:{}}. For more details please refer to “Waypoint Object Definition” in below. |
webhook_url Optional | String | A URL you want your results to be posted to, whenever completed |
Waypoint Object Definition
Each waypoint in waypoints object described above is consisted of following key/values:
Key | Type | Description |
id | String | An arbitrary string representing the waypoint |
geo | Object | Location of waypoint in format: {lat, lng} |
service_time Optional | Number | Waiting or processing time at the location, the time delay between arrival and departure (minutes) |
restrictions.after Optional | String | ID of another waypoint which this waypoint can be visited after. |
restrictions.before Optional | String | ID of another waypoint which this waypoint should be visited before. |
restrictions.ready Optional | Number | Earliest time the waypoint may be visited (minutes, greater than 0). This time is relative to plan’s start time. A route starts at 0 minutes. e.g. if you start driving at 8:00AM and a location needs to be visited after 9:00AM, use ready: 60. |
restrictions.due Optional | Number | Latest time the waypoint may be visited (minutes, greater than 0). This time is relative to plan’s start time. A route starts at 0 minutes. e.g. if you start driving at 8:00AM and a location needs to be visited before 10:00AM, use ready: 120. |
انواع پاسخ
اگر مشکلی در درخواست شما وجود ندارد ، پاسخی را با وضعیت 201 HTTP دریافت خواهید کرد که نشان می دهد کار شما انجام شده است و یک job_id را برای شما فراهم می کند که بعدا می توانید وضعیت آن را بدست آورید.
اگر مشکلی در درخواست شما رخ ندهد ، ممکن است یکی از این پیامهای خطا را دریافت کنید:
Type | Status Code | Description |
VALIDATION_ERROR | 422 | One or more properties of your request body is invalid |
RATE_LIMITED_ERROR | 429 | Too many requests |
AUTHENTICATION_ERROR | 401 | Your access token is not valid |
HEADERS
AuthorizationBearer {{access_token}}
Content-Typeapplication/json
BODY raw
{
“webhook_url”: “http://e438c29d.ngrok.io”,
“origin”: {
“geo”: {
“lat”: 35.734686,
“lng”: 51.370495
}
},
“destination”: {
“geo”: {
“lat”: 35.735601,
“lng”: 51.333876
}
},
“waypoints”: [
{
“service_time”: 12,
“id”: “stop-1”,
“restrictions”: {
“after”: “stop-2”
},
“geo”: {
“lat”: 35.735601,
“lng”: 51.333876
}
},
{
“id”: “stop-2”,
“geo”: {
“lat”: 35.733198,
“lng”: 51.359832
}
},
{
“id”: “stop-3”,
“geo”: {
“lat”: 35.731386,
“lng”: 51.351174
}
}
]
}
در این مظلب در مورد متدهای API مسیریابی جند مقصده صحبت کردیم در مطلب بعد متدهای آن را مورد بررسی قرار میدهیم.