コード例 #1
0
ファイル: XML.php プロジェクト: ryanunderwood/phpVMS
 public function acarsdata()
 {
     $output = '';
     CodonEvent::Dispatch('refresh_acars', 'XML');
     $flights = ACARSData::GetACARSData();
     $xml = new SimpleXMLElement('<livemap/>');
     if (!$flights) {
         $flights = array();
     }
     foreach ($flights as $flight) {
         $pilot = $xml->addChild('aircraft');
         $pilot->addAttribute('flightnum', $flight->flightnum);
         $pilot->addAttribute('lat', $flight->lat);
         $pilot->addAttribute('lng', $flight->lng);
         $pilot->addChild('pilotid', PilotData::GetPilotCode($flight->code, $flight->pilotid));
         $pilot->addChild('pilotname', $flight->firstname . ' ' . $flight->lastname);
         $pilot->addChild('flightnum', $flight->flightnum);
         $pilot->addChild('lat', $flight->lat);
         $pilot->addChild('lng', $flight->lng);
         $pilot->addChild('depicao', $flight->depicao);
         $pilot->addChild('arricao', $flight->arricao);
         $pilot->addChild('phase', $flight->phasedetail);
         $pilot->addChild('alt', $flight->alt);
         $pilot->addChild('gs', $flight->gs);
         $pilot->addChild('distremain', $flight->distremain);
         $pilot->addChild('timeremain', $flight->timeremain);
     }
     header('Content-type: text/xml');
     echo $xml->asXML();
 }
コード例 #2
0
ファイル: ACARS.php プロジェクト: BogusCurry/phpvms_5.5.x
 public function data()
 {
     $flights = ACARSData::GetACARSData();
     if (!$flights) {
         $flights = array();
     }
     $this->acarsflights = array();
     foreach ($flights as $flight) {
         if ($flight->route == '') {
             $flight->route_details = array();
         } else {
             #declare stClass (php 5.5)
             $params = new stdClass();
             # Jeff's fix for ACARS
             $params->deplat = $flight->deplat;
             $params->deplng = $flight->deplng;
             $params->route = $flight->route;
             $flight->route_details = NavData::parseRoute($params);
         }
         $c = (array) $flight;
         // Convert the object to an array
         $c['pilotid'] = PilotData::GetPilotCode($c['code'], $c['pilotid']);
         // Normalize the data
         if ($c['timeremaining'] == '') {
             $c['timeremaining'] == '-';
         }
         if (trim($c['phasedetail']) == '') {
             $c['phasedetail'] = 'Enroute';
         }
         /* If no heading was passed via ACARS app then calculate it
         			This should probably move to inside the ACARSData function, so then
         			 the heading is always there for no matter what the calcuation is
         			*/
         if ($flight->heading == '') {
             /* Calculate an angle based on current coords and the
             			destination coordinates */
             $flight->heading = intval(atan2($flight->lat - $flight->arrlat, $flight->lng - $flight->arrlng) * 180 / 3.14);
             //$flight->heading *= intval(180/3.14159);
             if ($flight->lng - $flight->arrlng < 0) {
                 $flight->heading += 180;
             }
             if ($flight->heading < 0) {
                 $flight->heading += 360;
             }
         }
         // Little one-off fixes to normalize data
         $c['distremaining'] = $c['distremain'];
         $c['pilotname'] = $c['firstname'] . ' ' . $c['lastname'];
         unset($c['messagelog']);
         $this->acarsflights[] = $c;
         continue;
     }
     CodonEvent::Dispatch('refresh_acars', 'ACARS');
     echo json_encode($this->acarsflights);
 }