예제 #1
0
파일: test.php 프로젝트: kletellier/adsb
 /**
  * Test if Adsb create instance
  * @return void
  */
 public function testIsInstance()
 {
     $inst = new Adsb();
     $this->assertNotNull($inst);
     $inst = new Adsb("*8D4068B6E908BE0009381053B699;");
     $this->assertEquals("8D4068B6E908BE0009381053B699", $inst->getMsg());
     $this->assertGreaterThan(0, $inst->getTs());
 }
예제 #2
0
 /**
  * Compute coordinates from Odd and Even Message (for bette result even message must be catched in first)
  * @param \Kletellier\Adsb $adsb_odd 
  * @param  \Kletellier\Adsb $adsb_even 
  * @return key value array with latitude and longitude keys
  */
 public static function getCoordinates(\Kletellier\Adsb $adsb_odd, \Kletellier\Adsb $adsb_even)
 {
     $ret = array();
     $cprlat_odd = $adsb_odd->getLatitude();
     $cprlon_odd = $adsb_odd->getLongitude();
     $cprlat_even = $adsb_even->getLatitude();
     $cprlon_even = $adsb_even->getLongitude();
     $dlat_even = 360.0 / 60;
     $dlat_odd = 360.0 / 59;
     // calculate Latitude index
     $j = floor((59 * $cprlat_even - 60 * $cprlat_odd) / 131072 + 0.5);
     $lat_even = $dlat_even * (self::modPos($j, 60) + $cprlat_even / 131072);
     if ($lat_even >= 270) {
         $lat_even = $lat_even - 360;
     }
     $lat_odd = $dlat_odd * (self::modPos($j, 59) + $cprlat_odd / 131072);
     if ($lat_odd >= 270) {
         $lat_odd = $lat_odd - 360;
     }
     if (self::cprNL($lat_even) == self::cprNL($lat_odd)) {
         $lat = "";
         $lon = "";
         if ($adsb_even->getTs() > $adsb_odd->getTs()) {
             $lat = $lat_even;
             $ni = self::cprN($lat_even, 0);
             $m = floor(($cprlon_even * (self::cprNL($lat_even) - 1) - $cprlon_odd * self::cprNL($lat_even)) / 131072.0 + 0.5);
             $lon = 360.0 / $ni * (self::modPos($m, $ni) + $cprlon_even / 131072);
         } else {
             $lat = $lat_odd;
             $ni = self::cprN($lat_odd, 1);
             $m = floor(($cprlon_even * (self::cprNL($lat_odd) - 1) - $cprlon_odd * self::cprNL($lat_odd)) / 131072 + 0.5);
             $lon = 360.0 / $ni * (self::modPos($m, $ni) + $cprlon_odd / 131072);
         }
         $lon -= floor(($lon + 180) / 360) * 360;
         if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
             $ret["longitude"] = $lon;
             $ret["latitude"] = $lat;
         } else {
             $ret = FALSE;
         }
     } else {
         // incorrect value
         $ret = FALSE;
     }
     return $ret;
 }