Corrected Korea

This commit is contained in:
2026-04-09 11:20:16 +10:00
parent 43f5c8ac3e
commit 7a07616f03
19 changed files with 1530 additions and 399 deletions
+18
View File
@@ -31,6 +31,24 @@ class UserFlight extends Model
'arrival_date' => 'immutable_datetime',
];
public function calculateGreatCircleDistance(): float{
$earthRadiusKm = 6371;
[$depLat, $depLong] = [$this->departureAirport->latitude_deg, $this->departureAirport->longitude_deg];
[$arrLat, $arrLong] = [$this->arrivalAirport->latitude_deg, $this->arrivalAirport->longitude_deg];
$latDelta = deg2rad($arrLat - $depLat);
$longDelta = deg2rad($arrLong - $depLong);
$a = sin($latDelta / 2) * sin($latDelta / 2)
+ cos(deg2rad($depLat)) * cos(deg2rad($arrLat))
* sin($longDelta / 2) * sin($longDelta / 2);
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
return $earthRadiusKm * $c;
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);