Update: 2026-07-06 01:20:19
This commit is contained in:
@@ -17,19 +17,8 @@
|
|||||||
* @return array|null Returns ['distance_km' => float, 'duration_min' => float] or null on failure.
|
* @return array|null Returns ['distance_km' => float, 'duration_min' => float] or null on failure.
|
||||||
*/
|
*/
|
||||||
function getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng, $countryCode = 'JO') {
|
function getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng, $countryCode = 'JO') {
|
||||||
// Select Intaleq Maps SaaS server based on country
|
// Intaleq Maps SaaS server handles all countries (Jordan, Syria, Egypt)
|
||||||
switch (strtoupper($countryCode)) {
|
$baseUrl = "https://map-saas.intaleqapp.com/api/maps/route";
|
||||||
case 'SY':
|
|
||||||
$baseUrl = "https://map-syria.siromove.com/api/maps/route";
|
|
||||||
break;
|
|
||||||
case 'EG':
|
|
||||||
$baseUrl = "https://map-egypt.siromove.com/api/maps/route";
|
|
||||||
break;
|
|
||||||
case 'JO':
|
|
||||||
default:
|
|
||||||
$baseUrl = "https://map-saas.intaleqapp.com/api/maps/route";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$queryParams = http_build_query([
|
$queryParams = http_build_query([
|
||||||
'fromLat' => $startLat,
|
'fromLat' => $startLat,
|
||||||
@@ -58,7 +47,7 @@ function getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng, $countryCod
|
|||||||
$data = json_decode($response, true);
|
$data = json_decode($response, true);
|
||||||
if (isset($data['distance']) && isset($data['duration'])) {
|
if (isset($data['distance']) && isset($data['duration'])) {
|
||||||
$distanceMeters = (float)$data['distance'];
|
$distanceMeters = (float)$data['distance'];
|
||||||
$durationSeconds = (float)$data['duration'];
|
$durationSeconds = isset($data['trafficAwareDuration']) ? (float)$data['trafficAwareDuration'] : (float)$data['duration'];
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'distance_km' => round($distanceMeters / 1000, 2),
|
'distance_km' => round($distanceMeters / 1000, 2),
|
||||||
|
|||||||
Reference in New Issue
Block a user