نسخة كاملة من مستودع سيرو عند ecfe7568 لتكون أساس تطبيق «انطلق». نُسخ المتعقَّب في git فقط (12,509 ملفاً / 302 م.ب) بـ git archive، لا `cp -r` — فاستُثنيت تلقائياً مخلفات البناء (build · node_modules · .dart_tool · .gradle · Pods ≈ 10.7 غ.ب) وكل ما يستثنيه .gitignore. هذا الكوميت **بلا أي تعديل عمداً** حتى يكون كل ما يليه فرقاً مقروءاً مقابل سيرو الأصلي. سيرو نفسه لم يُمسّ. ⚠️ لا يبني بعد: `.env` و`lib/env/env.g.dart` غير متعقَّبين في سيرو (وهذا صحيح — أسرار لكل مستأجر). كل تطبيق فلاتر هنا يحتاج .env خاصاً بانطلق ثم توليد env.g.dart عبر build_runner. لا تُنسخ أسرار سيرو. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?php
|
|
// ============================================================
|
|
// osrm_routing.php
|
|
// Helper functions for OpenStreetMap Routing Machine (OSRM)
|
|
// Used to estimate accurate distance (km) and duration (mins)
|
|
// ============================================================
|
|
|
|
/**
|
|
* Get Distance and Duration between two coordinates using public OSRM server.
|
|
* Note: If you host your own OSRM, replace the $osrmBaseUrl.
|
|
*
|
|
* @param float $startLat
|
|
* @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, $countryCode = 'JO') {
|
|
// Intaleq Maps SaaS server handles all countries (Jordan, Syria, Egypt)
|
|
$baseUrl = "https://map-saas.intaleqapp.com/api/maps/route";
|
|
|
|
$queryParams = http_build_query([
|
|
'fromLat' => $startLat,
|
|
'fromLng' => $startLng,
|
|
'toLat' => $endLat,
|
|
'toLng' => $endLng
|
|
]);
|
|
|
|
$url = "{$baseUrl}?{$queryParams}";
|
|
|
|
$ch = curl_init();
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 5 seconds timeout
|
|
|
|
// Add Intaleq API Key Header
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"x-api-key: in_9478b32836d19cff73db3063"
|
|
]);
|
|
|
|
$response = curl_exec($ch);
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
curl_close($ch);
|
|
|
|
if ($httpCode === 200 && $response) {
|
|
$data = json_decode($response, true);
|
|
if (isset($data['distance']) && isset($data['duration'])) {
|
|
$distanceMeters = (float)$data['distance'];
|
|
$durationSeconds = isset($data['trafficAwareDuration']) ? (float)$data['trafficAwareDuration'] : (float)$data['duration'];
|
|
|
|
return [
|
|
'distance_km' => round($distanceMeters / 1000, 2),
|
|
'duration_min' => round($durationSeconds / 60, 2)
|
|
];
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|