Jump to content
Sign in to follow this  
bass

Check whether the pilot arrived at the destination airport or not

Recommended Posts

Hello, for my site I made a check whether the pilot arrived at the right airport or not.

The script is installed in pirep_viewreport.tpl

This script I found on the Internet and applied it to the site.
In fact it is a distance rival.
1) You set an acceptable landing distance from the point (Airport) to an example of 35 km.
2) The data is compared, Example:
If the pilot landed the aircraft no further than 35 km from the point of coordinates of your arrival airport, the Value is ALL GOOD, if this distance is more than permissible (in my case 35 km), So the pilot arrived at some other airport and issued a warning !.

  • This photo shows that I should fly to UNNT, but I made a circle and returned to the airport of departure.

2017-10-29_144044.jpg

 

On this photo you can see a warning !!!

"You did not land the plane at the designated airport!"

2017-10-29_144541.jpg

 

This is the conclusion of an example when everything is fine. The pilot arrived at the right airport.

2017-10-29_144902.jpg

 

This is the code itself.

<!--Скрипт сравнения расстояния-->
<?php
// Радиус земли
define('EARTH_RADIUS', 6372795);

function calculateTheDistance ($φA, $λA, $φB, $λB) {
 
    // перевести координаты в радианы
    $lat1 = $φA * M_PI / 180;
    $lat2 = $φB * M_PI / 180;
    $long1 = $λA * M_PI / 180;
    $long2 = $λB * M_PI / 180;
 
    // косинусы и синусы широт и разницы долгот
    $cl1 = cos($lat1);
    $cl2 = cos($lat2);
    $sl1 = sin($lat1);
    $sl2 = sin($lat2);
    $delta = $long2 - $long1;
    $cdelta = cos($delta);
    $sdelta = sin($delta);
 
    // вычисления длины большого круга
    $y = sqrt(pow($cl2 * $sdelta, 2) + pow($cl1 * $sl2 - $sl1 * $cl2 * $cdelta, 2));
    $x = $sl1 * $sl2 + $cl1 * $cl2 * $cdelta;
 
    //
    $ad = atan2($y, $x);
    $dist = $ad * EARTH_RADIUS;
 
    return $dist;
}
 
   
$query = "SELECT * FROM phpvms_airports WHERE icao='$pirep->arricao'";
$Result = DB::get_results($query);
foreach($Result as $a)
{
$lat1 =  $a->lat;
$long1 =  $a->lng;
}
$lat2 = round($latP, 4); //LAT точки приземления
$long2 = round($lngP, 4); //LON точки прибытия
?>
<br>
<?php
$dopustimaia = 35000; // Это число в метрах допустимых от точки (Аэропорта)
$itogovaia = calculateTheDistance($lat1, $long1, $lat2, $long2);  // Это должна быть переменная точки приземления
if ($dopustimaia > $itogovaia) {
 echo '<div class="view-header">
                        
                        <div class="header-icon">
                            <i class="pe page-header-icon pe-7s-map-marker"></i>
                        </div>
                        <div class="header-title">
                            <h3>Благодарность от администрации</h3>
                            <small>
                                Рейс окончен в назначенном аэропорту.
                            </small>
                        </div>
                    </div>';
}
 else {
 echo '<div class="view-header">
                        
                        <div class="header-icon">
                            <i class="pe page-header-icon pe-7s-speaker"></i>
                        </div>
                        <div class="header-title">
                            <h3>Предупреждение!</h3>
                            <small>
                                С вас будет взысконно -1000 миль и -10 часов налета. Вы посадили самолет не в назначенном аэропорту!
                            </small>
                        </div>
                    </div>';
}
 
?>

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...