2 require_once('require/class.Connection.php');
3 require_once('require/class.Common.php');
4 require_once('require/class.Satellite.php');
5 date_default_timezone_set('UTC');
6 //$begintime = microtime(true);
7 $Satellite = new Satellite();
8 $Common = new Common();
10 if (isset($_GET['download'])) {
11 if ($_GET['download'] == "true")
13 header('Content-disposition: attachment; filename="flightairmap-sat.json"');
16 $history = urldecode(filter_input(INPUT_GET
,'history',FILTER_SANITIZE_STRING
));
17 header('Content-Type: text/javascript');
19 $begintime = microtime(true);
20 //$sqltime = round(microtime(true)-$begintime,2);
22 $spotter_array = array();
23 if (isset($_COOKIE['sattypes']) && $_COOKIE['sattypes'] != '') {
24 $sattypes = explode(',',$_COOKIE['sattypes']);
25 foreach ($sattypes as $sattype) {
26 //$spotter_array = array_merge($Satellite->position_all_type($sattype,$timeb-$globalLiveInterval,$timeb),$spotter_array);
27 $spotter_array = array_merge($Satellite->position_all_type($sattype),$spotter_array);
31 if ((isset($_COOKIE['displayiss']) && $_COOKIE['displayiss'] == 'true') ||
!isset($_COOKIE['displayiss'])) {
32 $spotter_array[] = $Satellite->position('ISS (ZARYA)');
33 $spotter_array[] = $Satellite->position('TIANGONG 1');
34 $spotter_array[] = $Satellite->position('TIANGONG-2');
37 //$spotter_array = array_unique($spotter_array,SORT_REGULAR);
38 //print_r($spotter_array);
39 $sqltime = round(microtime(true)-$begintime,2);
41 $output = '{"type":"FeatureCollection","features":[';
42 if (!empty($spotter_array) && is_array($spotter_array))
45 $coordinatearray = '';
47 foreach($spotter_array as $spotter_item)
50 $output_data .= '{"type":"Feature","properties":{';
51 $output_data .= '"famsatid":"'.$spotter_item['name'].'",';
52 $output_data .= '"name":"'.urlencode($spotter_item['name']).'",';
53 $output_data .= '"callsign":"'.$spotter_item['name'].'",';
54 $output_data .= '"type":"satellite",';
55 if ($spotter_item['name'] == 'ISS (ZARYA)') {
56 $output_data .= '"aircraft_shadow":"iss.png",';
57 } elseif ($spotter_item['name'] == 'TIANGONG 1' ||
$spotter_item['name'] == 'TIANGONG-2') {
58 $output_data .= '"aircraft_shadow":"tiangong1.png",';
60 $output_data .= '"aircraft_shadow":"defaultsat.png",';
62 $output_data .= '"altitude":0,';
63 $output_data .= '"sqt":'.$sqltime.',';
64 $nextlatlon = $Satellite->position($spotter_item['name'],time()+
$globalMapRefresh+
20);
65 $nextlat = $nextlatlon['latitude'];
66 if (abs($nextlat-$spotter_item['latitude']) > 90) {
67 if ($spotter_item['latitude'] < 0) $nexlat = -90;
70 $nextlon = $nextlatlon['longitude'];
71 if (abs($nextlon-$spotter_item['longitude']) > 180) {
72 if ($spotter_item['longitude'] < 0) $nextlon = -180;
75 $output_data .= '"nextlatlon":['.$nextlat.','.$nextlon.']},';
76 //$output_data .= '"heading":"'.$Common->getHeading($spotter_item['latitude'],$spotter_item['longitude'],$nextlatlon['latitude'],$nextlatlon['longitude']).'",';
77 $output_data .= '"geometry":{"type":"Point","coordinates":[';
78 $output_data .= $spotter_item['longitude'].','.$spotter_item['latitude'];
79 $output_data .= ']}},';
80 $output .= $output_data;
81 if ($history == $spotter_item['name']) {
82 $spotter_history_array = $Satellite->position($spotter_item['name'],time()-6000,time());
83 $spotter_history_array = array_reverse($spotter_history_array);
84 $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['name'].'","type": "history"},"geometry": {"type": "LineString","coordinates": [';
85 foreach ($spotter_history_array as $key => $spotter_history) {
86 if ((isset($previous_lon) && abs($previous_lon-$spotter_history['longitude']) > 180) ||
(isset($previous_lat) && abs($previous_lat-$spotter_history['latitude']) > 90)) {
89 $output_history .= '[';
90 $output_history .= $spotter_history['longitude'].', ';
91 $output_history .= $spotter_history['latitude'];
92 $output_history .= '],';
93 $previous_lon = $spotter_history['longitude'];
94 $previous_lat = $spotter_history['latitude'];
96 $output_history = substr($output_history,0,-1);
97 $output_history .= ']}},';
98 $output .= $output_history;
102 if (isset($output_data)) $output = substr($output,0,-1);