@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | $this->SI = new SpotterImport($this->db); |
| 17 | 17 | } |
| 18 | 18 | /** |
| 19 | - * Change IATA to ICAO value for ident |
|
| 20 | - * |
|
| 21 | - * @param String $ident ident |
|
| 22 | - * @return String the icao |
|
| 23 | - */ |
|
| 19 | + * Change IATA to ICAO value for ident |
|
| 20 | + * |
|
| 21 | + * @param String $ident ident |
|
| 22 | + * @return String the icao |
|
| 23 | + */ |
|
| 24 | 24 | public function ident2icao($ident) { |
| 25 | 25 | if (substr($ident,0,2) == 'AF') { |
| 26 | 26 | if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | - * Deletes all info in the live table |
|
| 40 | - * |
|
| 41 | - * @return String success or false |
|
| 42 | - * |
|
| 43 | - */ |
|
| 39 | + * Deletes all info in the live table |
|
| 40 | + * |
|
| 41 | + * @return String success or false |
|
| 42 | + * |
|
| 43 | + */ |
|
| 44 | 44 | public function deleteLiveAcarsData() |
| 45 | 45 | { |
| 46 | 46 | global $globalDBdriver; |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | - * Deletes all info in the archive table |
|
| 64 | - * |
|
| 65 | - * @return String success or false |
|
| 66 | - * |
|
| 67 | - */ |
|
| 63 | + * Deletes all info in the archive table |
|
| 64 | + * |
|
| 65 | + * @return String success or false |
|
| 66 | + * |
|
| 67 | + */ |
|
| 68 | 68 | public function deleteArchiveAcarsData() |
| 69 | 69 | { |
| 70 | 70 | global $globalACARSArchiveKeepMonths, $globalDBdriver; |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | - * Parse ACARS data |
|
| 89 | - * |
|
| 90 | - * @param String ACARS data in acarsdec data |
|
| 91 | - * |
|
| 92 | - */ |
|
| 88 | + * Parse ACARS data |
|
| 89 | + * |
|
| 90 | + * @param String ACARS data in acarsdec data |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | 93 | public function parse($data) { |
| 94 | 94 | global $globalDebug, $globalACARSArchive; |
| 95 | 95 | //$Image = new Image($this->db); |
@@ -666,11 +666,11 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | |
| 668 | 668 | /** |
| 669 | - * Add ACARS data |
|
| 670 | - * |
|
| 671 | - * @param String ACARS data in acarsdec data |
|
| 672 | - * |
|
| 673 | - */ |
|
| 669 | + * Add ACARS data |
|
| 670 | + * |
|
| 671 | + * @param String ACARS data in acarsdec data |
|
| 672 | + * |
|
| 673 | + */ |
|
| 674 | 674 | function add($data) { |
| 675 | 675 | global $globalDebug, $globalACARSArchive; |
| 676 | 676 | $Image = new Image($this->db); |
@@ -725,15 +725,15 @@ discard block |
||
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * Add Live ACARS data in DB |
|
| 729 | - * |
|
| 730 | - * @param String $ident ident |
|
| 731 | - * @param String $registration Registration of the aircraft |
|
| 732 | - * @param String $label Label of the ACARS message |
|
| 733 | - * @param String $block_id Block id of the ACARS message |
|
| 734 | - * @param String $msg_no Number of the ACARS message |
|
| 735 | - * @param String $message ACARS message |
|
| 736 | - */ |
|
| 728 | + * Add Live ACARS data in DB |
|
| 729 | + * |
|
| 730 | + * @param String $ident ident |
|
| 731 | + * @param String $registration Registration of the aircraft |
|
| 732 | + * @param String $label Label of the ACARS message |
|
| 733 | + * @param String $block_id Block id of the ACARS message |
|
| 734 | + * @param String $msg_no Number of the ACARS message |
|
| 735 | + * @param String $message ACARS message |
|
| 736 | + */ |
|
| 737 | 737 | public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 738 | 738 | global $globalDebug; |
| 739 | 739 | date_default_timezone_set('UTC'); |
@@ -771,15 +771,15 @@ discard block |
||
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | /** |
| 774 | - * Add Archive ACARS data in DB |
|
| 775 | - * |
|
| 776 | - * @param String $ident ident |
|
| 777 | - * @param String $registration Registration of the aircraft |
|
| 778 | - * @param String $label Label of the ACARS message |
|
| 779 | - * @param String $block_id Block id of the ACARS message |
|
| 780 | - * @param String $msg_no Number of the ACARS message |
|
| 781 | - * @param String $message ACARS message |
|
| 782 | - */ |
|
| 774 | + * Add Archive ACARS data in DB |
|
| 775 | + * |
|
| 776 | + * @param String $ident ident |
|
| 777 | + * @param String $registration Registration of the aircraft |
|
| 778 | + * @param String $label Label of the ACARS message |
|
| 779 | + * @param String $block_id Block id of the ACARS message |
|
| 780 | + * @param String $msg_no Number of the ACARS message |
|
| 781 | + * @param String $message ACARS message |
|
| 782 | + */ |
|
| 783 | 783 | public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
| 784 | 784 | global $globalDebug; |
| 785 | 785 | date_default_timezone_set('UTC'); |
@@ -813,11 +813,11 @@ discard block |
||
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | /** |
| 816 | - * Get Message title from label from DB |
|
| 817 | - * |
|
| 818 | - * @param String $label |
|
| 819 | - * @return String Return ACARS title |
|
| 820 | - */ |
|
| 816 | + * Get Message title from label from DB |
|
| 817 | + * |
|
| 818 | + * @param String $label |
|
| 819 | + * @return String Return ACARS title |
|
| 820 | + */ |
|
| 821 | 821 | public function getTitlefromLabel($label) { |
| 822 | 822 | $Connection = new Connection($this->db); |
| 823 | 823 | $this->db = $Connection->db; |
@@ -837,10 +837,10 @@ discard block |
||
| 837 | 837 | } |
| 838 | 838 | |
| 839 | 839 | /** |
| 840 | - * List all Message title & label from DB |
|
| 841 | - * |
|
| 842 | - * @return Array Return ACARS data in array |
|
| 843 | - */ |
|
| 840 | + * List all Message title & label from DB |
|
| 841 | + * |
|
| 842 | + * @return Array Return ACARS data in array |
|
| 843 | + */ |
|
| 844 | 844 | public function getAllTitleLabel() { |
| 845 | 845 | $query = "SELECT * FROM acars_label ORDER BY title"; |
| 846 | 846 | $query_values = array(); |
@@ -858,11 +858,11 @@ discard block |
||
| 858 | 858 | } |
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | - * Get Live ACARS data from DB |
|
| 862 | - * |
|
| 863 | - * @param String $ident |
|
| 864 | - * @return Array Return ACARS data in array |
|
| 865 | - */ |
|
| 861 | + * Get Live ACARS data from DB |
|
| 862 | + * |
|
| 863 | + * @param String $ident |
|
| 864 | + * @return Array Return ACARS data in array |
|
| 865 | + */ |
|
| 866 | 866 | public function getLiveAcarsData($ident) { |
| 867 | 867 | $query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC"; |
| 868 | 868 | $query_values = array(':ident' => $ident); |
@@ -880,10 +880,10 @@ discard block |
||
| 880 | 880 | } |
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | - * Get Latest ACARS data from DB |
|
| 884 | - * |
|
| 885 | - * @return Array Return ACARS data in array |
|
| 886 | - */ |
|
| 883 | + * Get Latest ACARS data from DB |
|
| 884 | + * |
|
| 885 | + * @return Array Return ACARS data in array |
|
| 886 | + */ |
|
| 887 | 887 | public function getLatestAcarsData($limit = '',$label = '') { |
| 888 | 888 | global $globalURL, $globalDBdriver; |
| 889 | 889 | $Image = new Image($this->db); |
@@ -980,10 +980,10 @@ discard block |
||
| 980 | 980 | } |
| 981 | 981 | |
| 982 | 982 | /** |
| 983 | - * Get Archive ACARS data from DB |
|
| 984 | - * |
|
| 985 | - * @return Array Return ACARS data in array |
|
| 986 | - */ |
|
| 983 | + * Get Archive ACARS data from DB |
|
| 984 | + * |
|
| 985 | + * @return Array Return ACARS data in array |
|
| 986 | + */ |
|
| 987 | 987 | public function getArchiveAcarsData($limit = '',$label = '') { |
| 988 | 988 | global $globalURL, $globalDBdriver; |
| 989 | 989 | $Image = new Image($this->db); |
@@ -1085,13 +1085,13 @@ discard block |
||
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | /** |
| 1088 | - * Add ModeS data to DB |
|
| 1089 | - * |
|
| 1090 | - * @param String $ident ident |
|
| 1091 | - * @param String $registration Registration of the aircraft |
|
| 1092 | - * @param String $icao |
|
| 1093 | - * @param String $ICAOTypeCode |
|
| 1094 | - */ |
|
| 1088 | + * Add ModeS data to DB |
|
| 1089 | + * |
|
| 1090 | + * @param String $ident ident |
|
| 1091 | + * @param String $registration Registration of the aircraft |
|
| 1092 | + * @param String $icao |
|
| 1093 | + * @param String $ICAOTypeCode |
|
| 1094 | + */ |
|
| 1095 | 1095 | public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
| 1096 | 1096 | global $globalDebug, $globalDBdriver; |
| 1097 | 1097 | $ident = trim($ident); |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Gets the images based on the aircraft registration |
|
| 16 | - * |
|
| 17 | - * @return Array the images list |
|
| 18 | - * |
|
| 19 | - */ |
|
| 15 | + * Gets the images based on the aircraft registration |
|
| 16 | + * |
|
| 17 | + * @return Array the images list |
|
| 18 | + * |
|
| 19 | + */ |
|
| 20 | 20 | public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 21 | 21 | { |
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | WHERE spotter_image.registration = :registration"; |
| 30 | 30 | $sth = $this->db->prepare($query); |
| 31 | 31 | $sth->execute(array(':registration' => $registration)); |
| 32 | - /* |
|
| 32 | + /* |
|
| 33 | 33 | $images_array = array(); |
| 34 | 34 | $temp_array = array(); |
| 35 | 35 | |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | - * Gets the image copyright based on the Exif data |
|
| 56 | - * |
|
| 57 | - * @return String image copyright |
|
| 58 | - * |
|
| 59 | - */ |
|
| 55 | + * Gets the image copyright based on the Exif data |
|
| 56 | + * |
|
| 57 | + * @return String image copyright |
|
| 58 | + * |
|
| 59 | + */ |
|
| 60 | 60 | public function getExifCopyright($url) { |
| 61 | 61 | $exif = exif_read_data($url); |
| 62 | 62 | $copyright = ''; |
@@ -71,11 +71,11 @@ discard block |
||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * Adds the images based on the aircraft registration |
|
| 75 | - * |
|
| 76 | - * @return String either success or error |
|
| 77 | - * |
|
| 78 | - */ |
|
| 74 | + * Adds the images based on the aircraft registration |
|
| 75 | + * |
|
| 76 | + * @return String either success or error |
|
| 77 | + * |
|
| 78 | + */ |
|
| 79 | 79 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 80 | 80 | { |
| 81 | 81 | global $globalDebug,$globalAircraftImageFetch; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * Gets the aircraft image |
|
| 108 | - * |
|
| 109 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 110 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 111 | - * |
|
| 112 | - */ |
|
| 107 | + * Gets the aircraft image |
|
| 108 | + * |
|
| 109 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 110 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 111 | + * |
|
| 112 | + */ |
|
| 113 | 113 | public function findAircraftImage($aircraft_registration, $aircraft_icao = '', $airline_icao = '') |
| 114 | 114 | { |
| 115 | 115 | global $globalAircraftImageSources, $globalIVAO; |
@@ -149,13 +149,13 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * Gets the aircraft image from Planespotters |
|
| 153 | - * |
|
| 154 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 155 | - * @param String $aircraft_name type of the aircraft |
|
| 156 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 157 | - * |
|
| 158 | - */ |
|
| 152 | + * Gets the aircraft image from Planespotters |
|
| 153 | + * |
|
| 154 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 155 | + * @param String $aircraft_name type of the aircraft |
|
| 156 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 157 | + * |
|
| 158 | + */ |
|
| 159 | 159 | public function fromPlanespotters($aircraft_registration, $aircraft_name='') { |
| 160 | 160 | $Common = new Common(); |
| 161 | 161 | // If aircraft registration is only number, also check with aircraft model |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * Gets the aircraft image from Deviantart |
|
| 186 | - * |
|
| 187 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 188 | - * @param String $aircraft_name type of the aircraft |
|
| 189 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 190 | - * |
|
| 191 | - */ |
|
| 185 | + * Gets the aircraft image from Deviantart |
|
| 186 | + * |
|
| 187 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 188 | + * @param String $aircraft_name type of the aircraft |
|
| 189 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 190 | + * |
|
| 191 | + */ |
|
| 192 | 192 | public function fromDeviantart($aircraft_registration, $aircraft_name='') { |
| 193 | 193 | $Common = new Common(); |
| 194 | 194 | // If aircraft registration is only number, also check with aircraft model |
@@ -216,13 +216,13 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Gets the aircraft image from JetPhotos |
|
| 220 | - * |
|
| 221 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 222 | - * @param String $aircraft_name type of the aircraft |
|
| 223 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 224 | - * |
|
| 225 | - */ |
|
| 219 | + * Gets the aircraft image from JetPhotos |
|
| 220 | + * |
|
| 221 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 222 | + * @param String $aircraft_name type of the aircraft |
|
| 223 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 224 | + * |
|
| 225 | + */ |
|
| 226 | 226 | public function fromJetPhotos($aircraft_registration, $aircraft_name='') { |
| 227 | 227 | $Common = new Common(); |
| 228 | 228 | $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | - * Gets the aircraft image from PlanePictures |
|
| 262 | - * |
|
| 263 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 264 | - * @param String $aircraft_name type of the aircraft |
|
| 265 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 266 | - * |
|
| 267 | - */ |
|
| 261 | + * Gets the aircraft image from PlanePictures |
|
| 262 | + * |
|
| 263 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 264 | + * @param String $aircraft_name type of the aircraft |
|
| 265 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 266 | + * |
|
| 267 | + */ |
|
| 268 | 268 | public function fromPlanePictures($aircraft_registration, $aircraft_name='') { |
| 269 | 269 | $Common = new Common(); |
| 270 | 270 | $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | - * Gets the aircraft image from Flickr |
|
| 296 | - * |
|
| 297 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 298 | - * @param String $aircraft_name type of the aircraft |
|
| 299 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 300 | - * |
|
| 301 | - */ |
|
| 295 | + * Gets the aircraft image from Flickr |
|
| 296 | + * |
|
| 297 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 298 | + * @param String $aircraft_name type of the aircraft |
|
| 299 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 300 | + * |
|
| 301 | + */ |
|
| 302 | 302 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 303 | 303 | $Common = new Common(); |
| 304 | 304 | if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
@@ -336,13 +336,13 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Gets the aircraft image from Bing |
|
| 340 | - * |
|
| 341 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 342 | - * @param String $aircraft_name type of the aircraft |
|
| 343 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 344 | - * |
|
| 345 | - */ |
|
| 339 | + * Gets the aircraft image from Bing |
|
| 340 | + * |
|
| 341 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 342 | + * @param String $aircraft_name type of the aircraft |
|
| 343 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 344 | + * |
|
| 345 | + */ |
|
| 346 | 346 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 347 | 347 | global $globalImageBingKey; |
| 348 | 348 | $Common = new Common(); |
@@ -368,13 +368,13 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | /** |
| 371 | - * Gets the aircraft image from airport-data |
|
| 372 | - * |
|
| 373 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 374 | - * @param String $aircraft_name type of the aircraft |
|
| 375 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 376 | - * |
|
| 377 | - */ |
|
| 371 | + * Gets the aircraft image from airport-data |
|
| 372 | + * |
|
| 373 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 374 | + * @param String $aircraft_name type of the aircraft |
|
| 375 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 376 | + * |
|
| 377 | + */ |
|
| 378 | 378 | public function fromAirportData($aircraft_registration,$aircraft_name='') { |
| 379 | 379 | $Common = new Common(); |
| 380 | 380 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
@@ -393,13 +393,13 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | - * Gets the aircraft image from WikiMedia |
|
| 397 | - * |
|
| 398 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 399 | - * @param String $aircraft_name type of the aircraft |
|
| 400 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 401 | - * |
|
| 402 | - */ |
|
| 396 | + * Gets the aircraft image from WikiMedia |
|
| 397 | + * |
|
| 398 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 399 | + * @param String $aircraft_name type of the aircraft |
|
| 400 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 401 | + * |
|
| 402 | + */ |
|
| 403 | 403 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 404 | 404 | $Common = new Common(); |
| 405 | 405 | if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
@@ -449,13 +449,13 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
| 452 | - * Gets the aircraft image from custom url |
|
| 453 | - * |
|
| 454 | - * @param String $aircraft_registration the registration of the aircraft |
|
| 455 | - * @param String $aircraft_name type of the aircraft |
|
| 456 | - * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 457 | - * |
|
| 458 | - */ |
|
| 452 | + * Gets the aircraft image from custom url |
|
| 453 | + * |
|
| 454 | + * @param String $aircraft_registration the registration of the aircraft |
|
| 455 | + * @param String $aircraft_name type of the aircraft |
|
| 456 | + * @return Array the aircraft thumbnail, orignal url and copyright |
|
| 457 | + * |
|
| 458 | + */ |
|
| 459 | 459 | public function fromCustomSource($aircraft_registration,$aircraft_name='') { |
| 460 | 460 | global $globalAircraftCustomSources; |
| 461 | 461 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
@@ -8,29 +8,29 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class Schedule { |
| 10 | 10 | protected $cookies = array(); |
| 11 | - public $db; |
|
| 11 | + public $db; |
|
| 12 | 12 | public function __construct($dbc = null) { |
| 13 | 13 | $Connection = new Connection($dbc); |
| 14 | 14 | $this->db = $Connection->db(); |
| 15 | - } |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Add schedule data to database |
|
| 19 | - * @param String $ident aircraft ident |
|
| 20 | - * @param String $departure_airport_icao departure airport icao |
|
| 21 | - * @param String $departure_airport_time departure airport time |
|
| 22 | - * @param String $arrival_airport_icao arrival airport icao |
|
| 23 | - * @param String $arrival_airport_time arrival airport time |
|
| 18 | + * Add schedule data to database |
|
| 19 | + * @param String $ident aircraft ident |
|
| 20 | + * @param String $departure_airport_icao departure airport icao |
|
| 21 | + * @param String $departure_airport_time departure airport time |
|
| 22 | + * @param String $arrival_airport_icao arrival airport icao |
|
| 23 | + * @param String $arrival_airport_time arrival airport time |
|
| 24 | 24 | / @param String $source source of data |
| 25 | - */ |
|
| 25 | + */ |
|
| 26 | 26 | |
| 27 | 27 | public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') { |
| 28 | 28 | date_default_timezone_set('UTC'); |
| 29 | 29 | $date = date("Y-m-d H:i:s",time()); |
| 30 | - //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 31 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 32 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 33 | - $query_values = array(':ident' => $ident); |
|
| 30 | + //if ($departure_airport_time == '' && $arrival_airport_time == '') exit; |
|
| 31 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident"; |
|
| 32 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident"; |
|
| 33 | + $query_values = array(':ident' => $ident); |
|
| 34 | 34 | try { |
| 35 | 35 | $sth = $this->db->prepare($query); |
| 36 | 36 | $sth->execute($query_values); |
@@ -39,18 +39,18 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | if ($sth->fetchColumn() > 0) { |
| 41 | 41 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 42 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 43 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 42 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 43 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 44 | 44 | } elseif ($arrival_airport_time == '') { |
| 45 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 46 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 45 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao"; |
|
| 46 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao); |
|
| 47 | 47 | } elseif ($departure_airport_time == '') { |
| 48 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 49 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 48 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 49 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 50 | 50 | } else { |
| 51 | - //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 52 | - $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 53 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 51 | + //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time"; |
|
| 52 | + $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time"; |
|
| 53 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time); |
|
| 54 | 54 | } |
| 55 | 55 | try { |
| 56 | 56 | $sth = $this->db->prepare($query); |
@@ -61,17 +61,17 @@ discard block |
||
| 61 | 61 | if ($sth->fetchColumn() == 0) { |
| 62 | 62 | //$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident'; |
| 63 | 63 | if ($departure_airport_time == '' && $arrival_airport_time == '') { |
| 64 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 65 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 64 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 65 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 66 | 66 | } elseif ($arrival_airport_time == '') { |
| 67 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 68 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 67 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 68 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source); |
|
| 69 | 69 | } elseif ($departure_airport_time == '') { |
| 70 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 71 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 70 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 71 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 72 | 72 | } else { |
| 73 | - $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 74 | - $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 73 | + $query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident'; |
|
| 74 | + $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source); |
|
| 75 | 75 | } |
| 76 | 76 | try { |
| 77 | 77 | $sth = $this->db->prepare($query); |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function getSchedule($ident) { |
| 107 | - $Translation = new Translation($this->db); |
|
| 108 | - $operator = $Translation->checkTranslation($ident,false); |
|
| 109 | - if ($ident != $operator) { |
|
| 110 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 111 | - $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 112 | - } else { |
|
| 113 | - $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1"; |
|
| 114 | - $query_values = array(':ident' => $ident); |
|
| 115 | - } |
|
| 107 | + $Translation = new Translation($this->db); |
|
| 108 | + $operator = $Translation->checkTranslation($ident,false); |
|
| 109 | + if ($ident != $operator) { |
|
| 110 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :operator OR CallSign = :ident LIMIT 1"; |
|
| 111 | + $query_values = array(':ident' => $ident,'operator' => $operator); |
|
| 112 | + } else { |
|
| 113 | + $query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE CallSign = :ident LIMIT 1"; |
|
| 114 | + $query_values = array(':ident' => $ident); |
|
| 115 | + } |
|
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
@@ -127,15 +127,15 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function checkSchedule($ident) { |
| 129 | 129 | global $globalDBdriver; |
| 130 | - //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 131 | - if ($globalDBdriver == 'mysql') { |
|
| 130 | + //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1"; |
|
| 131 | + if ($globalDBdriver == 'mysql') { |
|
| 132 | 132 | $query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1"; |
| 133 | 133 | } else { |
| 134 | 134 | $query = "SELECT COUNT(*) as nb FROM routes WHERE CallSign = :ident |
| 135 | 135 | AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL) |
| 136 | 136 | OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1"; |
| 137 | 137 | } |
| 138 | - $query_values = array(':ident' => $ident); |
|
| 138 | + $query_values = array(':ident' => $ident); |
|
| 139 | 139 | try { |
| 140 | 140 | $sth = $this->db->prepare($query); |
| 141 | 141 | $sth->execute($query_values); |
@@ -147,12 +147,12 @@ discard block |
||
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
| 150 | - * Get flight info from Air France |
|
| 151 | - * @param String $callsign The callsign |
|
| 152 | - * @param String $date date we want flight number info |
|
| 153 | - * @param String $carrier IATA code |
|
| 154 | - * @return Flight departure and arrival airports and time |
|
| 155 | - */ |
|
| 150 | + * Get flight info from Air France |
|
| 151 | + * @param String $callsign The callsign |
|
| 152 | + * @param String $date date we want flight number info |
|
| 153 | + * @param String $carrier IATA code |
|
| 154 | + * @return Flight departure and arrival airports and time |
|
| 155 | + */ |
|
| 156 | 156 | private function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') { |
| 157 | 157 | $Common = new Common(); |
| 158 | 158 | $check_date = new Datetime($date); |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | - * Get flight info from EasyJet |
|
| 192 | - * @param String $callsign The callsign |
|
| 193 | - * @param String $date date we want flight number info |
|
| 194 | - * @return Flight departure and arrival airports and time |
|
| 195 | - */ |
|
| 191 | + * Get flight info from EasyJet |
|
| 192 | + * @param String $callsign The callsign |
|
| 193 | + * @param String $date date we want flight number info |
|
| 194 | + * @return Flight departure and arrival airports and time |
|
| 195 | + */ |
|
| 196 | 196 | private function getEasyJet($callsign, $date = 'NOW') { |
| 197 | 197 | global $globalTimezone; |
| 198 | 198 | $Common = new Common(); |
@@ -216,10 +216,10 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
| 219 | - * Get flight info from Ryanair |
|
| 220 | - * @param String $callsign The callsign |
|
| 221 | - * @return Flight departure and arrival airports and time |
|
| 222 | - */ |
|
| 219 | + * Get flight info from Ryanair |
|
| 220 | + * @param String $callsign The callsign |
|
| 221 | + * @return Flight departure and arrival airports and time |
|
| 222 | + */ |
|
| 223 | 223 | private function getRyanair($callsign) { |
| 224 | 224 | $Common = new Common(); |
| 225 | 225 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -242,10 +242,10 @@ discard block |
||
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | - * Get flight info from Swiss |
|
| 246 | - * @param String $callsign The callsign |
|
| 247 | - * @return Flight departure and arrival airports and time |
|
| 248 | - */ |
|
| 245 | + * Get flight info from Swiss |
|
| 246 | + * @param String $callsign The callsign |
|
| 247 | + * @return Flight departure and arrival airports and time |
|
| 248 | + */ |
|
| 249 | 249 | private function getSwiss($callsign) { |
| 250 | 250 | $Common = new Common(); |
| 251 | 251 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * Get flight info from British Airways API |
|
| 278 | - * @param String $callsign The callsign |
|
| 279 | - * @param String $date date we want flight number info |
|
| 280 | - * @return Flight departure and arrival airports and time |
|
| 281 | - */ |
|
| 277 | + * Get flight info from British Airways API |
|
| 278 | + * @param String $callsign The callsign |
|
| 279 | + * @param String $date date we want flight number info |
|
| 280 | + * @return Flight departure and arrival airports and time |
|
| 281 | + */ |
|
| 282 | 282 | public function getBritishAirways($callsign, $date = 'NOW') { |
| 283 | 283 | global $globalBritishAirwaysKey; |
| 284 | 284 | $Common = new Common(); |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Get flight info from Lutfhansa API |
|
| 306 | - * @param String $callsign The callsign |
|
| 307 | - * @param String $date date we want flight number info |
|
| 308 | - * @return Flight departure and arrival airports and time |
|
| 309 | - */ |
|
| 305 | + * Get flight info from Lutfhansa API |
|
| 306 | + * @param String $callsign The callsign |
|
| 307 | + * @param String $date date we want flight number info |
|
| 308 | + * @return Flight departure and arrival airports and time |
|
| 309 | + */ |
|
| 310 | 310 | public function getLufthansa($callsign, $date = 'NOW') { |
| 311 | 311 | global $globalLufthansaKey; |
| 312 | 312 | $Common = new Common(); |
@@ -336,11 +336,11 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
| 339 | - * Get flight info from Transavia API |
|
| 340 | - * @param String $callsign The callsign |
|
| 341 | - * @param String $date date we want flight number info |
|
| 342 | - * @return Flight departure and arrival airports and time |
|
| 343 | - */ |
|
| 339 | + * Get flight info from Transavia API |
|
| 340 | + * @param String $callsign The callsign |
|
| 341 | + * @param String $date date we want flight number info |
|
| 342 | + * @return Flight departure and arrival airports and time |
|
| 343 | + */ |
|
| 344 | 344 | public function getTransavia($callsign, $date = 'NOW') { |
| 345 | 345 | global $globalTransaviaKey; |
| 346 | 346 | $Common = new Common(); |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | /** |
| 369 | - * Get flight info from Tunisair |
|
| 370 | - * @param String $callsign The callsign |
|
| 371 | - * @return Flight departure and arrival airports and time |
|
| 372 | - */ |
|
| 369 | + * Get flight info from Tunisair |
|
| 370 | + * @param String $callsign The callsign |
|
| 371 | + * @return Flight departure and arrival airports and time |
|
| 372 | + */ |
|
| 373 | 373 | public function getTunisair($callsign) { |
| 374 | 374 | $Common = new Common(); |
| 375 | 375 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -386,10 +386,10 @@ discard block |
||
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
| 389 | - * Get flight info from Vueling |
|
| 390 | - * @param String $callsign The callsign |
|
| 391 | - * @return Flight departure and arrival airports and time |
|
| 392 | - */ |
|
| 389 | + * Get flight info from Vueling |
|
| 390 | + * @param String $callsign The callsign |
|
| 391 | + * @return Flight departure and arrival airports and time |
|
| 392 | + */ |
|
| 393 | 393 | public function getVueling($callsign,$date = 'NOW') { |
| 394 | 394 | $Common = new Common(); |
| 395 | 395 | $check_date = new Datetime($date); |
@@ -411,11 +411,11 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | |
| 413 | 413 | /** |
| 414 | - * Get flight info from Iberia |
|
| 415 | - * @param String $callsign The callsign |
|
| 416 | - * @param String $date date we want flight number info |
|
| 417 | - * @return Flight departure and arrival airports and time |
|
| 418 | - */ |
|
| 414 | + * Get flight info from Iberia |
|
| 415 | + * @param String $callsign The callsign |
|
| 416 | + * @param String $date date we want flight number info |
|
| 417 | + * @return Flight departure and arrival airports and time |
|
| 418 | + */ |
|
| 419 | 419 | public function getIberia($callsign, $date = 'NOW') { |
| 420 | 420 | $Common = new Common(); |
| 421 | 421 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -445,11 +445,11 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | /** |
| 448 | - * Get flight info from Star Alliance |
|
| 449 | - * @param String $callsign The callsign |
|
| 450 | - * @param String $date date we want flight number info |
|
| 451 | - * @return Flight departure and arrival airports and time |
|
| 452 | - */ |
|
| 448 | + * Get flight info from Star Alliance |
|
| 449 | + * @param String $callsign The callsign |
|
| 450 | + * @param String $date date we want flight number info |
|
| 451 | + * @return Flight departure and arrival airports and time |
|
| 452 | + */ |
|
| 453 | 453 | |
| 454 | 454 | private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') { |
| 455 | 455 | $Common = new Common(); |
@@ -481,11 +481,11 @@ discard block |
||
| 481 | 481 | |
| 482 | 482 | |
| 483 | 483 | /** |
| 484 | - * Get flight info from Alitalia |
|
| 485 | - * @param String $callsign The callsign |
|
| 486 | - * @param String $date date we want flight number info |
|
| 487 | - * @return Flight departure and arrival airports and time |
|
| 488 | - */ |
|
| 484 | + * Get flight info from Alitalia |
|
| 485 | + * @param String $callsign The callsign |
|
| 486 | + * @param String $date date we want flight number info |
|
| 487 | + * @return Flight departure and arrival airports and time |
|
| 488 | + */ |
|
| 489 | 489 | private function getAlitalia($callsign, $date = 'NOW') { |
| 490 | 490 | $Common = new Common(); |
| 491 | 491 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -504,11 +504,11 @@ discard block |
||
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | /** |
| 507 | - * Get flight info from Brussels airlines |
|
| 508 | - * @param String $callsign The callsign |
|
| 509 | - * @param String $date date we want flight number info |
|
| 510 | - * @return Flight departure and arrival airports and time |
|
| 511 | - */ |
|
| 507 | + * Get flight info from Brussels airlines |
|
| 508 | + * @param String $callsign The callsign |
|
| 509 | + * @param String $date date we want flight number info |
|
| 510 | + * @return Flight departure and arrival airports and time |
|
| 511 | + */ |
|
| 512 | 512 | private function getBrussels($callsign, $date = 'NOW') { |
| 513 | 513 | $Common = new Common(); |
| 514 | 514 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -518,24 +518,24 @@ discard block |
||
| 518 | 518 | if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
| 519 | 519 | $data = $Common->getData($url); |
| 520 | 520 | if ($data != '') { |
| 521 | - //echo $data; |
|
| 522 | - $parsed_json = json_decode($data); |
|
| 523 | - if (isset($parsed_json[0]->FromAirportCode)) { |
|
| 521 | + //echo $data; |
|
| 522 | + $parsed_json = json_decode($data); |
|
| 523 | + if (isset($parsed_json[0]->FromAirportCode)) { |
|
| 524 | 524 | $DepartureAirportIata = $parsed_json[0]->FromAirportCode; |
| 525 | 525 | $ArrivalAirportIata = $parsed_json[0]->ToAirportCode; |
| 526 | 526 | $departureTime = date('H:i',strtotime($parsed_json[0]->ScheduledDepatureDate)); |
| 527 | 527 | $arrivalTime = date('H:i',strtotime($parsed_json[0]->ScheduledArrivalDate)); |
| 528 | 528 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels'); |
| 529 | - } |
|
| 529 | + } |
|
| 530 | 530 | } |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
| 534 | - * Get flight info from FlightRadar24 |
|
| 535 | - * @param String $callsign The callsign |
|
| 536 | - * @param String $date date we want flight number info |
|
| 537 | - * @return Flight departure and arrival airports and time |
|
| 538 | - */ |
|
| 534 | + * Get flight info from FlightRadar24 |
|
| 535 | + * @param String $callsign The callsign |
|
| 536 | + * @param String $date date we want flight number info |
|
| 537 | + * @return Flight departure and arrival airports and time |
|
| 538 | + */ |
|
| 539 | 539 | /* |
| 540 | 540 | public function getFlightRadar24($callsign, $date = 'NOW') { |
| 541 | 541 | $Common = new Common(); |
@@ -564,11 +564,11 @@ discard block |
||
| 564 | 564 | } |
| 565 | 565 | */ |
| 566 | 566 | /** |
| 567 | - * Get flight info from Lufthansa |
|
| 568 | - * @param String $callsign The callsign |
|
| 569 | - * @param String $date date we want flight number info |
|
| 570 | - * @return Flight departure and arrival airports and time |
|
| 571 | - */ |
|
| 567 | + * Get flight info from Lufthansa |
|
| 568 | + * @param String $callsign The callsign |
|
| 569 | + * @param String $date date we want flight number info |
|
| 570 | + * @return Flight departure and arrival airports and time |
|
| 571 | + */ |
|
| 572 | 572 | |
| 573 | 573 | /* private function getLufthansa($callsign, $date = 'NOW') { |
| 574 | 574 | $Common = new Common(); |
@@ -596,10 +596,10 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | */ |
| 598 | 598 | /** |
| 599 | - * Get flight info from flytap |
|
| 600 | - * @param String $callsign The callsign |
|
| 601 | - * @return Flight departure and arrival airports and time |
|
| 602 | - */ |
|
| 599 | + * Get flight info from flytap |
|
| 600 | + * @param String $callsign The callsign |
|
| 601 | + * @return Flight departure and arrival airports and time |
|
| 602 | + */ |
|
| 603 | 603 | private function getFlyTap($callsign) { |
| 604 | 604 | $Common = new Common(); |
| 605 | 605 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -622,10 +622,10 @@ discard block |
||
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | /** |
| 625 | - * Get flight info from flightmapper |
|
| 626 | - * @param String $callsign The callsign |
|
| 627 | - * @return Flight departure and arrival airports and time |
|
| 628 | - */ |
|
| 625 | + * Get flight info from flightmapper |
|
| 626 | + * @param String $callsign The callsign |
|
| 627 | + * @return Flight departure and arrival airports and time |
|
| 628 | + */ |
|
| 629 | 629 | public function getFlightMapper($callsign) { |
| 630 | 630 | $Common = new Common(); |
| 631 | 631 | $airline_icao = ''; |
@@ -653,11 +653,11 @@ discard block |
||
| 653 | 653 | $aarr = ''; |
| 654 | 654 | $n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr); |
| 655 | 655 | if ($n == 7) { |
| 656 | - $departureTime = $dhour; |
|
| 657 | - $arrivalTime = $ahour; |
|
| 658 | - $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 659 | - $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 660 | - return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 656 | + $departureTime = $dhour; |
|
| 657 | + $arrivalTime = $ahour; |
|
| 658 | + $DepartureAirportIata = str_replace(array('(',')'),'',$darr); |
|
| 659 | + $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr); |
|
| 660 | + return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper'); |
|
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | } |
@@ -665,10 +665,10 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | /** |
| 668 | - * Get flight info from flightaware |
|
| 669 | - * @param String $callsign The callsign |
|
| 670 | - * @return Flight departure and arrival airports and time |
|
| 671 | - */ |
|
| 668 | + * Get flight info from flightaware |
|
| 669 | + * @param String $callsign The callsign |
|
| 670 | + * @return Flight departure and arrival airports and time |
|
| 671 | + */ |
|
| 672 | 672 | public function getFlightAware($callsign) { |
| 673 | 673 | $Common = new Common(); |
| 674 | 674 | /* |
@@ -701,10 +701,10 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
| 704 | - * Get flight info from CostToTravel |
|
| 705 | - * @param String $callsign The callsign |
|
| 706 | - * @return Flight departure and arrival airports and time |
|
| 707 | - */ |
|
| 704 | + * Get flight info from CostToTravel |
|
| 705 | + * @param String $callsign The callsign |
|
| 706 | + * @return Flight departure and arrival airports and time |
|
| 707 | + */ |
|
| 708 | 708 | public function getCostToTravel($callsign) { |
| 709 | 709 | $Common = new Common(); |
| 710 | 710 | $url= "http://www.costtotravel.com/flight-number/".$callsign; |
@@ -726,11 +726,11 @@ discard block |
||
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | /** |
| 729 | - * Get flight info from Air Canada |
|
| 730 | - * @param String $callsign The callsign |
|
| 731 | - * @param String $date date we want flight number info |
|
| 732 | - * @return Flight departure and arrival airports and time |
|
| 733 | - */ |
|
| 729 | + * Get flight info from Air Canada |
|
| 730 | + * @param String $callsign The callsign |
|
| 731 | + * @param String $date date we want flight number info |
|
| 732 | + * @return Flight departure and arrival airports and time |
|
| 733 | + */ |
|
| 734 | 734 | private function getAirCanada($callsign,$date = 'NOW') { |
| 735 | 735 | $Common = new Common(); |
| 736 | 736 | date_default_timezone_set('UTC'); |
@@ -754,11 +754,11 @@ discard block |
||
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | /** |
| 757 | - * Get flight info from Vietnam Airlines |
|
| 758 | - * @param String $callsign The callsign |
|
| 759 | - * @param String $date date we want flight number info |
|
| 760 | - * @return Flight departure and arrival airports and time |
|
| 761 | - */ |
|
| 757 | + * Get flight info from Vietnam Airlines |
|
| 758 | + * @param String $callsign The callsign |
|
| 759 | + * @param String $date date we want flight number info |
|
| 760 | + * @return Flight departure and arrival airports and time |
|
| 761 | + */ |
|
| 762 | 762 | private function getVietnamAirlines($callsign, $date = 'NOW') { |
| 763 | 763 | $Common = new Common(); |
| 764 | 764 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
@@ -780,12 +780,12 @@ discard block |
||
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /** |
| 783 | - * Get flight info from Air Berlin |
|
| 784 | - * @param String $callsign The callsign |
|
| 785 | - * @param String $date date we want flight number info |
|
| 786 | - * @param String $carrier airline code |
|
| 787 | - * @return Flight departure and arrival airports and time |
|
| 788 | - */ |
|
| 783 | + * Get flight info from Air Berlin |
|
| 784 | + * @param String $callsign The callsign |
|
| 785 | + * @param String $date date we want flight number info |
|
| 786 | + * @param String $carrier airline code |
|
| 787 | + * @return Flight departure and arrival airports and time |
|
| 788 | + */ |
|
| 789 | 789 | private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') { |
| 790 | 790 | $Common = new Common(); |
| 791 | 791 | date_default_timezone_set('UTC'); |
@@ -814,11 +814,11 @@ discard block |
||
| 814 | 814 | $table = $Common->table2array($data); |
| 815 | 815 | $flight = $table; |
| 816 | 816 | if (isset($flight[5][4])) { |
| 817 | - $arrivalTime = $flight[5][4]; |
|
| 818 | - $arrivalAirport = $flight[5][3]; |
|
| 817 | + $arrivalTime = $flight[5][4]; |
|
| 818 | + $arrivalAirport = $flight[5][3]; |
|
| 819 | 819 | } else { |
| 820 | - $arrivalTime = ''; |
|
| 821 | - $arrivalAirport = ''; |
|
| 820 | + $arrivalTime = ''; |
|
| 821 | + $arrivalAirport = ''; |
|
| 822 | 822 | } |
| 823 | 823 | } else return array(); |
| 824 | 824 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | 1088 | } |
| 1089 | - return array(); |
|
| 1089 | + return array(); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | } |
| 1092 | 1092 | |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class SBS { |
| 3 | - static $latlon = array(); |
|
| 3 | + static $latlon = array(); |
|
| 4 | 4 | |
| 5 | - public function parse($buffer) { |
|
| 5 | + public function parse($buffer) { |
|
| 6 | 6 | // Not yet finished, no CRC checks |
| 7 | 7 | //echo $buffer."\n"; |
| 8 | 8 | $data = array(); |
@@ -13,47 +13,47 @@ discard block |
||
| 13 | 13 | $bin = gmp_strval( gmp_init($hex,16), 2); |
| 14 | 14 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
| 15 | 15 | if (strlen($hex) == 28) { |
| 16 | - $df = intval(substr($bin,0,5),2); |
|
| 17 | - //$ca = intval(substr($bin,5,3),2); |
|
| 18 | - // Only support DF17 for now |
|
| 19 | - //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
|
| 20 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
| 16 | + $df = intval(substr($bin,0,5),2); |
|
| 17 | + //$ca = intval(substr($bin,5,3),2); |
|
| 18 | + // Only support DF17 for now |
|
| 19 | + //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
|
| 20 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
| 21 | 21 | $icao = substr($hex,2,6); |
| 22 | 22 | $data['hex'] = $icao; |
| 23 | 23 | $tc = intval(substr($bin,32,5),2); |
| 24 | 24 | if ($tc >= 1 && $tc <= 4) { |
| 25 | - //callsign |
|
| 26 | - $csbin = substr($bin,40,56); |
|
| 27 | - $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
|
| 28 | - $cs = ''; |
|
| 29 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
| 30 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
| 31 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
| 32 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
| 33 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
| 34 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
| 35 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
| 36 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
| 37 | - $cs = str_replace('_','',$cs); |
|
| 38 | - $cs = str_replace('#','',$cs); |
|
| 39 | - $callsign = $cs; |
|
| 40 | - $data['ident'] = $callsign; |
|
| 25 | + //callsign |
|
| 26 | + $csbin = substr($bin,40,56); |
|
| 27 | + $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
|
| 28 | + $cs = ''; |
|
| 29 | + $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
| 30 | + $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
| 31 | + $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
| 32 | + $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
| 33 | + $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
| 34 | + $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
| 35 | + $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
| 36 | + $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
| 37 | + $cs = str_replace('_','',$cs); |
|
| 38 | + $cs = str_replace('#','',$cs); |
|
| 39 | + $callsign = $cs; |
|
| 40 | + $data['ident'] = $callsign; |
|
| 41 | 41 | } elseif ($tc >= 9 && $tc <= 18) { |
| 42 | - // Check Q-bit |
|
| 43 | - $q = substr($bin,47,1); |
|
| 44 | - if ($q) { |
|
| 42 | + // Check Q-bit |
|
| 43 | + $q = substr($bin,47,1); |
|
| 44 | + if ($q) { |
|
| 45 | 45 | $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
| 46 | 46 | $alt = $n*25-1000; |
| 47 | 47 | $data['altitude'] = $alt; |
| 48 | - } |
|
| 49 | - // Check odd/even flag |
|
| 50 | - $oe = substr($bin,53,1); |
|
| 51 | - //if ($oe) => odd else even |
|
| 52 | - // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
|
| 53 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
| 54 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
| 55 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 56 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 48 | + } |
|
| 49 | + // Check odd/even flag |
|
| 50 | + $oe = substr($bin,53,1); |
|
| 51 | + //if ($oe) => odd else even |
|
| 52 | + // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
|
| 53 | + $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
| 54 | + $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
| 55 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
| 56 | + elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
| 57 | 57 | $cprlat_odd = $cprlat; |
| 58 | 58 | $cprlon_odd = $cprlon; |
| 59 | 59 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -66,53 +66,53 @@ discard block |
||
| 66 | 66 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
| 67 | 67 | // check latitude zone |
| 68 | 68 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
| 69 | - if ($this::$latlon[$icao]['created'] > time()) { |
|
| 69 | + if ($this::$latlon[$icao]['created'] > time()) { |
|
| 70 | 70 | $ni = $this->cprN($lat_even,0); |
| 71 | 71 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
| 72 | 72 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
| 73 | 73 | $lat = $lat_even; |
| 74 | 74 | if ($lon > 180) $lon = $lon -360; |
| 75 | 75 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 76 | - //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
|
| 77 | - $data['latitude'] = $lat; |
|
| 78 | - $data['longitude'] = $lon; |
|
| 76 | + //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
|
| 77 | + $data['latitude'] = $lat; |
|
| 78 | + $data['longitude'] = $lon; |
|
| 79 | 79 | } |
| 80 | - } else { |
|
| 80 | + } else { |
|
| 81 | 81 | $ni = $this->cprN($lat_odd,1); |
| 82 | 82 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
| 83 | 83 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
| 84 | 84 | $lat = $lat_odd; |
| 85 | 85 | if ($lon > 180) $lon = $lon -360; |
| 86 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
| 87 | - //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
|
| 88 | - $data['latitude'] = $lat; |
|
| 89 | - $data['longitude'] = $lon; |
|
| 87 | + //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
|
| 88 | + $data['latitude'] = $lat; |
|
| 89 | + $data['longitude'] = $lon; |
|
| 90 | + } |
|
| 90 | 91 | } |
| 91 | - } |
|
| 92 | 92 | } else echo "Not cprNL"; |
| 93 | 93 | unset($this::$latlon[$icao]); |
| 94 | - } |
|
| 94 | + } |
|
| 95 | 95 | } elseif ($tc == 19) { |
| 96 | - // speed & heading |
|
| 97 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
| 98 | - $v_ew = intval(substr($bin,46,10),2); |
|
| 99 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
| 100 | - $v_ns = intval(substr($bin,57,10),2); |
|
| 101 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
| 102 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
| 103 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
| 104 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
| 105 | - if ($heading <0) $heading = $heading+360; |
|
| 106 | - $data['speed'] = $speed; |
|
| 107 | - $data['heading'] = $heading; |
|
| 96 | + // speed & heading |
|
| 97 | + $v_ew_dir = intval(substr($bin,45,1)); |
|
| 98 | + $v_ew = intval(substr($bin,46,10),2); |
|
| 99 | + $v_ns_dir = intval(substr($bin,56,1)); |
|
| 100 | + $v_ns = intval(substr($bin,57,10),2); |
|
| 101 | + if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
| 102 | + if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
| 103 | + $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
| 104 | + $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
| 105 | + if ($heading <0) $heading = $heading+360; |
|
| 106 | + $data['speed'] = $speed; |
|
| 107 | + $data['heading'] = $heading; |
|
| 108 | + } |
|
| 108 | 109 | } |
| 109 | - } |
|
| 110 | - if (isset($data)) { |
|
| 110 | + if (isset($data)) { |
|
| 111 | 111 | //print_r($data); |
| 112 | 112 | return $data; |
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | public function cprNL($lat) { |
@@ -177,16 +177,16 @@ discard block |
||
| 177 | 177 | if ($lat < 86.53536998) return 3; |
| 178 | 178 | if ($lat < 87.00000000) return 2; |
| 179 | 179 | return 1; |
| 180 | - } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - public function cprN($lat,$isodd) { |
|
| 182 | + public function cprN($lat,$isodd) { |
|
| 183 | 183 | $nl = $this->cprNL($lat) - $isodd; |
| 184 | 184 | if ($nl > 1) return $nl; |
| 185 | 185 | else return 1; |
| 186 | - } |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | - function parityCheck($msg, $bin) { |
|
| 189 | + function parityCheck($msg, $bin) { |
|
| 190 | 190 | $modes_checksum_table = array( |
| 191 | 191 | 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178, |
| 192 | 192 | 0x2c38bc, 0x161c5e, 0x0b0e2f, 0xfa7d13, 0x82c48d, 0xbe9842, 0x5f4c21, 0xd05c14, |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | $checksum = intval(substr($msg,22,6),16); |
| 209 | 209 | |
| 210 | 210 | for ($j = 0; $j < strlen($bin); $j++) { |
| 211 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 211 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
| 212 | 212 | } |
| 213 | 213 | if ($crc == $checksum) return true; |
| 214 | 214 | else { |
| 215 | - //echo "**** CRC ERROR ****\n"; |
|
| 216 | - return false; |
|
| 215 | + //echo "**** CRC ERROR ****\n"; |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 217 | 218 | } |
| 218 | - } |
|
| 219 | 219 | } |
| 220 | 220 | ?> |
@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | //protected $cookies = array(); |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * Get data from form result |
|
| 10 | - * @param String $url form URL |
|
| 11 | - * @param String $type type of submit form method (get or post) |
|
| 12 | - * @param String|Array $data values form post method |
|
| 13 | - * @param Array $headers header to submit with the form |
|
| 14 | - * @return String the result |
|
| 15 | - */ |
|
| 9 | + * Get data from form result |
|
| 10 | + * @param String $url form URL |
|
| 11 | + * @param String $type type of submit form method (get or post) |
|
| 12 | + * @param String|Array $data values form post method |
|
| 13 | + * @param Array $headers header to submit with the form |
|
| 14 | + * @return String the result |
|
| 15 | + */ |
|
| 16 | 16 | public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
| 17 | 17 | $ch = curl_init(); |
| 18 | 18 | curl_setopt($ch, CURLOPT_URL, $url); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | - return $result; |
|
| 70 | + return $result; |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * Convert a HTML table to an array |
|
| 84 | - * @param String $data HTML page |
|
| 85 | - * @return Array array of the tables in HTML page |
|
| 86 | - */ |
|
| 83 | + * Convert a HTML table to an array |
|
| 84 | + * @param String $data HTML page |
|
| 85 | + * @return Array array of the tables in HTML page |
|
| 86 | + */ |
|
| 87 | 87 | public function table2array($data) { |
| 88 | 88 | if (!is_string($data)) return array(); |
| 89 | 89 | if ($data == '') return array(); |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Convert <p> part of a HTML page to an array |
|
| 121 | - * @param String $data HTML page |
|
| 122 | - * @return Array array of the <p> in HTML page |
|
| 123 | - */ |
|
| 120 | + * Convert <p> part of a HTML page to an array |
|
| 121 | + * @param String $data HTML page |
|
| 122 | + * @return Array array of the <p> in HTML page |
|
| 123 | + */ |
|
| 124 | 124 | public function text2array($data) { |
| 125 | 125 | $html = str_get_html($data); |
| 126 | 126 | if ($html === false) return array(); |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
| 138 | - * Give distance between 2 coordonnates |
|
| 139 | - * @param Float $lat latitude of first point |
|
| 140 | - * @param Float $lon longitude of first point |
|
| 141 | - * @param Float $latc latitude of second point |
|
| 142 | - * @param Float $lonc longitude of second point |
|
| 143 | - * @param String $unit km else no unit used |
|
| 144 | - * @return Float Distance in $unit |
|
| 145 | - */ |
|
| 138 | + * Give distance between 2 coordonnates |
|
| 139 | + * @param Float $lat latitude of first point |
|
| 140 | + * @param Float $lon longitude of first point |
|
| 141 | + * @param Float $latc latitude of second point |
|
| 142 | + * @param Float $lonc longitude of second point |
|
| 143 | + * @param String $unit km else no unit used |
|
| 144 | + * @return Float Distance in $unit |
|
| 145 | + */ |
|
| 146 | 146 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 147 | 147 | if ($lat == $latc && $lon == $lonc) return 0; |
| 148 | 148 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | - * Check is distance realistic |
|
| 164 | - * @param int $timeDifference the time between the reception of both messages |
|
| 165 | - * @param float $distance distance covered |
|
| 166 | - * @return whether distance is realistic |
|
| 167 | - */ |
|
| 163 | + * Check is distance realistic |
|
| 164 | + * @param int $timeDifference the time between the reception of both messages |
|
| 165 | + * @param float $distance distance covered |
|
| 166 | + * @return whether distance is realistic |
|
| 167 | + */ |
|
| 168 | 168 | public function withinThreshold ($timeDifference, $distance) { |
| 169 | 169 | $x = abs($timeDifference); |
| 170 | 170 | $d = abs($distance); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function isInteger($input){ |
| 185 | - return(ctype_digit(strval($input))); |
|
| 185 | + return(ctype_digit(strval($input))); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | - * Copy folder contents |
|
| 202 | - * @param string $source Source path |
|
| 203 | - * @param string $dest Destination path |
|
| 204 | - * @return bool Returns true on success, false on failure |
|
| 205 | - */ |
|
| 201 | + * Copy folder contents |
|
| 202 | + * @param string $source Source path |
|
| 203 | + * @param string $dest Destination path |
|
| 204 | + * @return bool Returns true on success, false on failure |
|
| 205 | + */ |
|
| 206 | 206 | public function xcopy($source, $dest) |
| 207 | 207 | { |
| 208 | 208 | $files = glob($source.'*.*'); |
@@ -214,20 +214,20 @@ discard block |
||
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | - * Check if an url exist |
|
| 218 | - * @param String $url url to check |
|
| 219 | - * @return bool Return true on succes false on failure |
|
| 220 | - */ |
|
| 217 | + * Check if an url exist |
|
| 218 | + * @param String $url url to check |
|
| 219 | + * @return bool Return true on succes false on failure |
|
| 220 | + */ |
|
| 221 | 221 | public function urlexist($url){ |
| 222 | 222 | $headers=get_headers($url); |
| 223 | 223 | return stripos($headers[0],"200 OK")?true:false; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | - * Convert hexa to string |
|
| 228 | - * @param String $hex data in hexa |
|
| 229 | - * @return String Return result |
|
| 230 | - */ |
|
| 227 | + * Convert hexa to string |
|
| 228 | + * @param String $hex data in hexa |
|
| 229 | + * @return String Return result |
|
| 230 | + */ |
|
| 231 | 231 | public function hex2str($hex) { |
| 232 | 232 | $str = ''; |
| 233 | 233 | $hexln = strlen($hex); |
@@ -275,9 +275,9 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | - * Returns list of available locales |
|
| 279 | - * |
|
| 280 | - * @return array |
|
| 278 | + * Returns list of available locales |
|
| 279 | + * |
|
| 280 | + * @return array |
|
| 281 | 281 | */ |
| 282 | 282 | public function listLocaleDir() |
| 283 | 283 | { |
@@ -52,824 +52,824 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | class Predict |
| 54 | 54 | { |
| 55 | - const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | - const pi = 3.1415926535898; /* Pi */ |
|
| 57 | - const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | - const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | - const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | - const e6a = 1.0E-6; |
|
| 61 | - const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | - const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | - const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | - const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | - const xke = 7.43669161E-2; |
|
| 66 | - const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | - const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | - const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | - const ae = 1.0; |
|
| 70 | - const ck2 = 5.413079E-4; |
|
| 71 | - const ck4 = 6.209887E-7; |
|
| 72 | - const __f = 3.352779E-3; |
|
| 73 | - const ge = 3.986008E5; |
|
| 74 | - const __s__ = 1.012229; |
|
| 75 | - const qoms2t = 1.880279E-09; |
|
| 76 | - const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | - const omega_E = 1.0027379; |
|
| 78 | - const omega_ER = 6.3003879; |
|
| 79 | - const zns = 1.19459E-5; |
|
| 80 | - const c1ss = 2.9864797E-6; |
|
| 81 | - const zes = 1.675E-2; |
|
| 82 | - const znl = 1.5835218E-4; |
|
| 83 | - const c1l = 4.7968065E-7; |
|
| 84 | - const zel = 5.490E-2; |
|
| 85 | - const zcosis = 9.1744867E-1; |
|
| 86 | - const zsinis = 3.9785416E-1; |
|
| 87 | - const zsings = -9.8088458E-1; |
|
| 88 | - const zcosgs = 1.945905E-1; |
|
| 89 | - const zcoshs = 1; |
|
| 90 | - const zsinhs = 0; |
|
| 91 | - const q22 = 1.7891679E-6; |
|
| 92 | - const q31 = 2.1460748E-6; |
|
| 93 | - const q33 = 2.2123015E-7; |
|
| 94 | - const g22 = 5.7686396; |
|
| 95 | - const g32 = 9.5240898E-1; |
|
| 96 | - const g44 = 1.8014998; |
|
| 97 | - const g52 = 1.0508330; |
|
| 98 | - const g54 = 4.4108898; |
|
| 99 | - const root22 = 1.7891679E-6; |
|
| 100 | - const root32 = 3.7393792E-7; |
|
| 101 | - const root44 = 7.3636953E-9; |
|
| 102 | - const root52 = 1.1428639E-7; |
|
| 103 | - const root54 = 2.1765803E-9; |
|
| 104 | - const thdt = 4.3752691E-3; |
|
| 105 | - const rho = 1.5696615E-1; |
|
| 106 | - const mfactor = 7.292115E-5; |
|
| 107 | - const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | - const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 109 | - |
|
| 110 | - /* visibility constants */ |
|
| 111 | - const SAT_VIS_NONE = 0; |
|
| 112 | - const SAT_VIS_VISIBLE = 1; |
|
| 113 | - const SAT_VIS_DAYLIGHT = 2; |
|
| 114 | - const SAT_VIS_ECLIPSED = 3; |
|
| 115 | - |
|
| 116 | - /* preferences */ |
|
| 117 | - public $minEle = 10; // Minimum elevation |
|
| 118 | - public $timeRes = 10; // Pass details: time resolution |
|
| 119 | - public $numEntries = 20; // Pass details: number of entries |
|
| 120 | - public $threshold = -6; // Twilight threshold |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Predict the next pass. |
|
| 124 | - * |
|
| 125 | - * This function simply wraps the get_pass function using the current time |
|
| 126 | - * as parameter. |
|
| 127 | - * |
|
| 128 | - * Note: the data in sat will be corrupt (future) and must be refreshed |
|
| 129 | - * by the caller, if the caller will need it later on (eg. if the caller |
|
| 130 | - * is GtkSatList). |
|
| 131 | - * |
|
| 132 | - * @param Predict_Sat $sat The satellite data. |
|
| 133 | - * @param Predict_QTH $qth The observer data. |
|
| 134 | - * @param int $maxdt The maximum number of days to look ahead. |
|
| 135 | - * |
|
| 136 | - * @return Predict_Pass Pointer instance or NULL if no pass can be |
|
| 137 | - * found. |
|
| 138 | - */ |
|
| 139 | - public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt) |
|
| 140 | - { |
|
| 141 | - /* get the current time and call the get_pass function */ |
|
| 142 | - $now = Predict_Time::get_current_daynum(); |
|
| 143 | - |
|
| 144 | - return $this->get_pass($sat, $qth, $now, $maxdt); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** Predict first pass after a certain time. |
|
| 148 | - * |
|
| 149 | - * @param Predict_Sat $sat The satellite data. |
|
| 150 | - * @param Predict_QTH $qth The observer's location data. |
|
| 151 | - * @param float $start Starting time. |
|
| 152 | - * @param int $maxdt The maximum number of days to look ahead (0 for no limit). |
|
| 153 | - * |
|
| 154 | - * @return Predict_Pass or NULL if there was an error. |
|
| 155 | - * |
|
| 156 | - * This function will find the first upcoming pass with AOS no earlier than |
|
| 157 | - * t = start and no later than t = (start+maxdt). |
|
| 158 | - * |
|
| 159 | - * note For no time limit use maxdt = 0.0 |
|
| 160 | - * |
|
| 161 | - * note the data in sat will be corrupt (future) and must be refreshed |
|
| 162 | - * by the caller, if the caller will need it later on |
|
| 163 | - */ |
|
| 164 | - public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
|
| 165 | - { |
|
| 166 | - $aos = 0.0; /* time of AOS */ |
|
| 167 | - $tca = 0.0; /* time of TCA */ |
|
| 168 | - $los = 0.0; /* time of LOS */ |
|
| 169 | - $dt = 0.0; /* time diff */ |
|
| 170 | - $step = 0.0; /* time step */ |
|
| 171 | - $t0 = $start; |
|
| 172 | - $tres = 0.0; /* required time resolution */ |
|
| 173 | - $max_el = 0.0; /* maximum elevation */ |
|
| 174 | - $pass = null; |
|
| 175 | - $detail = null; |
|
| 176 | - $done = false; |
|
| 177 | - $iter = 0; /* number of iterations */ |
|
| 178 | - /* FIXME: watchdog */ |
|
| 179 | - |
|
| 180 | - /*copy sat_in to a working structure*/ |
|
| 181 | - $sat = clone $sat_in; |
|
| 182 | - $sat_working = clone $sat_in; |
|
| 183 | - |
|
| 184 | - /* get time resolution; sat-cfg stores it in seconds */ |
|
| 185 | - $tres = $this->timeRes / 86400.0; |
|
| 186 | - |
|
| 187 | - /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
|
| 55 | + const de2ra = 1.74532925E-2; /* Degrees to Radians */ |
|
| 56 | + const pi = 3.1415926535898; /* Pi */ |
|
| 57 | + const pio2 = 1.5707963267949; /* Pi/2 */ |
|
| 58 | + const x3pio2 = 4.71238898; /* 3*Pi/2 */ |
|
| 59 | + const twopi = 6.2831853071796; /* 2*Pi */ |
|
| 60 | + const e6a = 1.0E-6; |
|
| 61 | + const tothrd = 6.6666667E-1; /* 2/3 */ |
|
| 62 | + const xj2 = 1.0826158E-3; /* J2 Harmonic */ |
|
| 63 | + const xj3 = -2.53881E-6; /* J3 Harmonic */ |
|
| 64 | + const xj4 = -1.65597E-6; /* J4 Harmonic */ |
|
| 65 | + const xke = 7.43669161E-2; |
|
| 66 | + const xkmper = 6.378135E3; /* Earth radius km */ |
|
| 67 | + const xmnpda = 1.44E3; /* Minutes per day */ |
|
| 68 | + const km2mi = 0.621371; /* Kilometers per Mile */ |
|
| 69 | + const ae = 1.0; |
|
| 70 | + const ck2 = 5.413079E-4; |
|
| 71 | + const ck4 = 6.209887E-7; |
|
| 72 | + const __f = 3.352779E-3; |
|
| 73 | + const ge = 3.986008E5; |
|
| 74 | + const __s__ = 1.012229; |
|
| 75 | + const qoms2t = 1.880279E-09; |
|
| 76 | + const secday = 8.6400E4; /* Seconds per day */ |
|
| 77 | + const omega_E = 1.0027379; |
|
| 78 | + const omega_ER = 6.3003879; |
|
| 79 | + const zns = 1.19459E-5; |
|
| 80 | + const c1ss = 2.9864797E-6; |
|
| 81 | + const zes = 1.675E-2; |
|
| 82 | + const znl = 1.5835218E-4; |
|
| 83 | + const c1l = 4.7968065E-7; |
|
| 84 | + const zel = 5.490E-2; |
|
| 85 | + const zcosis = 9.1744867E-1; |
|
| 86 | + const zsinis = 3.9785416E-1; |
|
| 87 | + const zsings = -9.8088458E-1; |
|
| 88 | + const zcosgs = 1.945905E-1; |
|
| 89 | + const zcoshs = 1; |
|
| 90 | + const zsinhs = 0; |
|
| 91 | + const q22 = 1.7891679E-6; |
|
| 92 | + const q31 = 2.1460748E-6; |
|
| 93 | + const q33 = 2.2123015E-7; |
|
| 94 | + const g22 = 5.7686396; |
|
| 95 | + const g32 = 9.5240898E-1; |
|
| 96 | + const g44 = 1.8014998; |
|
| 97 | + const g52 = 1.0508330; |
|
| 98 | + const g54 = 4.4108898; |
|
| 99 | + const root22 = 1.7891679E-6; |
|
| 100 | + const root32 = 3.7393792E-7; |
|
| 101 | + const root44 = 7.3636953E-9; |
|
| 102 | + const root52 = 1.1428639E-7; |
|
| 103 | + const root54 = 2.1765803E-9; |
|
| 104 | + const thdt = 4.3752691E-3; |
|
| 105 | + const rho = 1.5696615E-1; |
|
| 106 | + const mfactor = 7.292115E-5; |
|
| 107 | + const __sr__ = 6.96000E5; /*Solar radius - kilometers (IAU 76)*/ |
|
| 108 | + const AU = 1.49597870E8; /*Astronomical unit - kilometers (IAU 76)*/ |
|
| 109 | + |
|
| 110 | + /* visibility constants */ |
|
| 111 | + const SAT_VIS_NONE = 0; |
|
| 112 | + const SAT_VIS_VISIBLE = 1; |
|
| 113 | + const SAT_VIS_DAYLIGHT = 2; |
|
| 114 | + const SAT_VIS_ECLIPSED = 3; |
|
| 115 | + |
|
| 116 | + /* preferences */ |
|
| 117 | + public $minEle = 10; // Minimum elevation |
|
| 118 | + public $timeRes = 10; // Pass details: time resolution |
|
| 119 | + public $numEntries = 20; // Pass details: number of entries |
|
| 120 | + public $threshold = -6; // Twilight threshold |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Predict the next pass. |
|
| 124 | + * |
|
| 125 | + * This function simply wraps the get_pass function using the current time |
|
| 126 | + * as parameter. |
|
| 127 | + * |
|
| 128 | + * Note: the data in sat will be corrupt (future) and must be refreshed |
|
| 129 | + * by the caller, if the caller will need it later on (eg. if the caller |
|
| 130 | + * is GtkSatList). |
|
| 131 | + * |
|
| 132 | + * @param Predict_Sat $sat The satellite data. |
|
| 133 | + * @param Predict_QTH $qth The observer data. |
|
| 134 | + * @param int $maxdt The maximum number of days to look ahead. |
|
| 135 | + * |
|
| 136 | + * @return Predict_Pass Pointer instance or NULL if no pass can be |
|
| 137 | + * found. |
|
| 138 | + */ |
|
| 139 | + public function get_next_pass(Predict_Sat $sat, Predict_QTH $qth, $maxdt) |
|
| 140 | + { |
|
| 141 | + /* get the current time and call the get_pass function */ |
|
| 142 | + $now = Predict_Time::get_current_daynum(); |
|
| 143 | + |
|
| 144 | + return $this->get_pass($sat, $qth, $now, $maxdt); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** Predict first pass after a certain time. |
|
| 148 | + * |
|
| 149 | + * @param Predict_Sat $sat The satellite data. |
|
| 150 | + * @param Predict_QTH $qth The observer's location data. |
|
| 151 | + * @param float $start Starting time. |
|
| 152 | + * @param int $maxdt The maximum number of days to look ahead (0 for no limit). |
|
| 153 | + * |
|
| 154 | + * @return Predict_Pass or NULL if there was an error. |
|
| 155 | + * |
|
| 156 | + * This function will find the first upcoming pass with AOS no earlier than |
|
| 157 | + * t = start and no later than t = (start+maxdt). |
|
| 158 | + * |
|
| 159 | + * note For no time limit use maxdt = 0.0 |
|
| 160 | + * |
|
| 161 | + * note the data in sat will be corrupt (future) and must be refreshed |
|
| 162 | + * by the caller, if the caller will need it later on |
|
| 163 | + */ |
|
| 164 | + public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
|
| 165 | + { |
|
| 166 | + $aos = 0.0; /* time of AOS */ |
|
| 167 | + $tca = 0.0; /* time of TCA */ |
|
| 168 | + $los = 0.0; /* time of LOS */ |
|
| 169 | + $dt = 0.0; /* time diff */ |
|
| 170 | + $step = 0.0; /* time step */ |
|
| 171 | + $t0 = $start; |
|
| 172 | + $tres = 0.0; /* required time resolution */ |
|
| 173 | + $max_el = 0.0; /* maximum elevation */ |
|
| 174 | + $pass = null; |
|
| 175 | + $detail = null; |
|
| 176 | + $done = false; |
|
| 177 | + $iter = 0; /* number of iterations */ |
|
| 178 | + /* FIXME: watchdog */ |
|
| 179 | + |
|
| 180 | + /*copy sat_in to a working structure*/ |
|
| 181 | + $sat = clone $sat_in; |
|
| 182 | + $sat_working = clone $sat_in; |
|
| 183 | + |
|
| 184 | + /* get time resolution; sat-cfg stores it in seconds */ |
|
| 185 | + $tres = $this->timeRes / 86400.0; |
|
| 186 | + |
|
| 187 | + /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
|
| 188 | 188 | or we run out of time |
| 189 | 189 | FIXME: we should have a safety break |
| 190 | 190 | */ |
| 191 | - while (!$done) { |
|
| 192 | - /* Find los of next pass or of current pass */ |
|
| 193 | - $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing |
|
| 194 | - $aos = $this->find_aos($sat, $qth, $t0, $maxdt); |
|
| 195 | - /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ |
|
| 196 | - /* __FILE__, */ |
|
| 197 | - /* __FUNCTION__, */ |
|
| 198 | - /* __LINE__, */ |
|
| 199 | - /* aos, */ |
|
| 200 | - /* los, */ |
|
| 201 | - /* t0); */ |
|
| 202 | - if ($aos > $los) { |
|
| 203 | - // los is from an currently happening pass, find previous aos |
|
| 204 | - $aos = $this->find_prev_aos($sat, $qth, $t0); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /* aos = 0.0 means no aos */ |
|
| 208 | - if ($aos == 0.0) { |
|
| 209 | - $done = true; |
|
| 210 | - } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 211 | - /* check whether we are within time limits; |
|
| 191 | + while (!$done) { |
|
| 192 | + /* Find los of next pass or of current pass */ |
|
| 193 | + $los = $this->find_los($sat, $qth, $t0, $maxdt); // See if a pass is ongoing |
|
| 194 | + $aos = $this->find_aos($sat, $qth, $t0, $maxdt); |
|
| 195 | + /* sat_log_log(SAT_LOG_LEVEL_MSG, "%s:%s:%d: found aos %f and los %f for t0=%f", */ |
|
| 196 | + /* __FILE__, */ |
|
| 197 | + /* __FUNCTION__, */ |
|
| 198 | + /* __LINE__, */ |
|
| 199 | + /* aos, */ |
|
| 200 | + /* los, */ |
|
| 201 | + /* t0); */ |
|
| 202 | + if ($aos > $los) { |
|
| 203 | + // los is from an currently happening pass, find previous aos |
|
| 204 | + $aos = $this->find_prev_aos($sat, $qth, $t0); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /* aos = 0.0 means no aos */ |
|
| 208 | + if ($aos == 0.0) { |
|
| 209 | + $done = true; |
|
| 210 | + } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 211 | + /* check whether we are within time limits; |
|
| 212 | 212 | maxdt = 0 mean no time limit. |
| 213 | 213 | */ |
| 214 | - $done = true; |
|
| 215 | - } else { |
|
| 216 | - //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later |
|
| 217 | - $dt = $los - $aos; |
|
| 214 | + $done = true; |
|
| 215 | + } else { |
|
| 216 | + //los = find_los (sat, qth, aos + 0.001, maxdt); // +1.5 min later |
|
| 217 | + $dt = $los - $aos; |
|
| 218 | 218 | |
| 219 | - /* get time step, which will give us the max number of entries */ |
|
| 220 | - $step = $dt / $this->numEntries; |
|
| 219 | + /* get time step, which will give us the max number of entries */ |
|
| 220 | + $step = $dt / $this->numEntries; |
|
| 221 | 221 | |
| 222 | - /* but if this is smaller than the required resolution |
|
| 222 | + /* but if this is smaller than the required resolution |
|
| 223 | 223 | we go with the resolution |
| 224 | 224 | */ |
| 225 | - if ($step < $tres) { |
|
| 226 | - $step = $tres; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /* create a pass_t entry; FIXME: g_try_new in 2.8 */ |
|
| 230 | - $pass = new Predict_Pass(); |
|
| 231 | - |
|
| 232 | - $pass->aos = $aos; |
|
| 233 | - $pass->los = $los; |
|
| 234 | - $pass->max_el = 0.0; |
|
| 235 | - $pass->aos_az = 0.0; |
|
| 236 | - $pass->los_az = 0.0; |
|
| 237 | - $pass->maxel_az = 0.0; |
|
| 238 | - $pass->vis = '---'; |
|
| 239 | - $pass->satname = $sat->nickname; |
|
| 240 | - $pass->details = array(); |
|
| 241 | - |
|
| 242 | - /* iterate over each time step */ |
|
| 243 | - for ($t = $pass->aos; $t <= $pass->los; $t += $step) { |
|
| 244 | - |
|
| 245 | - /* calculate satellite data */ |
|
| 246 | - $this->predict_calc($sat, $qth, $t); |
|
| 247 | - |
|
| 248 | - /* in the first iter we want to store |
|
| 225 | + if ($step < $tres) { |
|
| 226 | + $step = $tres; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /* create a pass_t entry; FIXME: g_try_new in 2.8 */ |
|
| 230 | + $pass = new Predict_Pass(); |
|
| 231 | + |
|
| 232 | + $pass->aos = $aos; |
|
| 233 | + $pass->los = $los; |
|
| 234 | + $pass->max_el = 0.0; |
|
| 235 | + $pass->aos_az = 0.0; |
|
| 236 | + $pass->los_az = 0.0; |
|
| 237 | + $pass->maxel_az = 0.0; |
|
| 238 | + $pass->vis = '---'; |
|
| 239 | + $pass->satname = $sat->nickname; |
|
| 240 | + $pass->details = array(); |
|
| 241 | + |
|
| 242 | + /* iterate over each time step */ |
|
| 243 | + for ($t = $pass->aos; $t <= $pass->los; $t += $step) { |
|
| 244 | + |
|
| 245 | + /* calculate satellite data */ |
|
| 246 | + $this->predict_calc($sat, $qth, $t); |
|
| 247 | + |
|
| 248 | + /* in the first iter we want to store |
|
| 249 | 249 | pass->aos_az |
| 250 | 250 | */ |
| 251 | - if ($t == $pass->aos) { |
|
| 252 | - $pass->aos_az = $sat->az; |
|
| 253 | - $pass->orbit = $sat->orbit; |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /* append details to sat->details */ |
|
| 257 | - $detail = new Predict_PassDetail(); |
|
| 258 | - $detail->time = $t; |
|
| 259 | - $detail->pos->x = $sat->pos->x; |
|
| 260 | - $detail->pos->y = $sat->pos->y; |
|
| 261 | - $detail->pos->z = $sat->pos->z; |
|
| 262 | - $detail->pos->w = $sat->pos->w; |
|
| 263 | - $detail->vel->x = $sat->vel->x; |
|
| 264 | - $detail->vel->y = $sat->vel->y; |
|
| 265 | - $detail->vel->z = $sat->vel->z; |
|
| 266 | - $detail->vel->w = $sat->vel->w; |
|
| 267 | - $detail->velo = $sat->velo; |
|
| 268 | - $detail->az = $sat->az; |
|
| 269 | - $detail->el = $sat->el; |
|
| 270 | - $detail->range = $sat->range; |
|
| 271 | - $detail->range_rate = $sat->range_rate; |
|
| 272 | - $detail->lat = $sat->ssplat; |
|
| 273 | - $detail->lon = $sat->ssplon; |
|
| 274 | - $detail->alt = $sat->alt; |
|
| 275 | - $detail->ma = $sat->ma; |
|
| 276 | - $detail->phase = $sat->phase; |
|
| 277 | - $detail->footprint = $sat->footprint; |
|
| 278 | - $detail->orbit = $sat->orbit; |
|
| 279 | - $detail->vis = $this->get_sat_vis($sat, $qth, $t); |
|
| 280 | - |
|
| 281 | - /* also store visibility "bit" */ |
|
| 282 | - switch ($detail->vis) { |
|
| 283 | - case self::SAT_VIS_VISIBLE: |
|
| 284 | - $pass->vis[0] = 'V'; |
|
| 285 | - break; |
|
| 286 | - case self::SAT_VIS_DAYLIGHT: |
|
| 287 | - $pass->vis[1] = 'D'; |
|
| 288 | - break; |
|
| 289 | - case self::SAT_VIS_ECLIPSED: |
|
| 290 | - $pass->vis[2] = 'E'; |
|
| 291 | - break; |
|
| 292 | - default: |
|
| 293 | - break; |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - // Using an array, no need to prepend and reverse the list |
|
| 297 | - // as gpredict does |
|
| 298 | - $pass->details[] = $detail; |
|
| 299 | - |
|
| 300 | - // Look up apparent magnitude if this is a visible pass |
|
| 301 | - if ($detail->vis === self::SAT_VIS_VISIBLE) { |
|
| 302 | - $apmag = $sat->calculateApparentMagnitude($t, $qth); |
|
| 303 | - if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) { |
|
| 304 | - $pass->max_apparent_magnitude = $apmag; |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /* store elevation if greater than the |
|
| 251 | + if ($t == $pass->aos) { |
|
| 252 | + $pass->aos_az = $sat->az; |
|
| 253 | + $pass->orbit = $sat->orbit; |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /* append details to sat->details */ |
|
| 257 | + $detail = new Predict_PassDetail(); |
|
| 258 | + $detail->time = $t; |
|
| 259 | + $detail->pos->x = $sat->pos->x; |
|
| 260 | + $detail->pos->y = $sat->pos->y; |
|
| 261 | + $detail->pos->z = $sat->pos->z; |
|
| 262 | + $detail->pos->w = $sat->pos->w; |
|
| 263 | + $detail->vel->x = $sat->vel->x; |
|
| 264 | + $detail->vel->y = $sat->vel->y; |
|
| 265 | + $detail->vel->z = $sat->vel->z; |
|
| 266 | + $detail->vel->w = $sat->vel->w; |
|
| 267 | + $detail->velo = $sat->velo; |
|
| 268 | + $detail->az = $sat->az; |
|
| 269 | + $detail->el = $sat->el; |
|
| 270 | + $detail->range = $sat->range; |
|
| 271 | + $detail->range_rate = $sat->range_rate; |
|
| 272 | + $detail->lat = $sat->ssplat; |
|
| 273 | + $detail->lon = $sat->ssplon; |
|
| 274 | + $detail->alt = $sat->alt; |
|
| 275 | + $detail->ma = $sat->ma; |
|
| 276 | + $detail->phase = $sat->phase; |
|
| 277 | + $detail->footprint = $sat->footprint; |
|
| 278 | + $detail->orbit = $sat->orbit; |
|
| 279 | + $detail->vis = $this->get_sat_vis($sat, $qth, $t); |
|
| 280 | + |
|
| 281 | + /* also store visibility "bit" */ |
|
| 282 | + switch ($detail->vis) { |
|
| 283 | + case self::SAT_VIS_VISIBLE: |
|
| 284 | + $pass->vis[0] = 'V'; |
|
| 285 | + break; |
|
| 286 | + case self::SAT_VIS_DAYLIGHT: |
|
| 287 | + $pass->vis[1] = 'D'; |
|
| 288 | + break; |
|
| 289 | + case self::SAT_VIS_ECLIPSED: |
|
| 290 | + $pass->vis[2] = 'E'; |
|
| 291 | + break; |
|
| 292 | + default: |
|
| 293 | + break; |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + // Using an array, no need to prepend and reverse the list |
|
| 297 | + // as gpredict does |
|
| 298 | + $pass->details[] = $detail; |
|
| 299 | + |
|
| 300 | + // Look up apparent magnitude if this is a visible pass |
|
| 301 | + if ($detail->vis === self::SAT_VIS_VISIBLE) { |
|
| 302 | + $apmag = $sat->calculateApparentMagnitude($t, $qth); |
|
| 303 | + if ($pass->max_apparent_magnitude === null || $apmag < $pass->max_apparent_magnitude) { |
|
| 304 | + $pass->max_apparent_magnitude = $apmag; |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /* store elevation if greater than the |
|
| 309 | 309 | previously stored one |
| 310 | 310 | */ |
| 311 | - if ($sat->el > $max_el) { |
|
| 312 | - $max_el = $sat->el; |
|
| 313 | - $tca = $t; |
|
| 314 | - $pass->maxel_az = $sat->az; |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - /* g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */ |
|
| 318 | - /* t, sat->az, sat->el, max_el); */ |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - /* calculate satellite data */ |
|
| 322 | - $this->predict_calc($sat, $qth, $pass->los); |
|
| 323 | - /* store los_az, max_el and tca */ |
|
| 324 | - $pass->los_az = $sat->az; |
|
| 325 | - $pass->max_el = $max_el; |
|
| 326 | - $pass->tca = $tca; |
|
| 327 | - |
|
| 328 | - /* check whether this pass is good */ |
|
| 329 | - if ($max_el >= $this->minEle) { |
|
| 330 | - $done = true; |
|
| 331 | - } else { |
|
| 332 | - $done = false; |
|
| 333 | - $t0 = $los + 0.014; // +20 min |
|
| 334 | - $pass = null; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - $iter++; |
|
| 338 | - } |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - return $pass; |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Calculate satellite visibility. |
|
| 346 | - * |
|
| 347 | - * @param Predict_Sat $sat The satellite structure. |
|
| 348 | - * @param Predict_QTH $qth The QTH |
|
| 349 | - * @param float $jul_utc The time at which the visibility should be calculated. |
|
| 350 | - * |
|
| 351 | - * @return int The visiblity constant, 0, 1, 2, or 3 (see above) |
|
| 352 | - */ |
|
| 353 | - public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc) |
|
| 354 | - { |
|
| 355 | - /* gboolean sat_sun_status; |
|
| 311 | + if ($sat->el > $max_el) { |
|
| 312 | + $max_el = $sat->el; |
|
| 313 | + $tca = $t; |
|
| 314 | + $pass->maxel_az = $sat->az; |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + /* g_print ("TIME: %f\tAZ: %f\tEL: %f (MAX: %f)\n", */ |
|
| 318 | + /* t, sat->az, sat->el, max_el); */ |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /* calculate satellite data */ |
|
| 322 | + $this->predict_calc($sat, $qth, $pass->los); |
|
| 323 | + /* store los_az, max_el and tca */ |
|
| 324 | + $pass->los_az = $sat->az; |
|
| 325 | + $pass->max_el = $max_el; |
|
| 326 | + $pass->tca = $tca; |
|
| 327 | + |
|
| 328 | + /* check whether this pass is good */ |
|
| 329 | + if ($max_el >= $this->minEle) { |
|
| 330 | + $done = true; |
|
| 331 | + } else { |
|
| 332 | + $done = false; |
|
| 333 | + $t0 = $los + 0.014; // +20 min |
|
| 334 | + $pass = null; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + $iter++; |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + return $pass; |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Calculate satellite visibility. |
|
| 346 | + * |
|
| 347 | + * @param Predict_Sat $sat The satellite structure. |
|
| 348 | + * @param Predict_QTH $qth The QTH |
|
| 349 | + * @param float $jul_utc The time at which the visibility should be calculated. |
|
| 350 | + * |
|
| 351 | + * @return int The visiblity constant, 0, 1, 2, or 3 (see above) |
|
| 352 | + */ |
|
| 353 | + public function get_sat_vis(Predict_Sat $sat, Predict_QTH $qth, $jul_utc) |
|
| 354 | + { |
|
| 355 | + /* gboolean sat_sun_status; |
|
| 356 | 356 | gdouble sun_el; |
| 357 | 357 | gdouble threshold; |
| 358 | 358 | gdouble eclipse_depth; |
| 359 | 359 | sat_vis_t vis = SAT_VIS_NONE; */ |
| 360 | 360 | |
| 361 | - $eclipse_depth = 0.0; |
|
| 362 | - $zero_vector = new Predict_Vector(); |
|
| 363 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 364 | - |
|
| 365 | - /* Solar ECI position vector */ |
|
| 366 | - $solar_vector = new Predict_Vector(); |
|
| 367 | - |
|
| 368 | - /* Solar observed az and el vector */ |
|
| 369 | - $solar_set = new Predict_ObsSet(); |
|
| 370 | - |
|
| 371 | - /* FIXME: could be passed as parameter */ |
|
| 372 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 373 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 374 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 375 | - $obs_geodetic->theta = 0; |
|
| 376 | - |
|
| 377 | - Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
|
| 378 | - Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set); |
|
| 379 | - |
|
| 380 | - if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) { |
|
| 381 | - /* satellite is eclipsed */ |
|
| 382 | - $sat_sun_status = false; |
|
| 383 | - } else { |
|
| 384 | - /* satellite in sunlight => may be visible */ |
|
| 385 | - $sat_sun_status = true; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if ($sat_sun_status) { |
|
| 389 | - $sun_el = Predict_Math::Degrees($solar_set->el); |
|
| 390 | - |
|
| 391 | - if ($sun_el <= $this->threshold && $sat->el >= 0.0) { |
|
| 392 | - $vis = self::SAT_VIS_VISIBLE; |
|
| 393 | - } else { |
|
| 394 | - $vis = self::SAT_VIS_DAYLIGHT; |
|
| 395 | - } |
|
| 396 | - } else { |
|
| 397 | - $vis = self::SAT_VIS_ECLIPSED; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - return $vis; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - /** Find the AOS time of the next pass. |
|
| 404 | - * @author Alexandru Csete, OZ9AEC |
|
| 405 | - * @author John A. Magliacane, KD2BD |
|
| 406 | - * @param Predict_Sat $sat The satellite data. |
|
| 407 | - * @param Predict_QTH $qth The observer's location (QTH) data. |
|
| 408 | - * @param float $start The julian date where calculation should start. |
|
| 409 | - * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 410 | - * @return The julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | - * |
|
| 412 | - * This function finds the time of AOS for the first coming pass taking place |
|
| 413 | - * no earlier that start. |
|
| 414 | - * If the satellite is currently within range, the function first calls |
|
| 415 | - * find_los to get the next LOS time. Then the calculations are done using |
|
| 416 | - * the new start time. |
|
| 417 | - * |
|
| 418 | - */ |
|
| 419 | - public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 420 | - { |
|
| 421 | - $t = $start; |
|
| 422 | - $aostime = 0.0; |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /* make sure current sat values are |
|
| 361 | + $eclipse_depth = 0.0; |
|
| 362 | + $zero_vector = new Predict_Vector(); |
|
| 363 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 364 | + |
|
| 365 | + /* Solar ECI position vector */ |
|
| 366 | + $solar_vector = new Predict_Vector(); |
|
| 367 | + |
|
| 368 | + /* Solar observed az and el vector */ |
|
| 369 | + $solar_set = new Predict_ObsSet(); |
|
| 370 | + |
|
| 371 | + /* FIXME: could be passed as parameter */ |
|
| 372 | + $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 373 | + $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 374 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 375 | + $obs_geodetic->theta = 0; |
|
| 376 | + |
|
| 377 | + Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
|
| 378 | + Predict_SGPObs::Calculate_Obs($jul_utc, $solar_vector, $zero_vector, $obs_geodetic, $solar_set); |
|
| 379 | + |
|
| 380 | + if (Predict_Solar::Sat_Eclipsed($sat->pos, $solar_vector, $eclipse_depth)) { |
|
| 381 | + /* satellite is eclipsed */ |
|
| 382 | + $sat_sun_status = false; |
|
| 383 | + } else { |
|
| 384 | + /* satellite in sunlight => may be visible */ |
|
| 385 | + $sat_sun_status = true; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if ($sat_sun_status) { |
|
| 389 | + $sun_el = Predict_Math::Degrees($solar_set->el); |
|
| 390 | + |
|
| 391 | + if ($sun_el <= $this->threshold && $sat->el >= 0.0) { |
|
| 392 | + $vis = self::SAT_VIS_VISIBLE; |
|
| 393 | + } else { |
|
| 394 | + $vis = self::SAT_VIS_DAYLIGHT; |
|
| 395 | + } |
|
| 396 | + } else { |
|
| 397 | + $vis = self::SAT_VIS_ECLIPSED; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + return $vis; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + /** Find the AOS time of the next pass. |
|
| 404 | + * @author Alexandru Csete, OZ9AEC |
|
| 405 | + * @author John A. Magliacane, KD2BD |
|
| 406 | + * @param Predict_Sat $sat The satellite data. |
|
| 407 | + * @param Predict_QTH $qth The observer's location (QTH) data. |
|
| 408 | + * @param float $start The julian date where calculation should start. |
|
| 409 | + * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 410 | + * @return The julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | + * |
|
| 412 | + * This function finds the time of AOS for the first coming pass taking place |
|
| 413 | + * no earlier that start. |
|
| 414 | + * If the satellite is currently within range, the function first calls |
|
| 415 | + * find_los to get the next LOS time. Then the calculations are done using |
|
| 416 | + * the new start time. |
|
| 417 | + * |
|
| 418 | + */ |
|
| 419 | + public function find_aos(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 420 | + { |
|
| 421 | + $t = $start; |
|
| 422 | + $aostime = 0.0; |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /* make sure current sat values are |
|
| 426 | 426 | in sync with the time |
| 427 | 427 | */ |
| 428 | - $this->predict_calc($sat, $qth, $start); |
|
| 429 | - |
|
| 430 | - /* check whether satellite has aos */ |
|
| 431 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 432 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 433 | - !$this->has_aos($sat, $qth)) { |
|
| 434 | - |
|
| 435 | - return 0.0; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - if ($sat->el > 0.0) { |
|
| 439 | - $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /* invalid time (potentially returned by find_los) */ |
|
| 443 | - if ($t < 0.1) { |
|
| 444 | - return 0.0; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - /* update satellite data */ |
|
| 448 | - $this->predict_calc($sat, $qth, $t); |
|
| 449 | - |
|
| 450 | - /* use upper time limit */ |
|
| 451 | - if ($maxdt > 0.0) { |
|
| 452 | - |
|
| 453 | - /* coarse time steps */ |
|
| 454 | - while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
|
| 455 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 456 | - $this->predict_calc($sat, $qth, $t); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - /* fine steps */ |
|
| 460 | - while (($aostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 461 | - |
|
| 462 | - if (abs($sat->el) < 0.005) { |
|
| 463 | - $aostime = $t; |
|
| 464 | - } else { |
|
| 465 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 466 | - $this->predict_calc($sat, $qth, $t); |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - } else { |
|
| 470 | - /* don't use upper time limit */ |
|
| 471 | - |
|
| 472 | - /* coarse time steps */ |
|
| 473 | - while ($sat->el < -1.0) { |
|
| 474 | - |
|
| 475 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 476 | - $this->predict_calc($sat, $qth, $t); |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - /* fine steps */ |
|
| 480 | - while ($aostime == 0.0) { |
|
| 481 | - |
|
| 482 | - if (abs($sat->el) < 0.005) { |
|
| 483 | - $aostime = $t; |
|
| 484 | - } else { |
|
| 485 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 486 | - $this->predict_calc($sat, $qth, $t); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - |
|
| 492 | - return $aostime; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - /** SGP4SDP4 driver for doing AOS/LOS calculations. |
|
| 496 | - * @param Predict_Sat $sat The satellite data. |
|
| 497 | - * @param Predict_QTH $qth The QTH observer location data. |
|
| 498 | - * @param float $t The time for calculation (Julian Date) |
|
| 499 | - * |
|
| 500 | - */ |
|
| 501 | - public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t) |
|
| 502 | - { |
|
| 503 | - $obs_set = new Predict_ObsSet(); |
|
| 504 | - $sat_geodetic = new Predict_Geodetic(); |
|
| 505 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 506 | - |
|
| 507 | - $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 508 | - $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 509 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 510 | - $obs_geodetic->theta = 0; |
|
| 511 | - |
|
| 512 | - $sat->jul_utc = $t; |
|
| 513 | - $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 514 | - |
|
| 515 | - /* call the norad routines according to the deep-space flag */ |
|
| 516 | - $sgpsdp = Predict_SGPSDP::getInstance($sat); |
|
| 517 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | - $sgpsdp->SDP4($sat, $sat->tsince); |
|
| 519 | - } else { |
|
| 520 | - $sgpsdp->SGP4($sat, $sat->tsince); |
|
| 521 | - } |
|
| 522 | - |
|
| 523 | - Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 524 | - |
|
| 525 | - /* get the velocity of the satellite */ |
|
| 526 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 527 | - $sat->velo = $sat->vel->w; |
|
| 528 | - Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 529 | - Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
|
| 530 | - |
|
| 531 | - while ($sat_geodetic->lon < -self::pi) { |
|
| 532 | - $sat_geodetic->lon += self::twopi; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - while ($sat_geodetic->lon > (self::pi)) { |
|
| 536 | - $sat_geodetic->lon -= self::twopi; |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 540 | - $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 541 | - $sat->range = $obs_set->range; |
|
| 542 | - $sat->range_rate = $obs_set->range_rate; |
|
| 543 | - $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 544 | - $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 545 | - $sat->alt = $sat_geodetic->alt; |
|
| 546 | - $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 547 | - $sat->ma *= 256.0 / 360.0; |
|
| 548 | - $sat->phase = Predict_Math::Degrees($sat->phase); |
|
| 549 | - |
|
| 550 | - /* same formulas, but the one from predict is nicer */ |
|
| 551 | - //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
|
| 552 | - $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 553 | - $age = $sat->jul_utc - $sat->jul_epoch; |
|
| 554 | - $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + |
|
| 555 | - $age * $sat->tle->bstar * self::ae) * $age + |
|
| 556 | - $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; |
|
| 557 | - } |
|
| 558 | - |
|
| 559 | - /** Find the LOS time of the next pass. |
|
| 560 | - * @author Alexandru Csete, OZ9AEC |
|
| 561 | - * @author John A. Magliacane, KD2BD |
|
| 562 | - * @param Predict_Sat $sat The satellite data. |
|
| 563 | - * @param Predict_QTH $qth The QTH observer location data. |
|
| 564 | - * @param float $start The time where calculation should start. (Julian Date) |
|
| 565 | - * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 566 | - * @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | - * |
|
| 568 | - * This function finds the time of LOS for the first coming pass taking place |
|
| 569 | - * no earlier that start. |
|
| 570 | - * If the satellite is currently out of range, the function first calls |
|
| 571 | - * find_aos to get the next AOS time. Then the calculations are done using |
|
| 572 | - * the new start time. |
|
| 573 | - * The function has a built-in watchdog to ensure that we don't end up in |
|
| 574 | - * lengthy loops. |
|
| 575 | - * |
|
| 576 | - */ |
|
| 577 | - public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 578 | - { |
|
| 579 | - $t = $start; |
|
| 580 | - $lostime = 0.0; |
|
| 581 | - |
|
| 582 | - |
|
| 583 | - $this->predict_calc($sat, $qth, $start); |
|
| 584 | - |
|
| 585 | - /* check whether satellite has aos */ |
|
| 586 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 587 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 588 | - !$this->has_aos ($sat, $qth)) { |
|
| 589 | - |
|
| 590 | - return 0.0; |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - if ($sat->el < 0.0) { |
|
| 594 | - $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - /* invalid time (potentially returned by find_aos) */ |
|
| 598 | - if ($t < 0.01) { |
|
| 599 | - return 0.0; |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /* update satellite data */ |
|
| 603 | - $this->predict_calc($sat, $qth, $t); |
|
| 604 | - |
|
| 605 | - /* use upper time limit */ |
|
| 606 | - if ($maxdt > 0.0) { |
|
| 607 | - |
|
| 608 | - /* coarse steps */ |
|
| 609 | - while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
|
| 610 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 611 | - $this->predict_calc($sat, $qth, $t); |
|
| 612 | - } |
|
| 613 | - |
|
| 614 | - /* fine steps */ |
|
| 615 | - while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | - |
|
| 617 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 618 | - $this->predict_calc($sat, $qth, $t); |
|
| 619 | - |
|
| 620 | - if (abs($sat->el) < 0.005) { |
|
| 621 | - $lostime = $t; |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - } else { |
|
| 625 | - /* don't use upper limit */ |
|
| 626 | - |
|
| 627 | - /* coarse steps */ |
|
| 628 | - while ($sat->el >= 1.0) { |
|
| 629 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 630 | - $this->predict_calc($sat, $qth, $t); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - /* fine steps */ |
|
| 634 | - while ($lostime == 0.0) { |
|
| 635 | - |
|
| 636 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 637 | - $this->predict_calc($sat, $qth, $t); |
|
| 638 | - |
|
| 639 | - if (abs($sat->el) < 0.005) |
|
| 640 | - $lostime = $t; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - |
|
| 644 | - return $lostime; |
|
| 645 | - } |
|
| 646 | - |
|
| 647 | - /** Find AOS time of current pass. |
|
| 648 | - * @param Predict_Sat $sat The satellite to find AOS for. |
|
| 649 | - * @param Predict_QTH $qth The ground station. |
|
| 650 | - * @param float $start Start time, prefereably now. |
|
| 651 | - * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | - * |
|
| 653 | - * This function can be used to find the AOS time in the past of the |
|
| 654 | - * current pass. |
|
| 655 | - */ |
|
| 656 | - public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start) |
|
| 657 | - { |
|
| 658 | - $aostime = $start; |
|
| 659 | - |
|
| 660 | - /* make sure current sat values are |
|
| 428 | + $this->predict_calc($sat, $qth, $start); |
|
| 429 | + |
|
| 430 | + /* check whether satellite has aos */ |
|
| 431 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 432 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 433 | + !$this->has_aos($sat, $qth)) { |
|
| 434 | + |
|
| 435 | + return 0.0; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + if ($sat->el > 0.0) { |
|
| 439 | + $t = $this->find_los($sat, $qth, $start, $maxdt) + 0.014; // +20 min |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /* invalid time (potentially returned by find_los) */ |
|
| 443 | + if ($t < 0.1) { |
|
| 444 | + return 0.0; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + /* update satellite data */ |
|
| 448 | + $this->predict_calc($sat, $qth, $t); |
|
| 449 | + |
|
| 450 | + /* use upper time limit */ |
|
| 451 | + if ($maxdt > 0.0) { |
|
| 452 | + |
|
| 453 | + /* coarse time steps */ |
|
| 454 | + while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
|
| 455 | + $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 456 | + $this->predict_calc($sat, $qth, $t); |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + /* fine steps */ |
|
| 460 | + while (($aostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 461 | + |
|
| 462 | + if (abs($sat->el) < 0.005) { |
|
| 463 | + $aostime = $t; |
|
| 464 | + } else { |
|
| 465 | + $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 466 | + $this->predict_calc($sat, $qth, $t); |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + } else { |
|
| 470 | + /* don't use upper time limit */ |
|
| 471 | + |
|
| 472 | + /* coarse time steps */ |
|
| 473 | + while ($sat->el < -1.0) { |
|
| 474 | + |
|
| 475 | + $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 476 | + $this->predict_calc($sat, $qth, $t); |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + /* fine steps */ |
|
| 480 | + while ($aostime == 0.0) { |
|
| 481 | + |
|
| 482 | + if (abs($sat->el) < 0.005) { |
|
| 483 | + $aostime = $t; |
|
| 484 | + } else { |
|
| 485 | + $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 486 | + $this->predict_calc($sat, $qth, $t); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + } |
|
| 490 | + } |
|
| 491 | + |
|
| 492 | + return $aostime; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** SGP4SDP4 driver for doing AOS/LOS calculations. |
|
| 496 | + * @param Predict_Sat $sat The satellite data. |
|
| 497 | + * @param Predict_QTH $qth The QTH observer location data. |
|
| 498 | + * @param float $t The time for calculation (Julian Date) |
|
| 499 | + * |
|
| 500 | + */ |
|
| 501 | + public function predict_calc(Predict_Sat $sat, Predict_QTH $qth, $t) |
|
| 502 | + { |
|
| 503 | + $obs_set = new Predict_ObsSet(); |
|
| 504 | + $sat_geodetic = new Predict_Geodetic(); |
|
| 505 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 506 | + |
|
| 507 | + $obs_geodetic->lon = $qth->lon * self::de2ra; |
|
| 508 | + $obs_geodetic->lat = $qth->lat * self::de2ra; |
|
| 509 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 510 | + $obs_geodetic->theta = 0; |
|
| 511 | + |
|
| 512 | + $sat->jul_utc = $t; |
|
| 513 | + $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 514 | + |
|
| 515 | + /* call the norad routines according to the deep-space flag */ |
|
| 516 | + $sgpsdp = Predict_SGPSDP::getInstance($sat); |
|
| 517 | + if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | + $sgpsdp->SDP4($sat, $sat->tsince); |
|
| 519 | + } else { |
|
| 520 | + $sgpsdp->SGP4($sat, $sat->tsince); |
|
| 521 | + } |
|
| 522 | + |
|
| 523 | + Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 524 | + |
|
| 525 | + /* get the velocity of the satellite */ |
|
| 526 | + $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 527 | + $sat->velo = $sat->vel->w; |
|
| 528 | + Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 529 | + Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
|
| 530 | + |
|
| 531 | + while ($sat_geodetic->lon < -self::pi) { |
|
| 532 | + $sat_geodetic->lon += self::twopi; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + while ($sat_geodetic->lon > (self::pi)) { |
|
| 536 | + $sat_geodetic->lon -= self::twopi; |
|
| 537 | + } |
|
| 538 | + |
|
| 539 | + $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 540 | + $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 541 | + $sat->range = $obs_set->range; |
|
| 542 | + $sat->range_rate = $obs_set->range_rate; |
|
| 543 | + $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 544 | + $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 545 | + $sat->alt = $sat_geodetic->alt; |
|
| 546 | + $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 547 | + $sat->ma *= 256.0 / 360.0; |
|
| 548 | + $sat->phase = Predict_Math::Degrees($sat->phase); |
|
| 549 | + |
|
| 550 | + /* same formulas, but the one from predict is nicer */ |
|
| 551 | + //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
|
| 552 | + $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 553 | + $age = $sat->jul_utc - $sat->jul_epoch; |
|
| 554 | + $sat->orbit = floor(($sat->tle->xno * self::xmnpda / self::twopi + |
|
| 555 | + $age * $sat->tle->bstar * self::ae) * $age + |
|
| 556 | + $sat->tle->xmo / self::twopi) + $sat->tle->revnum - 1; |
|
| 557 | + } |
|
| 558 | + |
|
| 559 | + /** Find the LOS time of the next pass. |
|
| 560 | + * @author Alexandru Csete, OZ9AEC |
|
| 561 | + * @author John A. Magliacane, KD2BD |
|
| 562 | + * @param Predict_Sat $sat The satellite data. |
|
| 563 | + * @param Predict_QTH $qth The QTH observer location data. |
|
| 564 | + * @param float $start The time where calculation should start. (Julian Date) |
|
| 565 | + * @param int $maxdt The upper time limit in days (0.0 = no limit) |
|
| 566 | + * @return The time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | + * |
|
| 568 | + * This function finds the time of LOS for the first coming pass taking place |
|
| 569 | + * no earlier that start. |
|
| 570 | + * If the satellite is currently out of range, the function first calls |
|
| 571 | + * find_aos to get the next AOS time. Then the calculations are done using |
|
| 572 | + * the new start time. |
|
| 573 | + * The function has a built-in watchdog to ensure that we don't end up in |
|
| 574 | + * lengthy loops. |
|
| 575 | + * |
|
| 576 | + */ |
|
| 577 | + public function find_los(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt) |
|
| 578 | + { |
|
| 579 | + $t = $start; |
|
| 580 | + $lostime = 0.0; |
|
| 581 | + |
|
| 582 | + |
|
| 583 | + $this->predict_calc($sat, $qth, $start); |
|
| 584 | + |
|
| 585 | + /* check whether satellite has aos */ |
|
| 586 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 587 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 588 | + !$this->has_aos ($sat, $qth)) { |
|
| 589 | + |
|
| 590 | + return 0.0; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + if ($sat->el < 0.0) { |
|
| 594 | + $t = $this->find_aos($sat, $qth, $start, $maxdt) + 0.001; // +1.5 min |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + /* invalid time (potentially returned by find_aos) */ |
|
| 598 | + if ($t < 0.01) { |
|
| 599 | + return 0.0; |
|
| 600 | + } |
|
| 601 | + |
|
| 602 | + /* update satellite data */ |
|
| 603 | + $this->predict_calc($sat, $qth, $t); |
|
| 604 | + |
|
| 605 | + /* use upper time limit */ |
|
| 606 | + if ($maxdt > 0.0) { |
|
| 607 | + |
|
| 608 | + /* coarse steps */ |
|
| 609 | + while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
|
| 610 | + $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 611 | + $this->predict_calc($sat, $qth, $t); |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + /* fine steps */ |
|
| 615 | + while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | + |
|
| 617 | + $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 618 | + $this->predict_calc($sat, $qth, $t); |
|
| 619 | + |
|
| 620 | + if (abs($sat->el) < 0.005) { |
|
| 621 | + $lostime = $t; |
|
| 622 | + } |
|
| 623 | + } |
|
| 624 | + } else { |
|
| 625 | + /* don't use upper limit */ |
|
| 626 | + |
|
| 627 | + /* coarse steps */ |
|
| 628 | + while ($sat->el >= 1.0) { |
|
| 629 | + $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 630 | + $this->predict_calc($sat, $qth, $t); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + /* fine steps */ |
|
| 634 | + while ($lostime == 0.0) { |
|
| 635 | + |
|
| 636 | + $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 637 | + $this->predict_calc($sat, $qth, $t); |
|
| 638 | + |
|
| 639 | + if (abs($sat->el) < 0.005) |
|
| 640 | + $lostime = $t; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + |
|
| 644 | + return $lostime; |
|
| 645 | + } |
|
| 646 | + |
|
| 647 | + /** Find AOS time of current pass. |
|
| 648 | + * @param Predict_Sat $sat The satellite to find AOS for. |
|
| 649 | + * @param Predict_QTH $qth The ground station. |
|
| 650 | + * @param float $start Start time, prefereably now. |
|
| 651 | + * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | + * |
|
| 653 | + * This function can be used to find the AOS time in the past of the |
|
| 654 | + * current pass. |
|
| 655 | + */ |
|
| 656 | + public function find_prev_aos(Predict_Sat $sat, Predict_QTH $qth, $start) |
|
| 657 | + { |
|
| 658 | + $aostime = $start; |
|
| 659 | + |
|
| 660 | + /* make sure current sat values are |
|
| 661 | 661 | in sync with the time |
| 662 | 662 | */ |
| 663 | - $this->predict_calc($sat, $qth, $start); |
|
| 664 | - |
|
| 665 | - /* check whether satellite has aos */ |
|
| 666 | - if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 667 | - ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 668 | - !$this->has_aos($sat, $qth)) { |
|
| 669 | - |
|
| 670 | - return 0.0; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - while ($sat->el >= 0.0) { |
|
| 674 | - $aostime -= 0.0005; // 0.75 min |
|
| 675 | - $this->predict_calc($sat, $qth, $aostime); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - return $aostime; |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - /** Determine whether satellite ever reaches AOS. |
|
| 682 | - * @author John A. Magliacane, KD2BD |
|
| 683 | - * @author Alexandru Csete, OZ9AEC |
|
| 684 | - * @param Predict_Sat $sat The satellite data. |
|
| 685 | - * @param Predict_QTH $qth The observer's location data |
|
| 686 | - * @return bool true if the satellite will reach AOS, false otherwise. |
|
| 687 | - * |
|
| 688 | - */ |
|
| 689 | - public function has_aos(Predict_Sat $sat, Predict_QTH $qth) |
|
| 690 | - { |
|
| 691 | - $retcode = false; |
|
| 692 | - |
|
| 693 | - /* FIXME */ |
|
| 694 | - if ($sat->meanmo == 0.0) { |
|
| 695 | - $retcode = false; |
|
| 696 | - } else { |
|
| 697 | - |
|
| 698 | - /* xincl is already in RAD by select_ephemeris */ |
|
| 699 | - $lin = $sat->tle->xincl; |
|
| 700 | - if ($lin >= self::pio2) { |
|
| 701 | - $lin = self::pi - $lin; |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0)); |
|
| 705 | - $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper; |
|
| 706 | - |
|
| 707 | - if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 708 | - $retcode = true; |
|
| 709 | - } else { |
|
| 710 | - $retcode = false; |
|
| 711 | - } |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - return $retcode; |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - /** Predict passes after a certain time. |
|
| 718 | - * |
|
| 719 | - * |
|
| 720 | - * This function calculates num upcoming passes with AOS no earlier |
|
| 721 | - * than t = start and not later that t = (start+maxdt). The function will |
|
| 722 | - * repeatedly call get_pass until |
|
| 723 | - * the number of predicted passes is equal to num, the time has reached |
|
| 724 | - * limit or the get_pass function returns NULL. |
|
| 725 | - * |
|
| 726 | - * note For no time limit use maxdt = 0.0 |
|
| 727 | - * |
|
| 728 | - * note the data in sat will be corrupt (future) and must be refreshed |
|
| 729 | - * by the caller, if the caller will need it later on (eg. if the caller |
|
| 730 | - * is GtkSatList). |
|
| 731 | - * |
|
| 732 | - * note Prepending to a singly linked list is much faster than appending. |
|
| 733 | - * Therefore, the elements are prepended whereafter the GSList is |
|
| 734 | - * reversed |
|
| 735 | - * |
|
| 736 | - * |
|
| 737 | - * @param Predict_Sat $sat The satellite data |
|
| 738 | - * @param Predict_QTH $qth The observer's location data |
|
| 739 | - * @param float $start The start julian date |
|
| 740 | - * @param int $maxdt The max # of days to look |
|
| 741 | - * @param int $num The max # of passes to get |
|
| 742 | - * @return array of Predict_Pass instances if found, empty array otherwise |
|
| 743 | - */ |
|
| 744 | - public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0) |
|
| 745 | - { |
|
| 746 | - $passes = array(); |
|
| 747 | - |
|
| 748 | - /* if no number has been specified |
|
| 663 | + $this->predict_calc($sat, $qth, $start); |
|
| 664 | + |
|
| 665 | + /* check whether satellite has aos */ |
|
| 666 | + if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
|
| 667 | + ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
|
| 668 | + !$this->has_aos($sat, $qth)) { |
|
| 669 | + |
|
| 670 | + return 0.0; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + while ($sat->el >= 0.0) { |
|
| 674 | + $aostime -= 0.0005; // 0.75 min |
|
| 675 | + $this->predict_calc($sat, $qth, $aostime); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + return $aostime; |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + /** Determine whether satellite ever reaches AOS. |
|
| 682 | + * @author John A. Magliacane, KD2BD |
|
| 683 | + * @author Alexandru Csete, OZ9AEC |
|
| 684 | + * @param Predict_Sat $sat The satellite data. |
|
| 685 | + * @param Predict_QTH $qth The observer's location data |
|
| 686 | + * @return bool true if the satellite will reach AOS, false otherwise. |
|
| 687 | + * |
|
| 688 | + */ |
|
| 689 | + public function has_aos(Predict_Sat $sat, Predict_QTH $qth) |
|
| 690 | + { |
|
| 691 | + $retcode = false; |
|
| 692 | + |
|
| 693 | + /* FIXME */ |
|
| 694 | + if ($sat->meanmo == 0.0) { |
|
| 695 | + $retcode = false; |
|
| 696 | + } else { |
|
| 697 | + |
|
| 698 | + /* xincl is already in RAD by select_ephemeris */ |
|
| 699 | + $lin = $sat->tle->xincl; |
|
| 700 | + if ($lin >= self::pio2) { |
|
| 701 | + $lin = self::pi - $lin; |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + $sma = 331.25 * exp(log(1440.0 / $sat->meanmo) * (2.0 / 3.0)); |
|
| 705 | + $apogee = $sma * (1.0 + $sat->tle->eo) - self::xkmper; |
|
| 706 | + |
|
| 707 | + if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 708 | + $retcode = true; |
|
| 709 | + } else { |
|
| 710 | + $retcode = false; |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + return $retcode; |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** Predict passes after a certain time. |
|
| 718 | + * |
|
| 719 | + * |
|
| 720 | + * This function calculates num upcoming passes with AOS no earlier |
|
| 721 | + * than t = start and not later that t = (start+maxdt). The function will |
|
| 722 | + * repeatedly call get_pass until |
|
| 723 | + * the number of predicted passes is equal to num, the time has reached |
|
| 724 | + * limit or the get_pass function returns NULL. |
|
| 725 | + * |
|
| 726 | + * note For no time limit use maxdt = 0.0 |
|
| 727 | + * |
|
| 728 | + * note the data in sat will be corrupt (future) and must be refreshed |
|
| 729 | + * by the caller, if the caller will need it later on (eg. if the caller |
|
| 730 | + * is GtkSatList). |
|
| 731 | + * |
|
| 732 | + * note Prepending to a singly linked list is much faster than appending. |
|
| 733 | + * Therefore, the elements are prepended whereafter the GSList is |
|
| 734 | + * reversed |
|
| 735 | + * |
|
| 736 | + * |
|
| 737 | + * @param Predict_Sat $sat The satellite data |
|
| 738 | + * @param Predict_QTH $qth The observer's location data |
|
| 739 | + * @param float $start The start julian date |
|
| 740 | + * @param int $maxdt The max # of days to look |
|
| 741 | + * @param int $num The max # of passes to get |
|
| 742 | + * @return array of Predict_Pass instances if found, empty array otherwise |
|
| 743 | + */ |
|
| 744 | + public function get_passes(Predict_Sat $sat, Predict_QTH $qth, $start, $maxdt, $num = 0) |
|
| 745 | + { |
|
| 746 | + $passes = array(); |
|
| 747 | + |
|
| 748 | + /* if no number has been specified |
|
| 749 | 749 | set it to something big */ |
| 750 | - if ($num == 0) { |
|
| 751 | - $num = 100; |
|
| 752 | - } |
|
| 750 | + if ($num == 0) { |
|
| 751 | + $num = 100; |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | - $t = $start; |
|
| 754 | + $t = $start; |
|
| 755 | 755 | |
| 756 | - for ($i = 0; $i < $num; $i++) { |
|
| 757 | - $pass = $this->get_pass($sat, $qth, $t, $maxdt); |
|
| 756 | + for ($i = 0; $i < $num; $i++) { |
|
| 757 | + $pass = $this->get_pass($sat, $qth, $t, $maxdt); |
|
| 758 | 758 | |
| 759 | - if ($pass != null) { |
|
| 760 | - $passes[] = $pass; |
|
| 761 | - $t = $pass->los + 0.014; // +20 min |
|
| 759 | + if ($pass != null) { |
|
| 760 | + $passes[] = $pass; |
|
| 761 | + $t = $pass->los + 0.014; // +20 min |
|
| 762 | 762 | |
| 763 | - /* if maxdt > 0.0 check whether we have reached t = start+maxdt |
|
| 763 | + /* if maxdt > 0.0 check whether we have reached t = start+maxdt |
|
| 764 | 764 | if yes finish predictions |
| 765 | 765 | */ |
| 766 | - if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) { |
|
| 767 | - $i = $num; |
|
| 768 | - } |
|
| 769 | - } else { |
|
| 770 | - /* we can't get any more passes */ |
|
| 771 | - $i = $num; |
|
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - return $passes; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Filters out visible passes and adds the visible aos, tca, los, and |
|
| 780 | - * corresponding az and ele for each. |
|
| 781 | - * |
|
| 782 | - * @param array $passes The passes returned from get_passes() |
|
| 783 | - * |
|
| 784 | - * @author Bill Shupp |
|
| 785 | - * @return array |
|
| 786 | - */ |
|
| 787 | - public function filterVisiblePasses(array $passes) |
|
| 788 | - { |
|
| 789 | - $filtered = array(); |
|
| 790 | - |
|
| 791 | - foreach ($passes as $result) { |
|
| 792 | - // Dummy check |
|
| 793 | - if ($result->vis[0] != 'V') { |
|
| 794 | - continue; |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - $aos = false; |
|
| 798 | - $aos_az = false; |
|
| 799 | - $aos = false; |
|
| 800 | - $tca = false; |
|
| 801 | - $los_az = false; |
|
| 802 | - $max_el = 0; |
|
| 803 | - |
|
| 804 | - foreach ($result->details as $detail) { |
|
| 805 | - if ($detail->vis != Predict::SAT_VIS_VISIBLE) { |
|
| 806 | - continue; |
|
| 807 | - } |
|
| 808 | - if ($detail->el < $this->minEle) { |
|
| 809 | - continue; |
|
| 810 | - } |
|
| 811 | - |
|
| 812 | - if ($aos == false) { |
|
| 813 | - $aos = $detail->time; |
|
| 814 | - $aos_az = $detail->az; |
|
| 815 | - $aos_el = $detail->el; |
|
| 816 | - $tca = $detail->time; |
|
| 817 | - $los = $detail->time; |
|
| 818 | - $los_az = $detail->az; |
|
| 819 | - $los_el = $detail->el; |
|
| 820 | - $max_el = $detail->el; |
|
| 821 | - $max_el_az = $detail->el; |
|
| 822 | - continue; |
|
| 823 | - } |
|
| 824 | - $los = $detail->time; |
|
| 825 | - $los_az = $detail->az; |
|
| 826 | - $los_el = $detail->el; |
|
| 827 | - |
|
| 828 | - if ($detail->el > $max_el) { |
|
| 829 | - $tca = $detail->time; |
|
| 830 | - $max_el = $detail->el; |
|
| 831 | - $max_el_az = $detail->az; |
|
| 832 | - } |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - if ($aos === false) { |
|
| 836 | - // Does not reach minimum elevation, skip |
|
| 837 | - continue; |
|
| 838 | - } |
|
| 839 | - |
|
| 840 | - $result->visible_aos = $aos; |
|
| 841 | - $result->visible_aos_az = $aos_az; |
|
| 842 | - $result->visible_aos_el = $aos_el; |
|
| 843 | - $result->visible_tca = $tca; |
|
| 844 | - $result->visible_max_el = $max_el; |
|
| 845 | - $result->visible_max_el_az = $max_el_az; |
|
| 846 | - $result->visible_los = $los; |
|
| 847 | - $result->visible_los_az = $los_az; |
|
| 848 | - $result->visible_los_el = $los_el; |
|
| 849 | - |
|
| 850 | - $filtered[] = $result; |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - return $filtered; |
|
| 854 | - } |
|
| 855 | - |
|
| 856 | - /** |
|
| 857 | - * Translates aziumuth degrees to compass direction: |
|
| 858 | - * |
|
| 859 | - * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°), |
|
| 860 | - * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°), |
|
| 861 | - * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°) |
|
| 862 | - * |
|
| 863 | - * @param int $az The azimuth in degrees, defaults to 0 |
|
| 864 | - * |
|
| 865 | - * @return string |
|
| 866 | - */ |
|
| 867 | - public function azDegreesToDirection($az = 0) |
|
| 868 | - { |
|
| 869 | - $i = floor($az / 22.5); |
|
| 870 | - $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 871 | - $i = ($az >= $m) ? $i + 1 : $i; |
|
| 872 | - |
|
| 873 | - return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 874 | - } |
|
| 766 | + if (($maxdt > 0.0) && ($t >= ($start + $maxdt))) { |
|
| 767 | + $i = $num; |
|
| 768 | + } |
|
| 769 | + } else { |
|
| 770 | + /* we can't get any more passes */ |
|
| 771 | + $i = $num; |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + return $passes; |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + /** |
|
| 779 | + * Filters out visible passes and adds the visible aos, tca, los, and |
|
| 780 | + * corresponding az and ele for each. |
|
| 781 | + * |
|
| 782 | + * @param array $passes The passes returned from get_passes() |
|
| 783 | + * |
|
| 784 | + * @author Bill Shupp |
|
| 785 | + * @return array |
|
| 786 | + */ |
|
| 787 | + public function filterVisiblePasses(array $passes) |
|
| 788 | + { |
|
| 789 | + $filtered = array(); |
|
| 790 | + |
|
| 791 | + foreach ($passes as $result) { |
|
| 792 | + // Dummy check |
|
| 793 | + if ($result->vis[0] != 'V') { |
|
| 794 | + continue; |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + $aos = false; |
|
| 798 | + $aos_az = false; |
|
| 799 | + $aos = false; |
|
| 800 | + $tca = false; |
|
| 801 | + $los_az = false; |
|
| 802 | + $max_el = 0; |
|
| 803 | + |
|
| 804 | + foreach ($result->details as $detail) { |
|
| 805 | + if ($detail->vis != Predict::SAT_VIS_VISIBLE) { |
|
| 806 | + continue; |
|
| 807 | + } |
|
| 808 | + if ($detail->el < $this->minEle) { |
|
| 809 | + continue; |
|
| 810 | + } |
|
| 811 | + |
|
| 812 | + if ($aos == false) { |
|
| 813 | + $aos = $detail->time; |
|
| 814 | + $aos_az = $detail->az; |
|
| 815 | + $aos_el = $detail->el; |
|
| 816 | + $tca = $detail->time; |
|
| 817 | + $los = $detail->time; |
|
| 818 | + $los_az = $detail->az; |
|
| 819 | + $los_el = $detail->el; |
|
| 820 | + $max_el = $detail->el; |
|
| 821 | + $max_el_az = $detail->el; |
|
| 822 | + continue; |
|
| 823 | + } |
|
| 824 | + $los = $detail->time; |
|
| 825 | + $los_az = $detail->az; |
|
| 826 | + $los_el = $detail->el; |
|
| 827 | + |
|
| 828 | + if ($detail->el > $max_el) { |
|
| 829 | + $tca = $detail->time; |
|
| 830 | + $max_el = $detail->el; |
|
| 831 | + $max_el_az = $detail->az; |
|
| 832 | + } |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + if ($aos === false) { |
|
| 836 | + // Does not reach minimum elevation, skip |
|
| 837 | + continue; |
|
| 838 | + } |
|
| 839 | + |
|
| 840 | + $result->visible_aos = $aos; |
|
| 841 | + $result->visible_aos_az = $aos_az; |
|
| 842 | + $result->visible_aos_el = $aos_el; |
|
| 843 | + $result->visible_tca = $tca; |
|
| 844 | + $result->visible_max_el = $max_el; |
|
| 845 | + $result->visible_max_el_az = $max_el_az; |
|
| 846 | + $result->visible_los = $los; |
|
| 847 | + $result->visible_los_az = $los_az; |
|
| 848 | + $result->visible_los_el = $los_el; |
|
| 849 | + |
|
| 850 | + $filtered[] = $result; |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + return $filtered; |
|
| 854 | + } |
|
| 855 | + |
|
| 856 | + /** |
|
| 857 | + * Translates aziumuth degrees to compass direction: |
|
| 858 | + * |
|
| 859 | + * N (0°), NNE (22.5°), NE (45°), ENE (67.5°), E (90°), ESE (112.5°), |
|
| 860 | + * SE (135°), SSE (157.5°), S (180°), SSW (202.5°), SW (225°), |
|
| 861 | + * WSW (247.5°), W (270°), WNW (292.5°), NW (315°), NNW (337.5°) |
|
| 862 | + * |
|
| 863 | + * @param int $az The azimuth in degrees, defaults to 0 |
|
| 864 | + * |
|
| 865 | + * @return string |
|
| 866 | + */ |
|
| 867 | + public function azDegreesToDirection($az = 0) |
|
| 868 | + { |
|
| 869 | + $i = floor($az / 22.5); |
|
| 870 | + $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 871 | + $i = ($az >= $m) ? $i + 1 : $i; |
|
| 872 | + |
|
| 873 | + return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 874 | + } |
|
| 875 | 875 | } |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | /* Common arguments between deep-space functions */ |
| 7 | 7 | class Predict_DeepArg |
| 8 | 8 | { |
| 9 | - /* Used by dpinit part of Deep() */ |
|
| 10 | - public $eosq; |
|
| 11 | - public $sinio; |
|
| 12 | - public $cosio; |
|
| 13 | - public $betao; |
|
| 14 | - public $aodp; |
|
| 15 | - public $theta2; |
|
| 16 | - public $sing; |
|
| 17 | - public $cosg; |
|
| 18 | - public $betao2; |
|
| 19 | - public $xmdot; |
|
| 20 | - public $omgdot; |
|
| 21 | - public $xnodot; |
|
| 22 | - public $xnodp; |
|
| 9 | + /* Used by dpinit part of Deep() */ |
|
| 10 | + public $eosq; |
|
| 11 | + public $sinio; |
|
| 12 | + public $cosio; |
|
| 13 | + public $betao; |
|
| 14 | + public $aodp; |
|
| 15 | + public $theta2; |
|
| 16 | + public $sing; |
|
| 17 | + public $cosg; |
|
| 18 | + public $betao2; |
|
| 19 | + public $xmdot; |
|
| 20 | + public $omgdot; |
|
| 21 | + public $xnodot; |
|
| 22 | + public $xnodp; |
|
| 23 | 23 | |
| 24 | - /* Used by dpsec and dpper parts of Deep() */ |
|
| 25 | - public $xll; |
|
| 26 | - public $omgadf; |
|
| 27 | - public $xnode; |
|
| 28 | - public $em; |
|
| 29 | - public $xinc; |
|
| 30 | - public $xn; |
|
| 31 | - public $t; |
|
| 24 | + /* Used by dpsec and dpper parts of Deep() */ |
|
| 25 | + public $xll; |
|
| 26 | + public $omgadf; |
|
| 27 | + public $xnode; |
|
| 28 | + public $em; |
|
| 29 | + public $xinc; |
|
| 30 | + public $xn; |
|
| 31 | + public $t; |
|
| 32 | 32 | |
| 33 | - /* Used by thetg and Deep() */ |
|
| 34 | - public $ds50; |
|
| 33 | + /* Used by thetg and Deep() */ |
|
| 34 | + public $ds50; |
|
| 35 | 35 | } |
@@ -3,16 +3,16 @@ |
||
| 3 | 3 | /** Brief satellite pass info. */ |
| 4 | 4 | class Predict_Pass |
| 5 | 5 | { |
| 6 | - public $satname; /*!< satellite name */ |
|
| 7 | - public $aos; /*!< AOS time in "jul_utc" */ |
|
| 8 | - public $tca; /*!< TCA time in "jul_utc" */ |
|
| 9 | - public $los; /*!< LOS time in "jul_utc" */ |
|
| 10 | - public $max_el; /*!< Maximum elevation during pass */ |
|
| 11 | - public $aos_az; /*!< Azimuth at AOS */ |
|
| 12 | - public $los_az; /*!< Azimuth at LOS */ |
|
| 13 | - public $orbit; /*!< Orbit number */ |
|
| 14 | - public $maxel_az; /*!< Azimuth at maximum elevation */ |
|
| 15 | - public $vis; /*!< Visibility string, e.g. VSE, -S-, V-- */ |
|
| 16 | - public $details = array(); /*!< List of pass_detail_t entries */ |
|
| 17 | - public $max_apparent_magnitude = null; /* maximum apparent magnitude, experimental */ |
|
| 6 | + public $satname; /*!< satellite name */ |
|
| 7 | + public $aos; /*!< AOS time in "jul_utc" */ |
|
| 8 | + public $tca; /*!< TCA time in "jul_utc" */ |
|
| 9 | + public $los; /*!< LOS time in "jul_utc" */ |
|
| 10 | + public $max_el; /*!< Maximum elevation during pass */ |
|
| 11 | + public $aos_az; /*!< Azimuth at AOS */ |
|
| 12 | + public $los_az; /*!< Azimuth at LOS */ |
|
| 13 | + public $orbit; /*!< Orbit number */ |
|
| 14 | + public $maxel_az; /*!< Azimuth at maximum elevation */ |
|
| 15 | + public $vis; /*!< Visibility string, e.g. VSE, -S-, V-- */ |
|
| 16 | + public $details = array(); /*!< List of pass_detail_t entries */ |
|
| 17 | + public $max_apparent_magnitude = null; /* maximum apparent magnitude, experimental */ |
|
| 18 | 18 | } |
@@ -19,178 +19,178 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class Predict_Math |
| 21 | 21 | { |
| 22 | - /* Returns sign of a float */ |
|
| 23 | - public static function Sign($arg) |
|
| 24 | - { |
|
| 25 | - if ($arg > 0 ) { |
|
| 26 | - return 1; |
|
| 27 | - } else if ($arg < 0 ) { |
|
| 28 | - return -1; |
|
| 29 | - } else { |
|
| 30 | - return 0; |
|
| 31 | - } |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /* Returns the arcsine of the argument */ |
|
| 35 | - public static function ArcSin($arg) |
|
| 36 | - { |
|
| 37 | - if (abs($arg) >= 1 ) { |
|
| 38 | - return (self::Sign($arg) * Predict::pio2); |
|
| 39 | - } else { |
|
| 40 | - return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /* Returns arccosine of rgument */ |
|
| 45 | - public static function ArcCos($arg) |
|
| 46 | - { |
|
| 47 | - return Predict::pio2 - self::ArcSin($arg); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* Adds vectors v1 and v2 together to produce v3 */ |
|
| 51 | - public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 52 | - { |
|
| 53 | - $v3->x = $v1->x + $v2->x; |
|
| 54 | - $v3->y = $v1->y + $v2->y; |
|
| 55 | - $v3->z = $v1->z + $v2->z; |
|
| 56 | - |
|
| 57 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /* Subtracts vector v2 from v1 to produce v3 */ |
|
| 61 | - public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 62 | - { |
|
| 63 | - $v3->x = $v1->x - $v2->x; |
|
| 64 | - $v3->y = $v1->y - $v2->y; |
|
| 65 | - $v3->z = $v1->z - $v2->z; |
|
| 66 | - |
|
| 67 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
|
| 71 | - public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
|
| 72 | - { |
|
| 73 | - $v2->x = $k * $v1->x; |
|
| 74 | - $v2->y = $k * $v1->y; |
|
| 75 | - $v2->z = $k * $v1->z; |
|
| 76 | - $v2->w = abs($k) * $v1->w; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /* Multiplies the vector v1 by the scalar k */ |
|
| 80 | - public static function Scale_Vector($k, Predict_Vector $v) |
|
| 81 | - { |
|
| 82 | - $v->x *= $k; |
|
| 83 | - $v->y *= $k; |
|
| 84 | - $v->z *= $k; |
|
| 85 | - |
|
| 86 | - $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /* Returns the dot product of two vectors */ |
|
| 90 | - public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
|
| 91 | - { |
|
| 92 | - return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /* Calculates the angle between vectors v1 and v2 */ |
|
| 96 | - public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
|
| 97 | - { |
|
| 98 | - $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z); |
|
| 99 | - $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z); |
|
| 100 | - return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w))); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /* Produces cross product of v1 and v2, and returns in v3 */ |
|
| 104 | - public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3) |
|
| 105 | - { |
|
| 106 | - $v3->x = $v1->y * $v2->z - $v1->z * $v2->y; |
|
| 107 | - $v3->y = $v1->z * $v2->x - $v1->x * $v2->z; |
|
| 108 | - $v3->z = $v1->x * $v2->y - $v1->y * $v2->x; |
|
| 109 | - |
|
| 110 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /* Normalizes a vector */ |
|
| 114 | - public static function Normalize(Predict_Vector $v ) |
|
| 115 | - { |
|
| 116 | - $v->x /= $v->w; |
|
| 117 | - $v->y /= $v->w; |
|
| 118 | - $v->z /= $v->w; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /* Four-quadrant arctan function */ |
|
| 122 | - public static function AcTan($sinx, $cosx) |
|
| 123 | - { |
|
| 124 | - if ($cosx == 0) { |
|
| 125 | - if ($sinx > 0) { |
|
| 126 | - return Predict::pio2; |
|
| 127 | - } else { |
|
| 128 | - return Predict::x3pio2; |
|
| 129 | - } |
|
| 130 | - } else { |
|
| 131 | - if ($cosx > 0) { |
|
| 132 | - if ($sinx > 0) { |
|
| 133 | - return atan($sinx / $cosx); |
|
| 134 | - } else { |
|
| 135 | - return Predict::twopi + atan($sinx / $cosx); |
|
| 136 | - } |
|
| 137 | - } else { |
|
| 138 | - return Predict::pi + atan($sinx / $cosx); |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /* Returns mod 2pi of argument */ |
|
| 144 | - public static function FMod2p($x) |
|
| 145 | - { |
|
| 146 | - $ret_val = $x; |
|
| 147 | - $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | - $ret_val -= $i * Predict::twopi; |
|
| 149 | - |
|
| 150 | - if ($ret_val < 0) { |
|
| 151 | - $ret_val += Predict::twopi; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - return $ret_val; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /* Returns arg1 mod arg2 */ |
|
| 158 | - public static function Modulus($arg1, $arg2) |
|
| 159 | - { |
|
| 160 | - $ret_val = $arg1; |
|
| 161 | - $i = (int) ($ret_val / $arg2); |
|
| 162 | - $ret_val -= $i * $arg2; |
|
| 163 | - |
|
| 164 | - if ($ret_val < 0) { |
|
| 165 | - $ret_val += $arg2; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - return $ret_val; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /* Returns fractional part of double argument */ |
|
| 172 | - public static function Frac($arg) |
|
| 173 | - { |
|
| 174 | - return $arg - floor($arg); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /* Converts the satellite's position and velocity */ |
|
| 178 | - /* vectors from normalised values to km and km/sec */ |
|
| 179 | - public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
|
| 180 | - { |
|
| 181 | - self::Scale_Vector(Predict::xkmper, $pos); |
|
| 182 | - self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /* Returns angle in radians from arg in degrees */ |
|
| 186 | - public static function Radians($arg) |
|
| 187 | - { |
|
| 188 | - return $arg * Predict::de2ra; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /* Returns angle in degrees from arg in rads */ |
|
| 192 | - public static function Degrees($arg) |
|
| 193 | - { |
|
| 194 | - return $arg / Predict::de2ra; |
|
| 195 | - } |
|
| 22 | + /* Returns sign of a float */ |
|
| 23 | + public static function Sign($arg) |
|
| 24 | + { |
|
| 25 | + if ($arg > 0 ) { |
|
| 26 | + return 1; |
|
| 27 | + } else if ($arg < 0 ) { |
|
| 28 | + return -1; |
|
| 29 | + } else { |
|
| 30 | + return 0; |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /* Returns the arcsine of the argument */ |
|
| 35 | + public static function ArcSin($arg) |
|
| 36 | + { |
|
| 37 | + if (abs($arg) >= 1 ) { |
|
| 38 | + return (self::Sign($arg) * Predict::pio2); |
|
| 39 | + } else { |
|
| 40 | + return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /* Returns arccosine of rgument */ |
|
| 45 | + public static function ArcCos($arg) |
|
| 46 | + { |
|
| 47 | + return Predict::pio2 - self::ArcSin($arg); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* Adds vectors v1 and v2 together to produce v3 */ |
|
| 51 | + public static function Vec_Add(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 52 | + { |
|
| 53 | + $v3->x = $v1->x + $v2->x; |
|
| 54 | + $v3->y = $v1->y + $v2->y; |
|
| 55 | + $v3->z = $v1->z + $v2->z; |
|
| 56 | + |
|
| 57 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /* Subtracts vector v2 from v1 to produce v3 */ |
|
| 61 | + public static function Vec_Sub(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 62 | + { |
|
| 63 | + $v3->x = $v1->x - $v2->x; |
|
| 64 | + $v3->y = $v1->y - $v2->y; |
|
| 65 | + $v3->z = $v1->z - $v2->z; |
|
| 66 | + |
|
| 67 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
|
| 71 | + public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
|
| 72 | + { |
|
| 73 | + $v2->x = $k * $v1->x; |
|
| 74 | + $v2->y = $k * $v1->y; |
|
| 75 | + $v2->z = $k * $v1->z; |
|
| 76 | + $v2->w = abs($k) * $v1->w; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /* Multiplies the vector v1 by the scalar k */ |
|
| 80 | + public static function Scale_Vector($k, Predict_Vector $v) |
|
| 81 | + { |
|
| 82 | + $v->x *= $k; |
|
| 83 | + $v->y *= $k; |
|
| 84 | + $v->z *= $k; |
|
| 85 | + |
|
| 86 | + $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /* Returns the dot product of two vectors */ |
|
| 90 | + public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
|
| 91 | + { |
|
| 92 | + return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /* Calculates the angle between vectors v1 and v2 */ |
|
| 96 | + public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
|
| 97 | + { |
|
| 98 | + $v1->w = sqrt($v1->x * $v1->x + $v1->y * $v1->y + $v1->z * $v1->z); |
|
| 99 | + $v2->w = sqrt($v2->x * $v2->x + $v2->y * $v2->y + $v2->z * $v2->z); |
|
| 100 | + return (self::ArcCos(self::Dot($v1, $v2) / ($v1->w * $v2->w))); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /* Produces cross product of v1 and v2, and returns in v3 */ |
|
| 104 | + public static function Cross(Predict_Vector $v1, Predict_Vector $v2 ,Predict_Vector $v3) |
|
| 105 | + { |
|
| 106 | + $v3->x = $v1->y * $v2->z - $v1->z * $v2->y; |
|
| 107 | + $v3->y = $v1->z * $v2->x - $v1->x * $v2->z; |
|
| 108 | + $v3->z = $v1->x * $v2->y - $v1->y * $v2->x; |
|
| 109 | + |
|
| 110 | + $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /* Normalizes a vector */ |
|
| 114 | + public static function Normalize(Predict_Vector $v ) |
|
| 115 | + { |
|
| 116 | + $v->x /= $v->w; |
|
| 117 | + $v->y /= $v->w; |
|
| 118 | + $v->z /= $v->w; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /* Four-quadrant arctan function */ |
|
| 122 | + public static function AcTan($sinx, $cosx) |
|
| 123 | + { |
|
| 124 | + if ($cosx == 0) { |
|
| 125 | + if ($sinx > 0) { |
|
| 126 | + return Predict::pio2; |
|
| 127 | + } else { |
|
| 128 | + return Predict::x3pio2; |
|
| 129 | + } |
|
| 130 | + } else { |
|
| 131 | + if ($cosx > 0) { |
|
| 132 | + if ($sinx > 0) { |
|
| 133 | + return atan($sinx / $cosx); |
|
| 134 | + } else { |
|
| 135 | + return Predict::twopi + atan($sinx / $cosx); |
|
| 136 | + } |
|
| 137 | + } else { |
|
| 138 | + return Predict::pi + atan($sinx / $cosx); |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /* Returns mod 2pi of argument */ |
|
| 144 | + public static function FMod2p($x) |
|
| 145 | + { |
|
| 146 | + $ret_val = $x; |
|
| 147 | + $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | + $ret_val -= $i * Predict::twopi; |
|
| 149 | + |
|
| 150 | + if ($ret_val < 0) { |
|
| 151 | + $ret_val += Predict::twopi; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + return $ret_val; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /* Returns arg1 mod arg2 */ |
|
| 158 | + public static function Modulus($arg1, $arg2) |
|
| 159 | + { |
|
| 160 | + $ret_val = $arg1; |
|
| 161 | + $i = (int) ($ret_val / $arg2); |
|
| 162 | + $ret_val -= $i * $arg2; |
|
| 163 | + |
|
| 164 | + if ($ret_val < 0) { |
|
| 165 | + $ret_val += $arg2; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + return $ret_val; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /* Returns fractional part of double argument */ |
|
| 172 | + public static function Frac($arg) |
|
| 173 | + { |
|
| 174 | + return $arg - floor($arg); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /* Converts the satellite's position and velocity */ |
|
| 178 | + /* vectors from normalised values to km and km/sec */ |
|
| 179 | + public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
|
| 180 | + { |
|
| 181 | + self::Scale_Vector(Predict::xkmper, $pos); |
|
| 182 | + self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /* Returns angle in radians from arg in degrees */ |
|
| 186 | + public static function Radians($arg) |
|
| 187 | + { |
|
| 188 | + return $arg * Predict::de2ra; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /* Returns angle in degrees from arg in rads */ |
|
| 192 | + public static function Degrees($arg) |
|
| 193 | + { |
|
| 194 | + return $arg / Predict::de2ra; |
|
| 195 | + } |
|
| 196 | 196 | } |