Update: 2026-07-06 01:01:29
This commit is contained in:
@@ -13,15 +13,27 @@
|
||||
* @param float $startLng
|
||||
* @param float $endLat
|
||||
* @param float $endLng
|
||||
* @param string $countryCode (e.g. 'JO', 'SY', 'EG')
|
||||
* @return array|null Returns ['distance_km' => float, 'duration_min' => float] or null on failure.
|
||||
*/
|
||||
function getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng) {
|
||||
function getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng, $countryCode = 'JO') {
|
||||
// Format: longitude,latitude
|
||||
$coordinates = "{$startLng},{$startLat};{$endLng},{$endLat}";
|
||||
|
||||
// Using public demo server. Note: Has rate limits.
|
||||
// For production, highly recommended to use: "http://your-own-osrm-server.com:5000"
|
||||
$osrmBaseUrl = "http://router.project-osrm.org";
|
||||
// Select Intaleq/Siro OSRM server based on country
|
||||
switch (strtoupper($countryCode)) {
|
||||
case 'SY':
|
||||
$osrmBaseUrl = "https://routes-syria.siromove.com";
|
||||
break;
|
||||
case 'EG':
|
||||
$osrmBaseUrl = "https://routes-egypt.siromove.com";
|
||||
break;
|
||||
case 'JO':
|
||||
default:
|
||||
$osrmBaseUrl = "https://routesjo.intaleq.xyz";
|
||||
break;
|
||||
}
|
||||
|
||||
$url = "{$osrmBaseUrl}/route/v1/driving/{$coordinates}?overview=false";
|
||||
|
||||
$ch = curl_init();
|
||||
|
||||
Reference in New Issue
Block a user