Update: 2026-07-06 01:01:29
This commit is contained in:
@@ -73,9 +73,15 @@ try {
|
|||||||
$newAwfarPrice = round($newSpeedPrice * 0.85, 3);
|
$newAwfarPrice = round($newSpeedPrice * 0.85, 3);
|
||||||
|
|
||||||
// أسعار الدقائق
|
// أسعار الدقائق
|
||||||
$newNormalMin = round($newSpeedPrice / 4, 3);
|
if ($country === 'JO') {
|
||||||
$newPeakMin = round($newNormalMin * 1.15, 3);
|
$newNormalMin = 0.06;
|
||||||
$newLateMin = round($newNormalMin * 1.25, 3);
|
$newPeakMin = 0.07;
|
||||||
|
$newLateMin = 0.08;
|
||||||
|
} else {
|
||||||
|
$newNormalMin = round($newSpeedPrice / 4, 3);
|
||||||
|
$newPeakMin = round($newNormalMin * 1.15, 3);
|
||||||
|
$newLateMin = round($newNormalMin * 1.25, 3);
|
||||||
|
}
|
||||||
|
|
||||||
$updateSql = "UPDATE kazan
|
$updateSql = "UPDATE kazan
|
||||||
SET speedPrice = :speedPrice,
|
SET speedPrice = :speedPrice,
|
||||||
|
|||||||
@@ -91,11 +91,12 @@ foreach ($data as $row) {
|
|||||||
$startLng = $resultData['start_lng'] ?? null;
|
$startLng = $resultData['start_lng'] ?? null;
|
||||||
$endLat = $resultData['end_lat'] ?? null;
|
$endLat = $resultData['end_lat'] ?? null;
|
||||||
$endLng = $resultData['end_lng'] ?? null;
|
$endLng = $resultData['end_lng'] ?? null;
|
||||||
|
$countryCode = $row['country_code'] ?? 'JO'; // Default
|
||||||
|
|
||||||
// --- OSRM Integration (Dynamic Distance & Duration) ---
|
// --- OSRM Integration (Dynamic Distance & Duration) ---
|
||||||
require_once __DIR__ . '/../core/osrm_routing.php';
|
require_once __DIR__ . '/../core/osrm_routing.php';
|
||||||
if ($startLat && $endLat && (!$durationMin || $durationMin <= 0)) {
|
if ($startLat && $endLat && (!$durationMin || $durationMin <= 0)) {
|
||||||
$osrmResult = getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng);
|
$osrmResult = getOsrmRouteDetails($startLat, $startLng, $endLat, $endLng, $countryCode);
|
||||||
if ($osrmResult) {
|
if ($osrmResult) {
|
||||||
$distanceKm = $osrmResult['distance_km']; // Override with accurate OSRM distance
|
$distanceKm = $osrmResult['distance_km']; // Override with accurate OSRM distance
|
||||||
$durationMin = $osrmResult['duration_min'];
|
$durationMin = $osrmResult['duration_min'];
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ if ($method === 'GET') {
|
|||||||
require_once __DIR__ . '/../core/osrm_routing.php';
|
require_once __DIR__ . '/../core/osrm_routing.php';
|
||||||
$duration_min = 0;
|
$duration_min = 0;
|
||||||
if ($start_lat != 0 && $end_lat != 0) {
|
if ($start_lat != 0 && $end_lat != 0) {
|
||||||
$osrmResult = getOsrmRouteDetails($start_lat, $start_lng, $end_lat, $end_lng);
|
$osrmResult = getOsrmRouteDetails($start_lat, $start_lng, $end_lat, $end_lng, $country_code);
|
||||||
if ($osrmResult) {
|
if ($osrmResult) {
|
||||||
$distance_km = $osrmResult['distance_km']; // Override with accurate OSRM distance
|
$distance_km = $osrmResult['distance_km']; // Override with accurate OSRM distance
|
||||||
$duration_min = $osrmResult['duration_min'];
|
$duration_min = $osrmResult['duration_min'];
|
||||||
|
|||||||
@@ -13,15 +13,27 @@
|
|||||||
* @param float $startLng
|
* @param float $startLng
|
||||||
* @param float $endLat
|
* @param float $endLat
|
||||||
* @param float $endLng
|
* @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.
|
* @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
|
// Format: longitude,latitude
|
||||||
$coordinates = "{$startLng},{$startLat};{$endLng},{$endLat}";
|
$coordinates = "{$startLng},{$startLat};{$endLng},{$endLat}";
|
||||||
|
|
||||||
// Using public demo server. Note: Has rate limits.
|
// Select Intaleq/Siro OSRM server based on country
|
||||||
// For production, highly recommended to use: "http://your-own-osrm-server.com:5000"
|
switch (strtoupper($countryCode)) {
|
||||||
$osrmBaseUrl = "http://router.project-osrm.org";
|
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";
|
$url = "{$osrmBaseUrl}/route/v1/driving/{$coordinates}?overview=false";
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|||||||
Reference in New Issue
Block a user