Corrected Korea
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user