if (!isset($globalDebug)) { $globalDebug = FALSE; } // Check if schema is at latest version $schema = new Connection(); if ($schema->latest() === false) { echo "You MUST update to latest schema. Run install/index.php"; exit; } if (isset($globalServer) && $globalServer) { $SI = new SpotterServer(); } else { $SI = new SpotterImport(); } $APRS = new APRS(); $SBS = new SBS(); $ATC = new ATC(); $Common = new Common(); date_default_timezone_set('UTC'); // signal handler - playing nice with sockets and dump1090 if (function_exists('pcntl_fork')) { pcntl_signal(SIGINT, function ($signo) { global $sockets; echo "\n\nctrl-c or kill signal received. Tidying up ... "; die("Bye!\n"); }); pcntl_signal_dispatch(); } // let's try and connect if ($globalDebug) { echo "Connecting...\n";
static function cprN($lat, $isodd) { $nl = SBS::cprNL($lat) - $isodd; if ($nl > 1) { return $nl; } else { return 1; } }
if ($latlon[$icao]['created'] > time()) { $ni = SBS::cprN($lat_even, 0); $m = floor($cprlon_even * (SBS::cprNL($lat_even) - 1) - $cprlon_odd * SBS::cprNL($lat_even) + 0.5); $lon = 360.0 / $ni * ($m % $ni + $cprlon_even); $lat = $lat_even; if ($lon > 180) { $lon = $lon - 360; } if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; $data['latitude'] = $lat; $data['longitude'] = $lon; } } else { $ni = SBS::cprN($lat_odd, 1); $m = floor($cprlon_even * (SBS::cprNL($lat_odd) - 1) - $cprlon_odd * SBS::cprNL($lat_odd) + 0.5); $lon = 360.0 / $ni * ($m % $ni + $cprlon_odd); $lat = $lat_odd; if ($lon > 180) { $lon = $lon - 360; } if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; $data['latitude'] = $lat; $data['longitude'] = $lon; } } } unset($latlon[$icao]); } } elseif ($tc == 19) {