Efficiency-calculation

From VPOIDS Documentation

This is how the efficiency calculation is done.

  • FA = from airport
  • TA = to airport
  • HB = homebase (origin)

{ FA -> TA + HB -> FA + HB -> TA = total_distance

FA -> TA distance / total_distance * 2 = efficiency

In the SQL below:

  • c1 is the origin airport for the mission leg
  • c2 is the destination airport for the mission leg
  • hb is the pilot's home base airport, or other point of comparison


   if ($home_base && $hb_airport = AirportPeer::retrieveByPK($home_base))
   {
         $c->addAsColumn('efficiency', "
         CEILING(ROUND(ACOS(SIN(RADIANS(c1.latitude))
         *SIN(RADIANS(c2.latitude))+COS(RADIANS(c1.latitude))
         *COS(RADIANS(c2.latitude))*COS(RADIANS(c1.longitude)-RADIANS(c2.longitude))) 
         *((180*60)/PI()))/(ROUND(ACOS(SIN(RADIANS(c1.latitude))
         *SIN(RADIANS(c2.latitude))+COS(RADIANS(c1.latitude))
         *COS(RADIANS(c2.latitude))
         *     
         COS(RADIANS(c1.longitude)-RADIANS(c2.longitude))
           ) * ((180*60)/PI())
         )
         +
         ROUND(
           ACOS(
             SIN(RADIANS({$hb_airport->getLatitude()}))
             *
             SIN(RADIANS(c2.latitude))
             +
             COS(RADIANS({$hb_airport->getLatitude()}))
             *
             COS(RADIANS(c2.latitude))
             *
             COS(RADIANS({$hb_airport->getLongitude()})-RADIANS(c2.longitude))
           ) * ((180*60)/PI())
         )
         +
         ROUND(
           ACOS(
             SIN(RADIANS({$hb_airport->getLatitude()}))
             *
             SIN(RADIANS(c1.latitude))
             +
             COS(RADIANS({$hb_airport->getLatitude()}))
             *
             COS(RADIANS(c1.latitude))
             *
             COS(RADIANS({$hb_airport->getLongitude()})-RADIANS(c1.longitude))
           ) * ((180*60)/PI()))) * 200)");
         
     $c->addDescendingOrderByColumn('efficiency');
   }