@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | class update_db { |
| 11 | 11 | public static $db_sqlite; |
| 12 | 12 | |
| 13 | + /** |
|
| 14 | + * @param string $file |
|
| 15 | + */ |
|
| 13 | 16 | public static function download($url, $file, $referer = '') { |
| 14 | 17 | $fp = fopen($file, 'w+'); |
| 15 | 18 | $ch = curl_init(); |
@@ -24,6 +27,9 @@ discard block |
||
| 24 | 27 | fclose($fp); |
| 25 | 28 | } |
| 26 | 29 | |
| 30 | + /** |
|
| 31 | + * @param string $in_file |
|
| 32 | + */ |
|
| 27 | 33 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 34 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 35 | $buffer_size = 4096; // read 4kb at a time |
@@ -45,6 +51,9 @@ discard block |
||
| 45 | 51 | } |
| 46 | 52 | } |
| 47 | 53 | |
| 54 | + /** |
|
| 55 | + * @param string $in_file |
|
| 56 | + */ |
|
| 48 | 57 | public static function unzip($in_file) { |
| 49 | 58 | if ($in_file != '' && file_exists($in_file)) { |
| 50 | 59 | $path = pathinfo(realpath($in_file), PATHINFO_DIRNAME); |
@@ -66,6 +75,9 @@ discard block |
||
| 66 | 75 | } |
| 67 | 76 | } |
| 68 | 77 | |
| 78 | + /** |
|
| 79 | + * @param string $database_file |
|
| 80 | + */ |
|
| 69 | 81 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 82 | global $globalDebug, $globalTransaction; |
| 71 | 83 | //$query = 'TRUNCATE TABLE routes'; |
@@ -108,6 +120,10 @@ discard block |
||
| 108 | 120 | } |
| 109 | 121 | return ''; |
| 110 | 122 | } |
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * @param string $database_file |
|
| 126 | + */ |
|
| 111 | 127 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 128 | global $globalDebug, $globalTransaction; |
| 113 | 129 | //$query = 'TRUNCATE TABLE routes'; |
@@ -147,6 +163,9 @@ discard block |
||
| 147 | 163 | return ''; |
| 148 | 164 | } |
| 149 | 165 | |
| 166 | + /** |
|
| 167 | + * @param string $database_file |
|
| 168 | + */ |
|
| 150 | 169 | public static function retrieve_route_skyteam($database_file) { |
| 151 | 170 | global $globalDebug, $globalTransaction; |
| 152 | 171 | //$query = 'TRUNCATE TABLE routes'; |
@@ -186,6 +205,10 @@ discard block |
||
| 186 | 205 | } |
| 187 | 206 | return ''; |
| 188 | 207 | } |
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param string $database_file |
|
| 211 | + */ |
|
| 189 | 212 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 190 | 213 | global $globalTransaction; |
| 191 | 214 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -251,6 +274,9 @@ discard block |
||
| 251 | 274 | return ''; |
| 252 | 275 | } |
| 253 | 276 | |
| 277 | + /** |
|
| 278 | + * @param string $database_file |
|
| 279 | + */ |
|
| 254 | 280 | public static function retrieve_modes_flarmnet($database_file) { |
| 255 | 281 | global $globalTransaction; |
| 256 | 282 | $Common = new Common(); |
@@ -321,6 +347,9 @@ discard block |
||
| 321 | 347 | return ''; |
| 322 | 348 | } |
| 323 | 349 | |
| 350 | + /** |
|
| 351 | + * @param string $database_file |
|
| 352 | + */ |
|
| 324 | 353 | public static function retrieve_modes_ogn($database_file) { |
| 325 | 354 | global $globalTransaction; |
| 326 | 355 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -389,6 +418,9 @@ discard block |
||
| 389 | 418 | return ''; |
| 390 | 419 | } |
| 391 | 420 | |
| 421 | + /** |
|
| 422 | + * @param string $database_file |
|
| 423 | + */ |
|
| 392 | 424 | public static function retrieve_owner($database_file,$country = 'F') { |
| 393 | 425 | global $globalTransaction; |
| 394 | 426 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
@@ -939,6 +971,10 @@ discard block |
||
| 939 | 971 | return ''; |
| 940 | 972 | } |
| 941 | 973 | |
| 974 | + /** |
|
| 975 | + * @param string $filename |
|
| 976 | + * @param string $tletype |
|
| 977 | + */ |
|
| 942 | 978 | public static function tle($filename,$tletype) { |
| 943 | 979 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 944 | 980 | global $tmp_dir, $globalTransaction; |
@@ -1071,6 +1107,9 @@ discard block |
||
| 1071 | 1107 | |
| 1072 | 1108 | } |
| 1073 | 1109 | */ |
| 1110 | + /** |
|
| 1111 | + * @param string $filename |
|
| 1112 | + */ |
|
| 1074 | 1113 | public static function waypoints($filename) { |
| 1075 | 1114 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1076 | 1115 | global $tmp_dir, $globalTransaction; |
@@ -1118,6 +1157,9 @@ discard block |
||
| 1118 | 1157 | return ''; |
| 1119 | 1158 | } |
| 1120 | 1159 | |
| 1160 | + /** |
|
| 1161 | + * @param string $filename |
|
| 1162 | + */ |
|
| 1121 | 1163 | public static function ivao_airlines($filename) { |
| 1122 | 1164 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 1123 | 1165 | global $tmp_dir, $globalTransaction; |
@@ -75,38 +75,38 @@ discard block |
||
| 75 | 75 | try { |
| 76 | 76 | //$Connection = new Connection(); |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | - $sth->execute(array(':source' => $database_file)); |
|
| 79 | - } catch(PDOException $e) { |
|
| 80 | - return "error : ".$e->getMessage(); |
|
| 81 | - } |
|
| 78 | + $sth->execute(array(':source' => $database_file)); |
|
| 79 | + } catch(PDOException $e) { |
|
| 80 | + return "error : ".$e->getMessage(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 84 | - update_db::connect_sqlite($database_file); |
|
| 83 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 84 | + update_db::connect_sqlite($database_file); |
|
| 85 | 85 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 86 | 86 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
| 87 | 87 | try { |
| 88 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 89 | - $sth->execute(); |
|
| 90 | - } catch(PDOException $e) { |
|
| 91 | - return "error : ".$e->getMessage(); |
|
| 92 | - } |
|
| 88 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 89 | + $sth->execute(); |
|
| 90 | + } catch(PDOException $e) { |
|
| 91 | + return "error : ".$e->getMessage(); |
|
| 92 | + } |
|
| 93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 94 | 94 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,ToAirport_ICAO,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
| 95 | 95 | $Connection = new Connection(); |
| 96 | 96 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 97 | try { |
| 98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 99 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 99 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | 101 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 102 | $sth_dest->execute($query_dest_values); |
| 103 | - } |
|
| 103 | + } |
|
| 104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
| 105 | 105 | } catch(PDOException $e) { |
| 106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
| 109 | - return ''; |
|
| 109 | + return ''; |
|
| 110 | 110 | } |
| 111 | 111 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 112 | global $globalDebug, $globalTransaction; |
@@ -117,12 +117,12 @@ discard block |
||
| 117 | 117 | try { |
| 118 | 118 | //$Connection = new Connection(); |
| 119 | 119 | $sth = $Connection->db->prepare($query); |
| 120 | - $sth->execute(array(':source' => 'oneworld')); |
|
| 121 | - } catch(PDOException $e) { |
|
| 122 | - return "error : ".$e->getMessage(); |
|
| 123 | - } |
|
| 120 | + $sth->execute(array(':source' => 'oneworld')); |
|
| 121 | + } catch(PDOException $e) { |
|
| 122 | + return "error : ".$e->getMessage(); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 125 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 127 | $Spotter = new Spotter(); |
| 128 | 128 | if ($fh = fopen($database_file,"r")) { |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | if ($globalTransaction) $Connection->db->commit(); |
| 148 | 148 | } |
| 149 | - return ''; |
|
| 149 | + return ''; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | public static function retrieve_route_skyteam($database_file) { |
@@ -158,12 +158,12 @@ discard block |
||
| 158 | 158 | try { |
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $sth = $Connection->db->prepare($query); |
| 161 | - $sth->execute(array(':source' => 'skyteam')); |
|
| 162 | - } catch(PDOException $e) { |
|
| 163 | - return "error : ".$e->getMessage(); |
|
| 164 | - } |
|
| 161 | + $sth->execute(array(':source' => 'skyteam')); |
|
| 162 | + } catch(PDOException $e) { |
|
| 163 | + return "error : ".$e->getMessage(); |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 166 | + if ($globalDebug) echo " - Add routes to DB -"; |
|
| 167 | 167 | |
| 168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 169 | $Spotter = new Spotter(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - return ''; |
|
| 192 | + return ''; |
|
| 193 | 193 | } |
| 194 | 194 | public static function retrieve_modes_sqlite_to_dest($database_file) { |
| 195 | 195 | global $globalTransaction; |
@@ -198,27 +198,27 @@ discard block |
||
| 198 | 198 | try { |
| 199 | 199 | $Connection = new Connection(); |
| 200 | 200 | $sth = $Connection->db->prepare($query); |
| 201 | - $sth->execute(array(':source' => $database_file)); |
|
| 202 | - } catch(PDOException $e) { |
|
| 203 | - return "error : ".$e->getMessage(); |
|
| 204 | - } |
|
| 201 | + $sth->execute(array(':source' => $database_file)); |
|
| 202 | + } catch(PDOException $e) { |
|
| 203 | + return "error : ".$e->getMessage(); |
|
| 204 | + } |
|
| 205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
| 206 | 206 | try { |
| 207 | 207 | $Connection = new Connection(); |
| 208 | 208 | $sth = $Connection->db->prepare($query); |
| 209 | - $sth->execute(array(':source' => $database_file)); |
|
| 210 | - } catch(PDOException $e) { |
|
| 211 | - return "error : ".$e->getMessage(); |
|
| 212 | - } |
|
| 209 | + $sth->execute(array(':source' => $database_file)); |
|
| 210 | + } catch(PDOException $e) { |
|
| 211 | + return "error : ".$e->getMessage(); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - update_db::connect_sqlite($database_file); |
|
| 214 | + update_db::connect_sqlite($database_file); |
|
| 215 | 215 | $query = 'select * from Aircraft'; |
| 216 | 216 | try { |
| 217 | - $sth = update_db::$db_sqlite->prepare($query); |
|
| 218 | - $sth->execute(); |
|
| 219 | - } catch(PDOException $e) { |
|
| 220 | - return "error : ".$e->getMessage(); |
|
| 221 | - } |
|
| 217 | + $sth = update_db::$db_sqlite->prepare($query); |
|
| 218 | + $sth->execute(); |
|
| 219 | + } catch(PDOException $e) { |
|
| 220 | + return "error : ".$e->getMessage(); |
|
| 221 | + } |
|
| 222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 223 | 223 | $query_dest = 'INSERT INTO aircraft_modes (LastModified, ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type,:source)'; |
| 224 | 224 | |
@@ -229,17 +229,17 @@ discard block |
||
| 229 | 229 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 230 | try { |
| 231 | 231 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 232 | - while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 232 | + while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
|
| 233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 235 | 235 | else $type = null; |
| 236 | 236 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 237 | 237 | $sth_dest->execute($query_dest_values); |
| 238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 240 | - $sth_dest_owner->execute($query_dest_owner_values); |
|
| 239 | + $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 240 | + $sth_dest_owner->execute($query_dest_owner_values); |
|
| 241 | 241 | } |
| 242 | - } |
|
| 242 | + } |
|
| 243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
| 244 | 244 | } catch(PDOException $e) { |
| 245 | 245 | return "error : ".$e->getMessage(); |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | try { |
| 250 | 250 | $Connection = new Connection(); |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | - $sth->execute(array(':source' => $database_file)); |
|
| 253 | - } catch(PDOException $e) { |
|
| 254 | - return "error : ".$e->getMessage(); |
|
| 255 | - } |
|
| 252 | + $sth->execute(array(':source' => $database_file)); |
|
| 253 | + } catch(PDOException $e) { |
|
| 254 | + return "error : ".$e->getMessage(); |
|
| 255 | + } |
|
| 256 | 256 | return ''; |
| 257 | 257 | } |
| 258 | 258 | |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | try { |
| 265 | 265 | $Connection = new Connection(); |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | - $sth->execute(array(':source' => $database_file)); |
|
| 268 | - } catch(PDOException $e) { |
|
| 269 | - return "error : ".$e->getMessage(); |
|
| 270 | - } |
|
| 267 | + $sth->execute(array(':source' => $database_file)); |
|
| 268 | + } catch(PDOException $e) { |
|
| 269 | + return "error : ".$e->getMessage(); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | 272 | if ($fh = fopen($database_file,"r")) { |
| 273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -277,26 +277,26 @@ discard block |
||
| 277 | 277 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 278 | try { |
| 279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 280 | - while (!feof($fh)) { |
|
| 281 | - $values = array(); |
|
| 282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 280 | + while (!feof($fh)) { |
|
| 281 | + $values = array(); |
|
| 282 | + $line = $Common->hex2str(fgets($fh,9999)); |
|
| 283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 284 | - $values['ModeS'] = substr($line,0,6); |
|
| 285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 287 | - // Check if we can find ICAO, else set it to GLID |
|
| 288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 289 | - $search_more = ''; |
|
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 291 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 292 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 284 | + $values['ModeS'] = substr($line,0,6); |
|
| 285 | + $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | + $aircraft_name = trim(substr($line,48,6)); |
|
| 287 | + // Check if we can find ICAO, else set it to GLID |
|
| 288 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 289 | + $search_more = ''; |
|
| 290 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 291 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 292 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 293 | 293 | try { |
| 294 | - $sth_search->execute(); |
|
| 295 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 296 | - //if (count($result) > 0) { |
|
| 297 | - if (isset($result['icao']) && $result['icao'] != '') { |
|
| 298 | - $values['ICAOTypeCode'] = $result['icao']; |
|
| 299 | - } |
|
| 294 | + $sth_search->execute(); |
|
| 295 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 296 | + //if (count($result) > 0) { |
|
| 297 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 298 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 299 | + } |
|
| 300 | 300 | } catch(PDOException $e) { |
| 301 | 301 | return "error : ".$e->getMessage(); |
| 302 | 302 | } |
@@ -319,10 +319,10 @@ discard block |
||
| 319 | 319 | try { |
| 320 | 320 | $Connection = new Connection(); |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | - $sth->execute(array(':source' => $database_file)); |
|
| 323 | - } catch(PDOException $e) { |
|
| 324 | - return "error : ".$e->getMessage(); |
|
| 325 | - } |
|
| 322 | + $sth->execute(array(':source' => $database_file)); |
|
| 323 | + } catch(PDOException $e) { |
|
| 324 | + return "error : ".$e->getMessage(); |
|
| 325 | + } |
|
| 326 | 326 | return ''; |
| 327 | 327 | } |
| 328 | 328 | |
@@ -333,10 +333,10 @@ discard block |
||
| 333 | 333 | try { |
| 334 | 334 | $Connection = new Connection(); |
| 335 | 335 | $sth = $Connection->db->prepare($query); |
| 336 | - $sth->execute(array(':source' => $database_file)); |
|
| 337 | - } catch(PDOException $e) { |
|
| 338 | - return "error : ".$e->getMessage(); |
|
| 339 | - } |
|
| 336 | + $sth->execute(array(':source' => $database_file)); |
|
| 337 | + } catch(PDOException $e) { |
|
| 338 | + return "error : ".$e->getMessage(); |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | if ($fh = fopen($database_file,"r")) { |
| 342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -347,24 +347,24 @@ discard block |
||
| 347 | 347 | try { |
| 348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 349 | 349 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | - while (!feof($fh)) { |
|
| 351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 350 | + while (!feof($fh)) { |
|
| 351 | + $line = fgetcsv($fh,9999,',',"'"); |
|
| 352 | 352 | |
| 353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 354 | 354 | //print_r($line); |
| 355 | - $values['ModeS'] = $line[1]; |
|
| 356 | - $values['Registration'] = $line[3]; |
|
| 357 | - $aircraft_name = $line[2]; |
|
| 358 | - // Check if we can find ICAO, else set it to GLID |
|
| 359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 360 | - $search_more = ''; |
|
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 362 | - $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 363 | - $sth_search = $Connection->db->prepare($query_search); |
|
| 355 | + $values['ModeS'] = $line[1]; |
|
| 356 | + $values['Registration'] = $line[3]; |
|
| 357 | + $aircraft_name = $line[2]; |
|
| 358 | + // Check if we can find ICAO, else set it to GLID |
|
| 359 | + $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 360 | + $search_more = ''; |
|
| 361 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 362 | + $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
|
| 363 | + $sth_search = $Connection->db->prepare($query_search); |
|
| 364 | 364 | try { |
| 365 | - $sth_search->execute(); |
|
| 366 | - $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 365 | + $sth_search->execute(); |
|
| 366 | + $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
|
| 367 | + if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 368 | 368 | } catch(PDOException $e) { |
| 369 | 369 | return "error : ".$e->getMessage(); |
| 370 | 370 | } |
@@ -387,10 +387,10 @@ discard block |
||
| 387 | 387 | try { |
| 388 | 388 | $Connection = new Connection(); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | - $sth->execute(array(':source' => $database_file)); |
|
| 391 | - } catch(PDOException $e) { |
|
| 392 | - return "error : ".$e->getMessage(); |
|
| 393 | - } |
|
| 390 | + $sth->execute(array(':source' => $database_file)); |
|
| 391 | + } catch(PDOException $e) { |
|
| 392 | + return "error : ".$e->getMessage(); |
|
| 393 | + } |
|
| 394 | 394 | return ''; |
| 395 | 395 | } |
| 396 | 396 | |
@@ -401,10 +401,10 @@ discard block |
||
| 401 | 401 | try { |
| 402 | 402 | $Connection = new Connection(); |
| 403 | 403 | $sth = $Connection->db->prepare($query); |
| 404 | - $sth->execute(array(':source' => $database_file)); |
|
| 405 | - } catch(PDOException $e) { |
|
| 406 | - return "error : ".$e->getMessage(); |
|
| 407 | - } |
|
| 404 | + $sth->execute(array(':source' => $database_file)); |
|
| 405 | + } catch(PDOException $e) { |
|
| 406 | + return "error : ".$e->getMessage(); |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | 409 | if ($fh = fopen($database_file,"r")) { |
| 410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -415,95 +415,95 @@ discard block |
||
| 415 | 415 | try { |
| 416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 417 | 417 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | - while (!feof($fh)) { |
|
| 419 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 420 | - $values = array(); |
|
| 421 | - //print_r($line); |
|
| 422 | - if ($country == 'F') { |
|
| 423 | - $values['registration'] = $line[0]; |
|
| 424 | - $values['base'] = $line[4]; |
|
| 425 | - $values['owner'] = $line[5]; |
|
| 426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 428 | - $values['cancel'] = $line[7]; |
|
| 418 | + while (!feof($fh)) { |
|
| 419 | + $line = fgetcsv($fh,9999,',','"'); |
|
| 420 | + $values = array(); |
|
| 421 | + //print_r($line); |
|
| 422 | + if ($country == 'F') { |
|
| 423 | + $values['registration'] = $line[0]; |
|
| 424 | + $values['base'] = $line[4]; |
|
| 425 | + $values['owner'] = $line[5]; |
|
| 426 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 428 | + $values['cancel'] = $line[7]; |
|
| 429 | 429 | } elseif ($country == 'EI') { |
| 430 | - // TODO : add modeS & reg to aircraft_modes |
|
| 431 | - $values['registration'] = $line[0]; |
|
| 432 | - $values['base'] = $line[3]; |
|
| 433 | - $values['owner'] = $line[2]; |
|
| 434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 436 | - $values['cancel'] = ''; |
|
| 430 | + // TODO : add modeS & reg to aircraft_modes |
|
| 431 | + $values['registration'] = $line[0]; |
|
| 432 | + $values['base'] = $line[3]; |
|
| 433 | + $values['owner'] = $line[2]; |
|
| 434 | + if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 436 | + $values['cancel'] = ''; |
|
| 437 | 437 | } elseif ($country == 'HB') { |
| 438 | - // TODO : add modeS & reg to aircraft_modes |
|
| 439 | - $values['registration'] = $line[0]; |
|
| 440 | - $values['base'] = null; |
|
| 441 | - $values['owner'] = $line[5]; |
|
| 442 | - $values['date_first_reg'] = null; |
|
| 443 | - $values['cancel'] = ''; |
|
| 438 | + // TODO : add modeS & reg to aircraft_modes |
|
| 439 | + $values['registration'] = $line[0]; |
|
| 440 | + $values['base'] = null; |
|
| 441 | + $values['owner'] = $line[5]; |
|
| 442 | + $values['date_first_reg'] = null; |
|
| 443 | + $values['cancel'] = ''; |
|
| 444 | 444 | } elseif ($country == 'OK') { |
| 445 | - // TODO : add modeS & reg to aircraft_modes |
|
| 446 | - $values['registration'] = $line[3]; |
|
| 447 | - $values['base'] = null; |
|
| 448 | - $values['owner'] = $line[5]; |
|
| 449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 451 | - $values['cancel'] = ''; |
|
| 445 | + // TODO : add modeS & reg to aircraft_modes |
|
| 446 | + $values['registration'] = $line[3]; |
|
| 447 | + $values['base'] = null; |
|
| 448 | + $values['owner'] = $line[5]; |
|
| 449 | + if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 451 | + $values['cancel'] = ''; |
|
| 452 | 452 | } elseif ($country == 'VH') { |
| 453 | - // TODO : add modeS & reg to aircraft_modes |
|
| 454 | - $values['registration'] = $line[0]; |
|
| 455 | - $values['base'] = null; |
|
| 456 | - $values['owner'] = $line[12]; |
|
| 457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 459 | - |
|
| 460 | - $values['cancel'] = $line[39]; |
|
| 453 | + // TODO : add modeS & reg to aircraft_modes |
|
| 454 | + $values['registration'] = $line[0]; |
|
| 455 | + $values['base'] = null; |
|
| 456 | + $values['owner'] = $line[12]; |
|
| 457 | + if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 459 | + |
|
| 460 | + $values['cancel'] = $line[39]; |
|
| 461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
| 462 | - $values['registration'] = $line[0]; |
|
| 463 | - $values['base'] = null; |
|
| 464 | - $values['owner'] = $line[4]; |
|
| 465 | - $values['date_first_reg'] = null; |
|
| 466 | - $values['cancel'] = ''; |
|
| 462 | + $values['registration'] = $line[0]; |
|
| 463 | + $values['base'] = null; |
|
| 464 | + $values['owner'] = $line[4]; |
|
| 465 | + $values['date_first_reg'] = null; |
|
| 466 | + $values['cancel'] = ''; |
|
| 467 | 467 | } elseif ($country == 'CC') { |
| 468 | - $values['registration'] = $line[0]; |
|
| 469 | - $values['base'] = null; |
|
| 470 | - $values['owner'] = $line[6]; |
|
| 471 | - $values['date_first_reg'] = null; |
|
| 472 | - $values['cancel'] = ''; |
|
| 468 | + $values['registration'] = $line[0]; |
|
| 469 | + $values['base'] = null; |
|
| 470 | + $values['owner'] = $line[6]; |
|
| 471 | + $values['date_first_reg'] = null; |
|
| 472 | + $values['cancel'] = ''; |
|
| 473 | 473 | } elseif ($country == 'HJ') { |
| 474 | - $values['registration'] = $line[0]; |
|
| 475 | - $values['base'] = null; |
|
| 476 | - $values['owner'] = $line[8]; |
|
| 477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 479 | - $values['cancel'] = ''; |
|
| 474 | + $values['registration'] = $line[0]; |
|
| 475 | + $values['base'] = null; |
|
| 476 | + $values['owner'] = $line[8]; |
|
| 477 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 479 | + $values['cancel'] = ''; |
|
| 480 | 480 | } elseif ($country == 'PP') { |
| 481 | - $values['registration'] = $line[0]; |
|
| 482 | - $values['base'] = null; |
|
| 483 | - $values['owner'] = $line[4]; |
|
| 484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 486 | - $values['cancel'] = $line[7]; |
|
| 481 | + $values['registration'] = $line[0]; |
|
| 482 | + $values['base'] = null; |
|
| 483 | + $values['owner'] = $line[4]; |
|
| 484 | + if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 486 | + $values['cancel'] = $line[7]; |
|
| 487 | 487 | } elseif ($country == 'E7') { |
| 488 | - $values['registration'] = $line[0]; |
|
| 489 | - $values['base'] = null; |
|
| 490 | - $values['owner'] = $line[4]; |
|
| 491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 493 | - $values['cancel'] = ''; |
|
| 488 | + $values['registration'] = $line[0]; |
|
| 489 | + $values['base'] = null; |
|
| 490 | + $values['owner'] = $line[4]; |
|
| 491 | + if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 493 | + $values['cancel'] = ''; |
|
| 494 | 494 | } elseif ($country == '8Q') { |
| 495 | - $values['registration'] = $line[0]; |
|
| 496 | - $values['base'] = null; |
|
| 497 | - $values['owner'] = $line[3]; |
|
| 498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 500 | - $values['cancel'] = ''; |
|
| 495 | + $values['registration'] = $line[0]; |
|
| 496 | + $values['base'] = null; |
|
| 497 | + $values['owner'] = $line[3]; |
|
| 498 | + if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | + else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 500 | + $values['cancel'] = ''; |
|
| 501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | - $values['registration'] = $line[0]; |
|
| 503 | - $values['base'] = null; |
|
| 504 | - $values['owner'] = $line[3]; |
|
| 505 | - $values['date_first_reg'] = null; |
|
| 506 | - $values['cancel'] = ''; |
|
| 502 | + $values['registration'] = $line[0]; |
|
| 503 | + $values['base'] = null; |
|
| 504 | + $values['owner'] = $line[3]; |
|
| 505 | + $values['date_first_reg'] = null; |
|
| 506 | + $values['cancel'] = ''; |
|
| 507 | 507 | } |
| 508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 509 | 509 | $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
@@ -625,20 +625,20 @@ discard block |
||
| 625 | 625 | try { |
| 626 | 626 | $Connection = new Connection(); |
| 627 | 627 | $sth = $Connection->db->prepare($query); |
| 628 | - $sth->execute(); |
|
| 629 | - } catch(PDOException $e) { |
|
| 630 | - return "error : ".$e->getMessage(); |
|
| 631 | - } |
|
| 628 | + $sth->execute(); |
|
| 629 | + } catch(PDOException $e) { |
|
| 630 | + return "error : ".$e->getMessage(); |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | |
| 634 | 634 | $query = 'ALTER TABLE airport DROP INDEX icaoidx'; |
| 635 | 635 | try { |
| 636 | 636 | $Connection = new Connection(); |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | - $sth->execute(); |
|
| 639 | - } catch(PDOException $e) { |
|
| 640 | - return "error : ".$e->getMessage(); |
|
| 641 | - } |
|
| 638 | + $sth->execute(); |
|
| 639 | + } catch(PDOException $e) { |
|
| 640 | + return "error : ".$e->getMessage(); |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | 643 | $query_dest = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image_thumb`,`image`) |
| 644 | 644 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
@@ -704,10 +704,10 @@ discard block |
||
| 704 | 704 | try { |
| 705 | 705 | $Connection = new Connection(); |
| 706 | 706 | $sth = $Connection->db->prepare($query); |
| 707 | - $sth->execute(); |
|
| 708 | - } catch(PDOException $e) { |
|
| 709 | - return "error : ".$e->getMessage(); |
|
| 710 | - } |
|
| 707 | + $sth->execute(); |
|
| 708 | + } catch(PDOException $e) { |
|
| 709 | + return "error : ".$e->getMessage(); |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | 712 | |
| 713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
@@ -717,10 +717,10 @@ discard block |
||
| 717 | 717 | try { |
| 718 | 718 | $Connection = new Connection(); |
| 719 | 719 | $sth = $Connection->db->prepare($query); |
| 720 | - $sth->execute($query_values); |
|
| 721 | - } catch(PDOException $e) { |
|
| 722 | - return "error : ".$e->getMessage(); |
|
| 723 | - } |
|
| 720 | + $sth->execute($query_values); |
|
| 721 | + } catch(PDOException $e) { |
|
| 722 | + return "error : ".$e->getMessage(); |
|
| 723 | + } |
|
| 724 | 724 | $i++; |
| 725 | 725 | /* |
| 726 | 726 | $query = 'DELETE FROM airport WHERE airport_id IN (SELECT * FROM (SELECT min(a.airport_id) FROM airport a GROUP BY a.icao) x)'; |
@@ -834,7 +834,7 @@ discard block |
||
| 834 | 834 | |
| 835 | 835 | |
| 836 | 836 | |
| 837 | - return "success"; |
|
| 837 | + return "success"; |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | public static function translation() { |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | try { |
| 851 | 851 | $Connection = new Connection(); |
| 852 | 852 | $sth = $Connection->db->prepare($query); |
| 853 | - $sth->execute(array(':source' => 'translation.csv')); |
|
| 854 | - } catch(PDOException $e) { |
|
| 855 | - return "error : ".$e->getMessage(); |
|
| 856 | - } |
|
| 853 | + $sth->execute(array(':source' => 'translation.csv')); |
|
| 854 | + } catch(PDOException $e) { |
|
| 855 | + return "error : ".$e->getMessage(); |
|
| 856 | + } |
|
| 857 | 857 | |
| 858 | 858 | |
| 859 | 859 | //update_db::unzip($out_file); |
@@ -872,21 +872,21 @@ discard block |
||
| 872 | 872 | $data = $row; |
| 873 | 873 | $operator = $data[2]; |
| 874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
| 875 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 876 | - //echo substr($operator, 0, 2)."\n";; |
|
| 877 | - if (count($airline_array) > 0) { |
|
| 875 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator, 0, 2)); |
|
| 876 | + //echo substr($operator, 0, 2)."\n";; |
|
| 877 | + if (count($airline_array) > 0) { |
|
| 878 | 878 | //print_r($airline_array); |
| 879 | 879 | $operator = $airline_array[0]['icao'].substr($operator,2); |
| 880 | - } |
|
| 881 | - } |
|
| 880 | + } |
|
| 881 | + } |
|
| 882 | 882 | |
| 883 | 883 | $operator_correct = $data[3]; |
| 884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 885 | - $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 886 | - if (count($airline_array) > 0) { |
|
| 887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 888 | - } |
|
| 889 | - } |
|
| 885 | + $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
|
| 886 | + if (count($airline_array) > 0) { |
|
| 887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 888 | + } |
|
| 889 | + } |
|
| 890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 891 | 891 | try { |
| 892 | 892 | $sth = $Connection->db->prepare($query); |
@@ -900,7 +900,7 @@ discard block |
||
| 900 | 900 | //$Connection->db->commit(); |
| 901 | 901 | } |
| 902 | 902 | return ''; |
| 903 | - } |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | 905 | public static function translation_fam() { |
| 906 | 906 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -910,10 +910,10 @@ discard block |
||
| 910 | 910 | try { |
| 911 | 911 | $Connection = new Connection(); |
| 912 | 912 | $sth = $Connection->db->prepare($query); |
| 913 | - $sth->execute(array(':source' => 'website_fam')); |
|
| 914 | - } catch(PDOException $e) { |
|
| 915 | - return "error : ".$e->getMessage(); |
|
| 916 | - } |
|
| 913 | + $sth->execute(array(':source' => 'website_fam')); |
|
| 914 | + } catch(PDOException $e) { |
|
| 915 | + return "error : ".$e->getMessage(); |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | //update_db::unzip($out_file); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | //$Connection->db->commit(); |
| 943 | 943 | } |
| 944 | 944 | return ''; |
| 945 | - } |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | 947 | public static function tle($filename,$tletype) { |
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -953,10 +953,10 @@ discard block |
||
| 953 | 953 | try { |
| 954 | 954 | $Connection = new Connection(); |
| 955 | 955 | $sth = $Connection->db->prepare($query); |
| 956 | - $sth->execute(array(':source' => $filename)); |
|
| 957 | - } catch(PDOException $e) { |
|
| 958 | - return "error : ".$e->getMessage(); |
|
| 959 | - } |
|
| 956 | + $sth->execute(array(':source' => $filename)); |
|
| 957 | + } catch(PDOException $e) { |
|
| 958 | + return "error : ".$e->getMessage(); |
|
| 959 | + } |
|
| 960 | 960 | |
| 961 | 961 | $Connection = new Connection(); |
| 962 | 962 | if (($handle = fopen($filename, 'r')) !== FALSE) |
@@ -991,54 +991,54 @@ discard block |
||
| 991 | 991 | //$Connection->db->commit(); |
| 992 | 992 | } |
| 993 | 993 | return ''; |
| 994 | - } |
|
| 994 | + } |
|
| 995 | 995 | |
| 996 | 996 | /** |
| 997 | - * Convert a HTML table to an array |
|
| 998 | - * @param String $data HTML page |
|
| 999 | - * @return Array array of the tables in HTML page |
|
| 1000 | - */ |
|
| 1001 | - private static function table2array($data) { |
|
| 1002 | - $html = str_get_html($data); |
|
| 1003 | - $tabledata=array(); |
|
| 1004 | - foreach($html->find('tr') as $element) |
|
| 1005 | - { |
|
| 1006 | - $td = array(); |
|
| 1007 | - foreach( $element->find('th') as $row) |
|
| 1008 | - { |
|
| 1009 | - $td [] = trim($row->plaintext); |
|
| 1010 | - } |
|
| 1011 | - $td=array_filter($td); |
|
| 1012 | - $tabledata[] = $td; |
|
| 1013 | - |
|
| 1014 | - $td = array(); |
|
| 1015 | - $tdi = array(); |
|
| 1016 | - foreach( $element->find('td') as $row) |
|
| 1017 | - { |
|
| 1018 | - $td [] = trim($row->plaintext); |
|
| 1019 | - $tdi [] = trim($row->innertext); |
|
| 1020 | - } |
|
| 1021 | - $td=array_filter($td); |
|
| 1022 | - $tdi=array_filter($tdi); |
|
| 1023 | - // $tabledata[]=array_merge($td,$tdi); |
|
| 1024 | - $tabledata[]=$td; |
|
| 1025 | - } |
|
| 1026 | - return(array_filter($tabledata)); |
|
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - /** |
|
| 1030 | - * Get data from form result |
|
| 1031 | - * @param String $url form URL |
|
| 1032 | - * @return String the result |
|
| 1033 | - */ |
|
| 1034 | - private static function getData($url) { |
|
| 1035 | - $ch = curl_init(); |
|
| 1036 | - curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1037 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1038 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1039 | - curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
| 1040 | - return curl_exec($ch); |
|
| 1041 | - } |
|
| 997 | + * Convert a HTML table to an array |
|
| 998 | + * @param String $data HTML page |
|
| 999 | + * @return Array array of the tables in HTML page |
|
| 1000 | + */ |
|
| 1001 | + private static function table2array($data) { |
|
| 1002 | + $html = str_get_html($data); |
|
| 1003 | + $tabledata=array(); |
|
| 1004 | + foreach($html->find('tr') as $element) |
|
| 1005 | + { |
|
| 1006 | + $td = array(); |
|
| 1007 | + foreach( $element->find('th') as $row) |
|
| 1008 | + { |
|
| 1009 | + $td [] = trim($row->plaintext); |
|
| 1010 | + } |
|
| 1011 | + $td=array_filter($td); |
|
| 1012 | + $tabledata[] = $td; |
|
| 1013 | + |
|
| 1014 | + $td = array(); |
|
| 1015 | + $tdi = array(); |
|
| 1016 | + foreach( $element->find('td') as $row) |
|
| 1017 | + { |
|
| 1018 | + $td [] = trim($row->plaintext); |
|
| 1019 | + $tdi [] = trim($row->innertext); |
|
| 1020 | + } |
|
| 1021 | + $td=array_filter($td); |
|
| 1022 | + $tdi=array_filter($tdi); |
|
| 1023 | + // $tabledata[]=array_merge($td,$tdi); |
|
| 1024 | + $tabledata[]=$td; |
|
| 1025 | + } |
|
| 1026 | + return(array_filter($tabledata)); |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + /** |
|
| 1030 | + * Get data from form result |
|
| 1031 | + * @param String $url form URL |
|
| 1032 | + * @return String the result |
|
| 1033 | + */ |
|
| 1034 | + private static function getData($url) { |
|
| 1035 | + $ch = curl_init(); |
|
| 1036 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 1037 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
|
| 1038 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
|
| 1039 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
|
| 1040 | + return curl_exec($ch); |
|
| 1041 | + } |
|
| 1042 | 1042 | /* |
| 1043 | 1043 | public static function waypoints() { |
| 1044 | 1044 | $data = update_db::getData('http://www.fallingrain.com/world/FR/waypoints.html'); |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | if ($globalTransaction) $Connection->db->commit(); |
| 1122 | 1122 | } |
| 1123 | 1123 | return ''; |
| 1124 | - } |
|
| 1124 | + } |
|
| 1125 | 1125 | |
| 1126 | 1126 | public static function ivao_airlines($filename) { |
| 1127 | 1127 | //require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
@@ -1131,10 +1131,10 @@ discard block |
||
| 1131 | 1131 | try { |
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $sth = $Connection->db->prepare($query); |
| 1134 | - $sth->execute(); |
|
| 1135 | - } catch(PDOException $e) { |
|
| 1136 | - return "error : ".$e->getMessage(); |
|
| 1137 | - } |
|
| 1134 | + $sth->execute(); |
|
| 1135 | + } catch(PDOException $e) { |
|
| 1136 | + return "error : ".$e->getMessage(); |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | 1139 | $header = NULL; |
| 1140 | 1140 | $delimiter = ':'; |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | if ($globalTransaction) $Connection->db->commit(); |
| 1159 | 1159 | } |
| 1160 | 1160 | return ''; |
| 1161 | - } |
|
| 1161 | + } |
|
| 1162 | 1162 | |
| 1163 | 1163 | public static function update_airspace() { |
| 1164 | 1164 | global $tmp_dir, $globalDBdriver; |
@@ -1168,11 +1168,11 @@ discard block |
||
| 1168 | 1168 | $query = 'DROP TABLE airspace'; |
| 1169 | 1169 | try { |
| 1170 | 1170 | $sth = $Connection->db->prepare($query); |
| 1171 | - $sth->execute(); |
|
| 1172 | - } catch(PDOException $e) { |
|
| 1171 | + $sth->execute(); |
|
| 1172 | + } catch(PDOException $e) { |
|
| 1173 | 1173 | return "error : ".$e->getMessage(); |
| 1174 | - } |
|
| 1175 | - } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | 1178 | if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
@@ -1227,10 +1227,10 @@ discard block |
||
| 1227 | 1227 | $query = 'DROP TABLE countries'; |
| 1228 | 1228 | try { |
| 1229 | 1229 | $sth = $Connection->db->prepare($query); |
| 1230 | - $sth->execute(); |
|
| 1231 | - } catch(PDOException $e) { |
|
| 1232 | - echo "error : ".$e->getMessage(); |
|
| 1233 | - } |
|
| 1230 | + $sth->execute(); |
|
| 1231 | + } catch(PDOException $e) { |
|
| 1232 | + echo "error : ".$e->getMessage(); |
|
| 1233 | + } |
|
| 1234 | 1234 | } |
| 1235 | 1235 | if ($globalDBdriver == 'mysql') { |
| 1236 | 1236 | update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
@@ -1619,11 +1619,11 @@ discard block |
||
| 1619 | 1619 | $query = 'DROP TABLE airspace'; |
| 1620 | 1620 | try { |
| 1621 | 1621 | $sth = $Connection->db->prepare($query); |
| 1622 | - $sth->execute(); |
|
| 1623 | - } catch(PDOException $e) { |
|
| 1622 | + $sth->execute(); |
|
| 1623 | + } catch(PDOException $e) { |
|
| 1624 | 1624 | return "error : ".$e->getMessage(); |
| 1625 | - } |
|
| 1626 | - } |
|
| 1625 | + } |
|
| 1626 | + } |
|
| 1627 | 1627 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1628 | 1628 | update_db::insert_airspace_version($airspace_md5); |
| 1629 | 1629 | } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
@@ -1743,12 +1743,12 @@ discard block |
||
| 1743 | 1743 | echo $data; |
| 1744 | 1744 | */ |
| 1745 | 1745 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1746 | - //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1747 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | - $result = fread($fh,100000000); |
|
| 1749 | - //echo $result; |
|
| 1750 | - //var_dump(str_get_html($result)); |
|
| 1751 | - //print_r(self::table2array($result)); |
|
| 1746 | + //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
|
| 1747 | + $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | + $result = fread($fh,100000000); |
|
| 1749 | + //echo $result; |
|
| 1750 | + //var_dump(str_get_html($result)); |
|
| 1751 | + //print_r(self::table2array($result)); |
|
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | } |
@@ -1762,10 +1762,10 @@ discard block |
||
| 1762 | 1762 | try { |
| 1763 | 1763 | $Connection = new Connection(); |
| 1764 | 1764 | $sth = $Connection->db->prepare($query); |
| 1765 | - $sth->execute(); |
|
| 1766 | - } catch(PDOException $e) { |
|
| 1767 | - return "error : ".$e->getMessage(); |
|
| 1768 | - } |
|
| 1765 | + $sth->execute(); |
|
| 1766 | + } catch(PDOException $e) { |
|
| 1767 | + return "error : ".$e->getMessage(); |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | 1770 | $error = ''; |
| 1771 | 1771 | if ($globalDebug) echo "Notam : Download..."; |
@@ -1821,8 +1821,8 @@ discard block |
||
| 1821 | 1821 | $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
| 1822 | 1822 | $data['permanent'] = 0; |
| 1823 | 1823 | } else { |
| 1824 | - $data['date_end'] = NULL; |
|
| 1825 | - $data['permanent'] = 1; |
|
| 1824 | + $data['date_end'] = NULL; |
|
| 1825 | + $data['permanent'] = 1; |
|
| 1826 | 1826 | } |
| 1827 | 1827 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1828 | 1828 | $NOTAM = new NOTAM(); |
@@ -1881,13 +1881,13 @@ discard block |
||
| 1881 | 1881 | try { |
| 1882 | 1882 | $Connection = new Connection(); |
| 1883 | 1883 | $sth = $Connection->db->prepare($query); |
| 1884 | - $sth->execute(); |
|
| 1885 | - } catch(PDOException $e) { |
|
| 1886 | - return "error : ".$e->getMessage(); |
|
| 1887 | - } |
|
| 1888 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1889 | - if ($row['nb'] > 0) return false; |
|
| 1890 | - else return true; |
|
| 1884 | + $sth->execute(); |
|
| 1885 | + } catch(PDOException $e) { |
|
| 1886 | + return "error : ".$e->getMessage(); |
|
| 1887 | + } |
|
| 1888 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1889 | + if ($row['nb'] > 0) return false; |
|
| 1890 | + else return true; |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | public static function insert_last_update() { |
@@ -1896,10 +1896,10 @@ discard block |
||
| 1896 | 1896 | try { |
| 1897 | 1897 | $Connection = new Connection(); |
| 1898 | 1898 | $sth = $Connection->db->prepare($query); |
| 1899 | - $sth->execute(); |
|
| 1900 | - } catch(PDOException $e) { |
|
| 1901 | - return "error : ".$e->getMessage(); |
|
| 1902 | - } |
|
| 1899 | + $sth->execute(); |
|
| 1900 | + } catch(PDOException $e) { |
|
| 1901 | + return "error : ".$e->getMessage(); |
|
| 1902 | + } |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | 1905 | public static function check_airspace_version($version) { |
@@ -1907,13 +1907,13 @@ discard block |
||
| 1907 | 1907 | try { |
| 1908 | 1908 | $Connection = new Connection(); |
| 1909 | 1909 | $sth = $Connection->db->prepare($query); |
| 1910 | - $sth->execute(array(':version' => $version)); |
|
| 1911 | - } catch(PDOException $e) { |
|
| 1912 | - return "error : ".$e->getMessage(); |
|
| 1913 | - } |
|
| 1914 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1915 | - if ($row['nb'] > 0) return true; |
|
| 1916 | - else return false; |
|
| 1910 | + $sth->execute(array(':version' => $version)); |
|
| 1911 | + } catch(PDOException $e) { |
|
| 1912 | + return "error : ".$e->getMessage(); |
|
| 1913 | + } |
|
| 1914 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1915 | + if ($row['nb'] > 0) return true; |
|
| 1916 | + else return false; |
|
| 1917 | 1917 | } |
| 1918 | 1918 | |
| 1919 | 1919 | |
@@ -1923,10 +1923,10 @@ discard block |
||
| 1923 | 1923 | try { |
| 1924 | 1924 | $Connection = new Connection(); |
| 1925 | 1925 | $sth = $Connection->db->prepare($query); |
| 1926 | - $sth->execute(array(':version' => $version)); |
|
| 1927 | - } catch(PDOException $e) { |
|
| 1928 | - return "error : ".$e->getMessage(); |
|
| 1929 | - } |
|
| 1926 | + $sth->execute(array(':version' => $version)); |
|
| 1927 | + } catch(PDOException $e) { |
|
| 1928 | + return "error : ".$e->getMessage(); |
|
| 1929 | + } |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | public static function check_last_notam_update() { |
@@ -1939,13 +1939,13 @@ discard block |
||
| 1939 | 1939 | try { |
| 1940 | 1940 | $Connection = new Connection(); |
| 1941 | 1941 | $sth = $Connection->db->prepare($query); |
| 1942 | - $sth->execute(); |
|
| 1943 | - } catch(PDOException $e) { |
|
| 1944 | - return "error : ".$e->getMessage(); |
|
| 1945 | - } |
|
| 1946 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1947 | - if ($row['nb'] > 0) return false; |
|
| 1948 | - else return true; |
|
| 1942 | + $sth->execute(); |
|
| 1943 | + } catch(PDOException $e) { |
|
| 1944 | + return "error : ".$e->getMessage(); |
|
| 1945 | + } |
|
| 1946 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1947 | + if ($row['nb'] > 0) return false; |
|
| 1948 | + else return true; |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | public static function insert_last_notam_update() { |
@@ -1954,10 +1954,10 @@ discard block |
||
| 1954 | 1954 | try { |
| 1955 | 1955 | $Connection = new Connection(); |
| 1956 | 1956 | $sth = $Connection->db->prepare($query); |
| 1957 | - $sth->execute(); |
|
| 1958 | - } catch(PDOException $e) { |
|
| 1959 | - return "error : ".$e->getMessage(); |
|
| 1960 | - } |
|
| 1957 | + $sth->execute(); |
|
| 1958 | + } catch(PDOException $e) { |
|
| 1959 | + return "error : ".$e->getMessage(); |
|
| 1960 | + } |
|
| 1961 | 1961 | } |
| 1962 | 1962 | public static function check_last_airspace_update() { |
| 1963 | 1963 | global $globalDBdriver; |
@@ -1969,13 +1969,13 @@ discard block |
||
| 1969 | 1969 | try { |
| 1970 | 1970 | $Connection = new Connection(); |
| 1971 | 1971 | $sth = $Connection->db->prepare($query); |
| 1972 | - $sth->execute(); |
|
| 1973 | - } catch(PDOException $e) { |
|
| 1974 | - return "error : ".$e->getMessage(); |
|
| 1975 | - } |
|
| 1976 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1977 | - if ($row['nb'] > 0) return false; |
|
| 1978 | - else return true; |
|
| 1972 | + $sth->execute(); |
|
| 1973 | + } catch(PDOException $e) { |
|
| 1974 | + return "error : ".$e->getMessage(); |
|
| 1975 | + } |
|
| 1976 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 1977 | + if ($row['nb'] > 0) return false; |
|
| 1978 | + else return true; |
|
| 1979 | 1979 | } |
| 1980 | 1980 | |
| 1981 | 1981 | public static function insert_last_airspace_update() { |
@@ -1984,10 +1984,10 @@ discard block |
||
| 1984 | 1984 | try { |
| 1985 | 1985 | $Connection = new Connection(); |
| 1986 | 1986 | $sth = $Connection->db->prepare($query); |
| 1987 | - $sth->execute(); |
|
| 1988 | - } catch(PDOException $e) { |
|
| 1989 | - return "error : ".$e->getMessage(); |
|
| 1990 | - } |
|
| 1987 | + $sth->execute(); |
|
| 1988 | + } catch(PDOException $e) { |
|
| 1989 | + return "error : ".$e->getMessage(); |
|
| 1990 | + } |
|
| 1991 | 1991 | } |
| 1992 | 1992 | |
| 1993 | 1993 | public static function check_last_owner_update() { |
@@ -2000,13 +2000,13 @@ discard block |
||
| 2000 | 2000 | try { |
| 2001 | 2001 | $Connection = new Connection(); |
| 2002 | 2002 | $sth = $Connection->db->prepare($query); |
| 2003 | - $sth->execute(); |
|
| 2004 | - } catch(PDOException $e) { |
|
| 2005 | - return "error : ".$e->getMessage(); |
|
| 2006 | - } |
|
| 2007 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2008 | - if ($row['nb'] > 0) return false; |
|
| 2009 | - else return true; |
|
| 2003 | + $sth->execute(); |
|
| 2004 | + } catch(PDOException $e) { |
|
| 2005 | + return "error : ".$e->getMessage(); |
|
| 2006 | + } |
|
| 2007 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2008 | + if ($row['nb'] > 0) return false; |
|
| 2009 | + else return true; |
|
| 2010 | 2010 | } |
| 2011 | 2011 | |
| 2012 | 2012 | public static function insert_last_owner_update() { |
@@ -2015,10 +2015,10 @@ discard block |
||
| 2015 | 2015 | try { |
| 2016 | 2016 | $Connection = new Connection(); |
| 2017 | 2017 | $sth = $Connection->db->prepare($query); |
| 2018 | - $sth->execute(); |
|
| 2019 | - } catch(PDOException $e) { |
|
| 2020 | - return "error : ".$e->getMessage(); |
|
| 2021 | - } |
|
| 2018 | + $sth->execute(); |
|
| 2019 | + } catch(PDOException $e) { |
|
| 2020 | + return "error : ".$e->getMessage(); |
|
| 2021 | + } |
|
| 2022 | 2022 | } |
| 2023 | 2023 | public static function check_last_schedules_update() { |
| 2024 | 2024 | global $globalDBdriver; |
@@ -2030,13 +2030,13 @@ discard block |
||
| 2030 | 2030 | try { |
| 2031 | 2031 | $Connection = new Connection(); |
| 2032 | 2032 | $sth = $Connection->db->prepare($query); |
| 2033 | - $sth->execute(); |
|
| 2034 | - } catch(PDOException $e) { |
|
| 2035 | - return "error : ".$e->getMessage(); |
|
| 2036 | - } |
|
| 2037 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2038 | - if ($row['nb'] > 0) return false; |
|
| 2039 | - else return true; |
|
| 2033 | + $sth->execute(); |
|
| 2034 | + } catch(PDOException $e) { |
|
| 2035 | + return "error : ".$e->getMessage(); |
|
| 2036 | + } |
|
| 2037 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2038 | + if ($row['nb'] > 0) return false; |
|
| 2039 | + else return true; |
|
| 2040 | 2040 | } |
| 2041 | 2041 | |
| 2042 | 2042 | public static function insert_last_schedules_update() { |
@@ -2045,10 +2045,10 @@ discard block |
||
| 2045 | 2045 | try { |
| 2046 | 2046 | $Connection = new Connection(); |
| 2047 | 2047 | $sth = $Connection->db->prepare($query); |
| 2048 | - $sth->execute(); |
|
| 2049 | - } catch(PDOException $e) { |
|
| 2050 | - return "error : ".$e->getMessage(); |
|
| 2051 | - } |
|
| 2048 | + $sth->execute(); |
|
| 2049 | + } catch(PDOException $e) { |
|
| 2050 | + return "error : ".$e->getMessage(); |
|
| 2051 | + } |
|
| 2052 | 2052 | } |
| 2053 | 2053 | public static function check_last_tle_update() { |
| 2054 | 2054 | global $globalDBdriver; |
@@ -2060,13 +2060,13 @@ discard block |
||
| 2060 | 2060 | try { |
| 2061 | 2061 | $Connection = new Connection(); |
| 2062 | 2062 | $sth = $Connection->db->prepare($query); |
| 2063 | - $sth->execute(); |
|
| 2064 | - } catch(PDOException $e) { |
|
| 2065 | - return "error : ".$e->getMessage(); |
|
| 2066 | - } |
|
| 2067 | - $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2068 | - if ($row['nb'] > 0) return false; |
|
| 2069 | - else return true; |
|
| 2063 | + $sth->execute(); |
|
| 2064 | + } catch(PDOException $e) { |
|
| 2065 | + return "error : ".$e->getMessage(); |
|
| 2066 | + } |
|
| 2067 | + $row = $sth->fetch(PDO::FETCH_ASSOC); |
|
| 2068 | + if ($row['nb'] > 0) return false; |
|
| 2069 | + else return true; |
|
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | public static function insert_last_tle_update() { |
@@ -2075,10 +2075,10 @@ discard block |
||
| 2075 | 2075 | try { |
| 2076 | 2076 | $Connection = new Connection(); |
| 2077 | 2077 | $sth = $Connection->db->prepare($query); |
| 2078 | - $sth->execute(); |
|
| 2079 | - } catch(PDOException $e) { |
|
| 2080 | - return "error : ".$e->getMessage(); |
|
| 2081 | - } |
|
| 2078 | + $sth->execute(); |
|
| 2079 | + } catch(PDOException $e) { |
|
| 2080 | + return "error : ".$e->getMessage(); |
|
| 2081 | + } |
|
| 2082 | 2082 | } |
| 2083 | 2083 | |
| 2084 | 2084 | public static function update_all() { |
@@ -24,20 +24,20 @@ discard block |
||
| 24 | 24 | fclose($fp); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public static function gunzip($in_file,$out_file_name = '') { |
|
| 27 | + public static function gunzip($in_file, $out_file_name = '') { |
|
| 28 | 28 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 29 | $buffer_size = 4096; // read 4kb at a time |
| 30 | 30 | if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
| 31 | 31 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 32 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 33 | + if (function_exists('gzopen')) $file = gzopen($in_file, 'rb'); |
|
| 34 | + elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb'); |
|
| 35 | 35 | else { |
| 36 | 36 | echo 'gzopen not available'; |
| 37 | 37 | die; |
| 38 | 38 | } |
| 39 | 39 | $out_file = fopen($out_file_name, 'wb'); |
| 40 | - while(!gzeof($file)) { |
|
| 40 | + while (!gzeof($file)) { |
|
| 41 | 41 | fwrite($out_file, gzread($file, $buffer_size)); |
| 42 | 42 | } |
| 43 | 43 | fclose($out_file); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | try { |
| 62 | 62 | self::$db_sqlite = new PDO('sqlite:'.$database); |
| 63 | 63 | self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 64 | - } catch(PDOException $e) { |
|
| 64 | + } catch (PDOException $e) { |
|
| 65 | 65 | return "error : ".$e->getMessage(); |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | //$Connection = new Connection(); |
| 77 | 77 | $sth = $Connection->db->prepare($query); |
| 78 | 78 | $sth->execute(array(':source' => $database_file)); |
| 79 | - } catch(PDOException $e) { |
|
| 79 | + } catch (PDOException $e) { |
|
| 80 | 80 | return "error : ".$e->getMessage(); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | try { |
| 88 | 88 | $sth = update_db::$db_sqlite->prepare($query); |
| 89 | 89 | $sth->execute(); |
| 90 | - } catch(PDOException $e) { |
|
| 90 | + } catch (PDOException $e) { |
|
| 91 | 91 | return "error : ".$e->getMessage(); |
| 92 | 92 | } |
| 93 | 93 | //$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)'; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 99 | 99 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 100 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | - $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
|
| 101 | + $query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file); |
|
| 102 | 102 | $sth_dest->execute($query_dest_values); |
| 103 | 103 | } |
| 104 | 104 | if ($globalTransaction) $Connection->db->commit(); |
| 105 | - } catch(PDOException $e) { |
|
| 105 | + } catch (PDOException $e) { |
|
| 106 | 106 | if ($globalTransaction) $Connection->db->rollBack(); |
| 107 | 107 | return "error : ".$e->getMessage(); |
| 108 | 108 | } |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | //$Connection = new Connection(); |
| 119 | 119 | $sth = $Connection->db->prepare($query); |
| 120 | 120 | $sth->execute(array(':source' => 'oneworld')); |
| 121 | - } catch(PDOException $e) { |
|
| 121 | + } catch (PDOException $e) { |
|
| 122 | 122 | return "error : ".$e->getMessage(); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | if ($globalDebug) echo " - Add routes to DB -"; |
| 126 | 126 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 127 | $Spotter = new Spotter(); |
| 128 | - if ($fh = fopen($database_file,"r")) { |
|
| 128 | + if ($fh = fopen($database_file, "r")) { |
|
| 129 | 129 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 130 | $Connection = new Connection(); |
| 131 | 131 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | 132 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 133 | 133 | while (!feof($fh)) { |
| 134 | - $line = fgetcsv($fh,9999,','); |
|
| 134 | + $line = fgetcsv($fh, 9999, ','); |
|
| 135 | 135 | if ($line[0] != '') { |
| 136 | 136 | if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) { |
| 137 | 137 | try { |
| 138 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
|
| 138 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld'); |
|
| 139 | 139 | $sth_dest->execute($query_dest_values); |
| 140 | - } catch(PDOException $e) { |
|
| 140 | + } catch (PDOException $e) { |
|
| 141 | 141 | if ($globalTransaction) $Connection->db->rollBack(); |
| 142 | 142 | return "error : ".$e->getMessage(); |
| 143 | 143 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | //$Connection = new Connection(); |
| 160 | 160 | $sth = $Connection->db->prepare($query); |
| 161 | 161 | $sth->execute(array(':source' => 'skyteam')); |
| 162 | - } catch(PDOException $e) { |
|
| 162 | + } catch (PDOException $e) { |
|
| 163 | 163 | return "error : ".$e->getMessage(); |
| 164 | 164 | } |
| 165 | 165 | |
@@ -167,24 +167,24 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 169 | $Spotter = new Spotter(); |
| 170 | - if ($fh = fopen($database_file,"r")) { |
|
| 170 | + if ($fh = fopen($database_file, "r")) { |
|
| 171 | 171 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 172 | 172 | $Connection = new Connection(); |
| 173 | 173 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 174 | try { |
| 175 | 175 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 176 | 176 | while (!feof($fh)) { |
| 177 | - $line = fgetcsv($fh,9999,','); |
|
| 177 | + $line = fgetcsv($fh, 9999, ','); |
|
| 178 | 178 | if ($line[0] != '') { |
| 179 | 179 | //$datebe = explode(' - ',$line[2]); |
| 180 | 180 | //if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) { |
| 181 | - $query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam'); |
|
| 181 | + $query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam'); |
|
| 182 | 182 | $sth_dest->execute($query_dest_values); |
| 183 | 183 | //} |
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | if ($globalTransaction) $Connection->db->commit(); |
| 187 | - } catch(PDOException $e) { |
|
| 187 | + } catch (PDOException $e) { |
|
| 188 | 188 | if ($globalTransaction) $Connection->db->rollBack(); |
| 189 | 189 | return "error : ".$e->getMessage(); |
| 190 | 190 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | $Connection = new Connection(); |
| 200 | 200 | $sth = $Connection->db->prepare($query); |
| 201 | 201 | $sth->execute(array(':source' => $database_file)); |
| 202 | - } catch(PDOException $e) { |
|
| 202 | + } catch (PDOException $e) { |
|
| 203 | 203 | return "error : ".$e->getMessage(); |
| 204 | 204 | } |
| 205 | 205 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $Connection = new Connection(); |
| 208 | 208 | $sth = $Connection->db->prepare($query); |
| 209 | 209 | $sth->execute(array(':source' => $database_file)); |
| 210 | - } catch(PDOException $e) { |
|
| 210 | + } catch (PDOException $e) { |
|
| 211 | 211 | return "error : ".$e->getMessage(); |
| 212 | 212 | } |
| 213 | 213 | |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | try { |
| 217 | 217 | $sth = update_db::$db_sqlite->prepare($query); |
| 218 | 218 | $sth->execute(); |
| 219 | - } catch(PDOException $e) { |
|
| 219 | + } catch (PDOException $e) { |
|
| 220 | 220 | return "error : ".$e->getMessage(); |
| 221 | 221 | } |
| 222 | 222 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
@@ -233,15 +233,15 @@ discard block |
||
| 233 | 233 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | 234 | if ($values['UserString4'] == 'M') $type = 'military'; |
| 235 | 235 | else $type = null; |
| 236 | - $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
|
| 236 | + $query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type); |
|
| 237 | 237 | $sth_dest->execute($query_dest_values); |
| 238 | 238 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
| 239 | - $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']); |
|
| 239 | + $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']); |
|
| 240 | 240 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | if ($globalTransaction) $Connection->db->commit(); |
| 244 | - } catch(PDOException $e) { |
|
| 244 | + } catch (PDOException $e) { |
|
| 245 | 245 | return "error : ".$e->getMessage(); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $Connection = new Connection(); |
| 251 | 251 | $sth = $Connection->db->prepare($query); |
| 252 | 252 | $sth->execute(array(':source' => $database_file)); |
| 253 | - } catch(PDOException $e) { |
|
| 253 | + } catch (PDOException $e) { |
|
| 254 | 254 | return "error : ".$e->getMessage(); |
| 255 | 255 | } |
| 256 | 256 | return ''; |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | $Connection = new Connection(); |
| 266 | 266 | $sth = $Connection->db->prepare($query); |
| 267 | 267 | $sth->execute(array(':source' => $database_file)); |
| 268 | - } catch(PDOException $e) { |
|
| 268 | + } catch (PDOException $e) { |
|
| 269 | 269 | return "error : ".$e->getMessage(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ($fh = fopen($database_file,"r")) { |
|
| 272 | + if ($fh = fopen($database_file, "r")) { |
|
| 273 | 273 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 274 | 274 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 275 | 275 | |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 280 | 280 | while (!feof($fh)) { |
| 281 | 281 | $values = array(); |
| 282 | - $line = $Common->hex2str(fgets($fh,9999)); |
|
| 282 | + $line = $Common->hex2str(fgets($fh, 9999)); |
|
| 283 | 283 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 284 | - $values['ModeS'] = substr($line,0,6); |
|
| 285 | - $values['Registration'] = trim(substr($line,69,6)); |
|
| 286 | - $aircraft_name = trim(substr($line,48,6)); |
|
| 284 | + $values['ModeS'] = substr($line, 0, 6); |
|
| 285 | + $values['Registration'] = trim(substr($line, 69, 6)); |
|
| 286 | + $aircraft_name = trim(substr($line, 48, 6)); |
|
| 287 | 287 | // Check if we can find ICAO, else set it to GLID |
| 288 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 288 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 289 | 289 | $search_more = ''; |
| 290 | 290 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 291 | 291 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -297,20 +297,20 @@ discard block |
||
| 297 | 297 | if (isset($result['icao']) && $result['icao'] != '') { |
| 298 | 298 | $values['ICAOTypeCode'] = $result['icao']; |
| 299 | 299 | } |
| 300 | - } catch(PDOException $e) { |
|
| 300 | + } catch (PDOException $e) { |
|
| 301 | 301 | return "error : ".$e->getMessage(); |
| 302 | 302 | } |
| 303 | 303 | if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 304 | 304 | // Add data to db |
| 305 | 305 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 306 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 307 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 307 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 308 | 308 | //print_r($query_dest_values); |
| 309 | 309 | $sth_dest->execute($query_dest_values); |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | if ($globalTransaction) $Connection->db->commit(); |
| 313 | - } catch(PDOException $e) { |
|
| 313 | + } catch (PDOException $e) { |
|
| 314 | 314 | return "error : ".$e->getMessage(); |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | $Connection = new Connection(); |
| 321 | 321 | $sth = $Connection->db->prepare($query); |
| 322 | 322 | $sth->execute(array(':source' => $database_file)); |
| 323 | - } catch(PDOException $e) { |
|
| 323 | + } catch (PDOException $e) { |
|
| 324 | 324 | return "error : ".$e->getMessage(); |
| 325 | 325 | } |
| 326 | 326 | return ''; |
@@ -334,11 +334,11 @@ discard block |
||
| 334 | 334 | $Connection = new Connection(); |
| 335 | 335 | $sth = $Connection->db->prepare($query); |
| 336 | 336 | $sth->execute(array(':source' => $database_file)); |
| 337 | - } catch(PDOException $e) { |
|
| 337 | + } catch (PDOException $e) { |
|
| 338 | 338 | return "error : ".$e->getMessage(); |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | - if ($fh = fopen($database_file,"r")) { |
|
| 341 | + if ($fh = fopen($database_file, "r")) { |
|
| 342 | 342 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 343 | 343 | $query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source)'; |
| 344 | 344 | |
@@ -346,9 +346,9 @@ discard block |
||
| 346 | 346 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 347 | try { |
| 348 | 348 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 349 | - $tmp = fgetcsv($fh,9999,',',"'"); |
|
| 349 | + $tmp = fgetcsv($fh, 9999, ',', "'"); |
|
| 350 | 350 | while (!feof($fh)) { |
| 351 | - $line = fgetcsv($fh,9999,',',"'"); |
|
| 351 | + $line = fgetcsv($fh, 9999, ',', "'"); |
|
| 352 | 352 | |
| 353 | 353 | //FFFFFF RIDEAU VALLEY SOARINGASW-20 C-FBKN MZ 123.400 |
| 354 | 354 | //print_r($line); |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $values['Registration'] = $line[3]; |
| 357 | 357 | $aircraft_name = $line[2]; |
| 358 | 358 | // Check if we can find ICAO, else set it to GLID |
| 359 | - $aircraft_name_split = explode(' ',$aircraft_name); |
|
| 359 | + $aircraft_name_split = explode(' ', $aircraft_name); |
|
| 360 | 360 | $search_more = ''; |
| 361 | 361 | if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
| 362 | 362 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
@@ -365,20 +365,20 @@ discard block |
||
| 365 | 365 | $sth_search->execute(); |
| 366 | 366 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | 367 | if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
| 368 | - } catch(PDOException $e) { |
|
| 368 | + } catch (PDOException $e) { |
|
| 369 | 369 | return "error : ".$e->getMessage(); |
| 370 | 370 | } |
| 371 | 371 | //if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
| 372 | 372 | // Add data to db |
| 373 | 373 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') { |
| 374 | 374 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 375 | - $query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file); |
|
| 375 | + $query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file); |
|
| 376 | 376 | //print_r($query_dest_values); |
| 377 | 377 | $sth_dest->execute($query_dest_values); |
| 378 | 378 | } |
| 379 | 379 | } |
| 380 | 380 | if ($globalTransaction) $Connection->db->commit(); |
| 381 | - } catch(PDOException $e) { |
|
| 381 | + } catch (PDOException $e) { |
|
| 382 | 382 | return "error : ".$e->getMessage(); |
| 383 | 383 | } |
| 384 | 384 | } |
@@ -388,13 +388,13 @@ discard block |
||
| 388 | 388 | $Connection = new Connection(); |
| 389 | 389 | $sth = $Connection->db->prepare($query); |
| 390 | 390 | $sth->execute(array(':source' => $database_file)); |
| 391 | - } catch(PDOException $e) { |
|
| 391 | + } catch (PDOException $e) { |
|
| 392 | 392 | return "error : ".$e->getMessage(); |
| 393 | 393 | } |
| 394 | 394 | return ''; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public static function retrieve_owner($database_file,$country = 'F') { |
|
| 397 | + public static function retrieve_owner($database_file, $country = 'F') { |
|
| 398 | 398 | global $globalTransaction; |
| 399 | 399 | //$query = 'TRUNCATE TABLE aircraft_modes'; |
| 400 | 400 | $query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source"; |
@@ -402,11 +402,11 @@ discard block |
||
| 402 | 402 | $Connection = new Connection(); |
| 403 | 403 | $sth = $Connection->db->prepare($query); |
| 404 | 404 | $sth->execute(array(':source' => $database_file)); |
| 405 | - } catch(PDOException $e) { |
|
| 405 | + } catch (PDOException $e) { |
|
| 406 | 406 | return "error : ".$e->getMessage(); |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if ($fh = fopen($database_file,"r")) { |
|
| 409 | + if ($fh = fopen($database_file, "r")) { |
|
| 410 | 410 | //$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)'; |
| 411 | 411 | $query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)'; |
| 412 | 412 | |
@@ -414,9 +414,9 @@ discard block |
||
| 414 | 414 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 415 | try { |
| 416 | 416 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 417 | - $tmp = fgetcsv($fh,9999,',','"'); |
|
| 417 | + $tmp = fgetcsv($fh, 9999, ',', '"'); |
|
| 418 | 418 | while (!feof($fh)) { |
| 419 | - $line = fgetcsv($fh,9999,',','"'); |
|
| 419 | + $line = fgetcsv($fh, 9999, ',', '"'); |
|
| 420 | 420 | $values = array(); |
| 421 | 421 | //print_r($line); |
| 422 | 422 | if ($country == 'F') { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | $values['base'] = $line[4]; |
| 425 | 425 | $values['owner'] = $line[5]; |
| 426 | 426 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 427 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 428 | 428 | $values['cancel'] = $line[7]; |
| 429 | 429 | } elseif ($country == 'EI') { |
| 430 | 430 | // TODO : add modeS & reg to aircraft_modes |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $values['base'] = $line[3]; |
| 433 | 433 | $values['owner'] = $line[2]; |
| 434 | 434 | if ($line[1] == '') $values['date_first_reg'] = null; |
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 435 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1])); |
|
| 436 | 436 | $values['cancel'] = ''; |
| 437 | 437 | } elseif ($country == 'HB') { |
| 438 | 438 | // TODO : add modeS & reg to aircraft_modes |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | $values['base'] = null; |
| 448 | 448 | $values['owner'] = $line[5]; |
| 449 | 449 | if ($line[18] == '') $values['date_first_reg'] = null; |
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 450 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18])); |
|
| 451 | 451 | $values['cancel'] = ''; |
| 452 | 452 | } elseif ($country == 'VH') { |
| 453 | 453 | // TODO : add modeS & reg to aircraft_modes |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | $values['base'] = null; |
| 456 | 456 | $values['owner'] = $line[12]; |
| 457 | 457 | if ($line[28] == '') $values['date_first_reg'] = null; |
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 458 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28])); |
|
| 459 | 459 | |
| 460 | 460 | $values['cancel'] = $line[39]; |
| 461 | 461 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -475,28 +475,28 @@ discard block |
||
| 475 | 475 | $values['base'] = null; |
| 476 | 476 | $values['owner'] = $line[8]; |
| 477 | 477 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 478 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 479 | 479 | $values['cancel'] = ''; |
| 480 | 480 | } elseif ($country == 'PP') { |
| 481 | 481 | $values['registration'] = $line[0]; |
| 482 | 482 | $values['base'] = null; |
| 483 | 483 | $values['owner'] = $line[4]; |
| 484 | 484 | if ($line[6] == '') $values['date_first_reg'] = null; |
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 485 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6])); |
|
| 486 | 486 | $values['cancel'] = $line[7]; |
| 487 | 487 | } elseif ($country == 'E7') { |
| 488 | 488 | $values['registration'] = $line[0]; |
| 489 | 489 | $values['base'] = null; |
| 490 | 490 | $values['owner'] = $line[4]; |
| 491 | 491 | if ($line[5] == '') $values['date_first_reg'] = null; |
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 492 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5])); |
|
| 493 | 493 | $values['cancel'] = ''; |
| 494 | 494 | } elseif ($country == '8Q') { |
| 495 | 495 | $values['registration'] = $line[0]; |
| 496 | 496 | $values['base'] = null; |
| 497 | 497 | $values['owner'] = $line[3]; |
| 498 | 498 | if ($line[7] == '') $values['date_first_reg'] = null; |
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 499 | + else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7])); |
|
| 500 | 500 | $values['cancel'] = ''; |
| 501 | 501 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 502 | $values['registration'] = $line[0]; |
@@ -506,12 +506,12 @@ discard block |
||
| 506 | 506 | $values['cancel'] = ''; |
| 507 | 507 | } |
| 508 | 508 | if ($values['cancel'] == '' && $values['registration'] != null) { |
| 509 | - $query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file); |
|
| 509 | + $query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file); |
|
| 510 | 510 | $sth_dest->execute($query_dest_values); |
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | if ($globalTransaction) $Connection->db->commit(); |
| 514 | - } catch(PDOException $e) { |
|
| 514 | + } catch (PDOException $e) { |
|
| 515 | 515 | return "error : ".$e->getMessage(); |
| 516 | 516 | } |
| 517 | 517 | } |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $Connection = new Connection(); |
| 627 | 627 | $sth = $Connection->db->prepare($query); |
| 628 | 628 | $sth->execute(); |
| 629 | - } catch(PDOException $e) { |
|
| 629 | + } catch (PDOException $e) { |
|
| 630 | 630 | return "error : ".$e->getMessage(); |
| 631 | 631 | } |
| 632 | 632 | |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | $Connection = new Connection(); |
| 637 | 637 | $sth = $Connection->db->prepare($query); |
| 638 | 638 | $sth->execute(); |
| 639 | - } catch(PDOException $e) { |
|
| 639 | + } catch (PDOException $e) { |
|
| 640 | 640 | return "error : ".$e->getMessage(); |
| 641 | 641 | } |
| 642 | 642 | |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 648 | 648 | |
| 649 | 649 | $i = 0; |
| 650 | - while($row = sparql_fetch_array($result)) |
|
| 650 | + while ($row = sparql_fetch_array($result)) |
|
| 651 | 651 | { |
| 652 | 652 | if ($i >= 1) { |
| 653 | 653 | //print_r($row); |
@@ -667,31 +667,31 @@ discard block |
||
| 667 | 667 | $row['image'] = ''; |
| 668 | 668 | $row['image_thumb'] = ''; |
| 669 | 669 | } else { |
| 670 | - $image = str_replace(' ','_',$row['image']); |
|
| 670 | + $image = str_replace(' ', '_', $row['image']); |
|
| 671 | 671 | $digest = md5($image); |
| 672 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image; |
|
| 673 | - $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder; |
|
| 674 | - $folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image; |
|
| 675 | - $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder; |
|
| 672 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image; |
|
| 673 | + $row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder; |
|
| 674 | + $folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image; |
|
| 675 | + $row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder; |
|
| 676 | 676 | } |
| 677 | 677 | |
| 678 | - $country = explode('-',$row['country']); |
|
| 678 | + $country = explode('-', $row['country']); |
|
| 679 | 679 | $row['country'] = $country[0]; |
| 680 | 680 | |
| 681 | 681 | $row['type'] = trim($row['type']); |
| 682 | - if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) { |
|
| 682 | + if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) { |
|
| 683 | 683 | $row['type'] = 'Military'; |
| 684 | 684 | } elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') { |
| 685 | 685 | $row['type'] = 'small_airport'; |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city']))); |
|
| 689 | - $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']); |
|
| 688 | + $row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city']))); |
|
| 689 | + $query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']); |
|
| 690 | 690 | //print_r($query_dest_values); |
| 691 | 691 | |
| 692 | 692 | try { |
| 693 | 693 | $sth_dest->execute($query_dest_values); |
| 694 | - } catch(PDOException $e) { |
|
| 694 | + } catch (PDOException $e) { |
|
| 695 | 695 | return "error : ".$e->getMessage(); |
| 696 | 696 | } |
| 697 | 697 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | $Connection = new Connection(); |
| 706 | 706 | $sth = $Connection->db->prepare($query); |
| 707 | 707 | $sth->execute(); |
| 708 | - } catch(PDOException $e) { |
|
| 708 | + } catch (PDOException $e) { |
|
| 709 | 709 | return "error : ".$e->getMessage(); |
| 710 | 710 | } |
| 711 | 711 | |
@@ -713,12 +713,12 @@ discard block |
||
| 713 | 713 | if ($globalDebug) echo "Insert Not available Airport...\n"; |
| 714 | 714 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 715 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | - $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
|
| 716 | + $query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => ''); |
|
| 717 | 717 | try { |
| 718 | 718 | $Connection = new Connection(); |
| 719 | 719 | $sth = $Connection->db->prepare($query); |
| 720 | 720 | $sth->execute($query_values); |
| 721 | - } catch(PDOException $e) { |
|
| 721 | + } catch (PDOException $e) { |
|
| 722 | 722 | return "error : ".$e->getMessage(); |
| 723 | 723 | } |
| 724 | 724 | $i++; |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | echo "Download data from ourairports.com...\n"; |
| 737 | 737 | $delimiter = ','; |
| 738 | 738 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | - update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
|
| 739 | + update_db::download('http://ourairports.com/data/airports.csv', $out_file); |
|
| 740 | 740 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 741 | 741 | echo "Add data from ourairports.com...\n"; |
| 742 | 742 | |
@@ -747,32 +747,32 @@ discard block |
||
| 747 | 747 | //$Connection->db->beginTransaction(); |
| 748 | 748 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 749 | { |
| 750 | - if(!$header) $header = $row; |
|
| 750 | + if (!$header) $header = $row; |
|
| 751 | 751 | else { |
| 752 | 752 | $data = array(); |
| 753 | 753 | $data = array_combine($header, $row); |
| 754 | 754 | try { |
| 755 | 755 | $sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao'); |
| 756 | 756 | $sth->execute(array(':icao' => $data['gps_code'])); |
| 757 | - } catch(PDOException $e) { |
|
| 757 | + } catch (PDOException $e) { |
|
| 758 | 758 | return "error : ".$e->getMessage(); |
| 759 | 759 | } |
| 760 | 760 | if ($sth->fetchColumn() > 0) { |
| 761 | 761 | $query = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 762 | 762 | try { |
| 763 | 763 | $sth = $Connection->db->prepare($query); |
| 764 | - $sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type'])); |
|
| 765 | - } catch(PDOException $e) { |
|
| 764 | + $sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type'])); |
|
| 765 | + } catch (PDOException $e) { |
|
| 766 | 766 | return "error : ".$e->getMessage(); |
| 767 | 767 | } |
| 768 | 768 | } else { |
| 769 | 769 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`) |
| 770 | 770 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)"; |
| 771 | - $query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']); |
|
| 771 | + $query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']); |
|
| 772 | 772 | try { |
| 773 | 773 | $sth = $Connection->db->prepare($query); |
| 774 | 774 | $sth->execute($query_values); |
| 775 | - } catch(PDOException $e) { |
|
| 775 | + } catch (PDOException $e) { |
|
| 776 | 776 | return "error : ".$e->getMessage(); |
| 777 | 777 | } |
| 778 | 778 | $i++; |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | echo "Download data from another free database...\n"; |
| 787 | 787 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | - update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
|
| 788 | + update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file); |
|
| 789 | 789 | if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
| 790 | 790 | update_db::unzip($out_file); |
| 791 | 791 | $header = NULL; |
@@ -797,15 +797,15 @@ discard block |
||
| 797 | 797 | //$Connection->db->beginTransaction(); |
| 798 | 798 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 799 | { |
| 800 | - if(!$header) $header = $row; |
|
| 800 | + if (!$header) $header = $row; |
|
| 801 | 801 | else { |
| 802 | 802 | $data = $row; |
| 803 | 803 | |
| 804 | 804 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
| 805 | 805 | try { |
| 806 | 806 | $sth = $Connection->db->prepare($query); |
| 807 | - $sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4])))); |
|
| 808 | - } catch(PDOException $e) { |
|
| 807 | + $sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4])))); |
|
| 808 | + } catch (PDOException $e) { |
|
| 809 | 809 | return "error : ".$e->getMessage(); |
| 810 | 810 | } |
| 811 | 811 | } |
@@ -819,15 +819,15 @@ discard block |
||
| 819 | 819 | try { |
| 820 | 820 | $sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'"); |
| 821 | 821 | $sth->execute(); |
| 822 | - } catch(PDOException $e) { |
|
| 822 | + } catch (PDOException $e) { |
|
| 823 | 823 | return "error : ".$e->getMessage(); |
| 824 | 824 | } |
| 825 | 825 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 826 | 826 | $query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao'; |
| 827 | 827 | try { |
| 828 | 828 | $sth2 = $Connection->db->prepare($query2); |
| 829 | - $sth2->execute(array(':icao' => $row['icao'],':type' => 'military')); |
|
| 830 | - } catch(PDOException $e) { |
|
| 829 | + $sth2->execute(array(':icao' => $row['icao'], ':type' => 'military')); |
|
| 830 | + } catch (PDOException $e) { |
|
| 831 | 831 | return "error : ".$e->getMessage(); |
| 832 | 832 | } |
| 833 | 833 | } |
@@ -851,7 +851,7 @@ discard block |
||
| 851 | 851 | $Connection = new Connection(); |
| 852 | 852 | $sth = $Connection->db->prepare($query); |
| 853 | 853 | $sth->execute(array(':source' => 'translation.csv')); |
| 854 | - } catch(PDOException $e) { |
|
| 854 | + } catch (PDOException $e) { |
|
| 855 | 855 | return "error : ".$e->getMessage(); |
| 856 | 856 | } |
| 857 | 857 | |
@@ -868,7 +868,7 @@ discard block |
||
| 868 | 868 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 869 | 869 | { |
| 870 | 870 | $i++; |
| 871 | - if($i > 12) { |
|
| 871 | + if ($i > 12) { |
|
| 872 | 872 | $data = $row; |
| 873 | 873 | $operator = $data[2]; |
| 874 | 874 | if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) { |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | //echo substr($operator, 0, 2)."\n";; |
| 877 | 877 | if (count($airline_array) > 0) { |
| 878 | 878 | //print_r($airline_array); |
| 879 | - $operator = $airline_array[0]['icao'].substr($operator,2); |
|
| 879 | + $operator = $airline_array[0]['icao'].substr($operator, 2); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | |
@@ -884,14 +884,14 @@ discard block |
||
| 884 | 884 | if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) { |
| 885 | 885 | $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2)); |
| 886 | 886 | if (count($airline_array) > 0) { |
| 887 | - $operator_correct = $airline_array[0]['icao'].substr($operator_correct,2); |
|
| 887 | + $operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2); |
|
| 888 | 888 | } |
| 889 | 889 | } |
| 890 | 890 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 891 | 891 | try { |
| 892 | 892 | $sth = $Connection->db->prepare($query); |
| 893 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | - } catch(PDOException $e) { |
|
| 893 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv')); |
|
| 894 | + } catch (PDOException $e) { |
|
| 895 | 895 | return "error : ".$e->getMessage(); |
| 896 | 896 | } |
| 897 | 897 | } |
@@ -911,7 +911,7 @@ discard block |
||
| 911 | 911 | $Connection = new Connection(); |
| 912 | 912 | $sth = $Connection->db->prepare($query); |
| 913 | 913 | $sth->execute(array(':source' => 'website_fam')); |
| 914 | - } catch(PDOException $e) { |
|
| 914 | + } catch (PDOException $e) { |
|
| 915 | 915 | return "error : ".$e->getMessage(); |
| 916 | 916 | } |
| 917 | 917 | |
@@ -931,8 +931,8 @@ discard block |
||
| 931 | 931 | $query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)'; |
| 932 | 932 | try { |
| 933 | 933 | $sth = $Connection->db->prepare($query); |
| 934 | - $sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | - } catch(PDOException $e) { |
|
| 934 | + $sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam')); |
|
| 935 | + } catch (PDOException $e) { |
|
| 936 | 936 | return "error : ".$e->getMessage(); |
| 937 | 937 | } |
| 938 | 938 | } |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | return ''; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - public static function tle($filename,$tletype) { |
|
| 947 | + public static function tle($filename, $tletype) { |
|
| 948 | 948 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 949 | 949 | global $tmp_dir, $globalTransaction; |
| 950 | 950 | //$Spotter = new Spotter(); |
@@ -954,7 +954,7 @@ discard block |
||
| 954 | 954 | $Connection = new Connection(); |
| 955 | 955 | $sth = $Connection->db->prepare($query); |
| 956 | 956 | $sth->execute(array(':source' => $filename)); |
| 957 | - } catch(PDOException $e) { |
|
| 957 | + } catch (PDOException $e) { |
|
| 958 | 958 | return "error : ".$e->getMessage(); |
| 959 | 959 | } |
| 960 | 960 | |
@@ -979,8 +979,8 @@ discard block |
||
| 979 | 979 | $query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)'; |
| 980 | 980 | try { |
| 981 | 981 | $sth = $Connection->db->prepare($query); |
| 982 | - $sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename)); |
|
| 983 | - } catch(PDOException $e) { |
|
| 982 | + $sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename)); |
|
| 983 | + } catch (PDOException $e) { |
|
| 984 | 984 | return "error : ".$e->getMessage(); |
| 985 | 985 | } |
| 986 | 986 | |
@@ -1000,28 +1000,28 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | private static function table2array($data) { |
| 1002 | 1002 | $html = str_get_html($data); |
| 1003 | - $tabledata=array(); |
|
| 1004 | - foreach($html->find('tr') as $element) |
|
| 1003 | + $tabledata = array(); |
|
| 1004 | + foreach ($html->find('tr') as $element) |
|
| 1005 | 1005 | { |
| 1006 | 1006 | $td = array(); |
| 1007 | - foreach( $element->find('th') as $row) |
|
| 1007 | + foreach ($element->find('th') as $row) |
|
| 1008 | 1008 | { |
| 1009 | 1009 | $td [] = trim($row->plaintext); |
| 1010 | 1010 | } |
| 1011 | - $td=array_filter($td); |
|
| 1011 | + $td = array_filter($td); |
|
| 1012 | 1012 | $tabledata[] = $td; |
| 1013 | 1013 | |
| 1014 | 1014 | $td = array(); |
| 1015 | 1015 | $tdi = array(); |
| 1016 | - foreach( $element->find('td') as $row) |
|
| 1016 | + foreach ($element->find('td') as $row) |
|
| 1017 | 1017 | { |
| 1018 | 1018 | $td [] = trim($row->plaintext); |
| 1019 | 1019 | $tdi [] = trim($row->innertext); |
| 1020 | 1020 | } |
| 1021 | - $td=array_filter($td); |
|
| 1022 | - $tdi=array_filter($tdi); |
|
| 1021 | + $td = array_filter($td); |
|
| 1022 | + $tdi = array_filter($tdi); |
|
| 1023 | 1023 | // $tabledata[]=array_merge($td,$tdi); |
| 1024 | - $tabledata[]=$td; |
|
| 1024 | + $tabledata[] = $td; |
|
| 1025 | 1025 | } |
| 1026 | 1026 | return(array_filter($tabledata)); |
| 1027 | 1027 | } |
@@ -1094,13 +1094,13 @@ discard block |
||
| 1094 | 1094 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1095 | { |
| 1096 | 1096 | $i++; |
| 1097 | - if($i > 3 && count($row) > 2) { |
|
| 1097 | + if ($i > 3 && count($row) > 2) { |
|
| 1098 | 1098 | $data = array_values(array_filter($row)); |
| 1099 | 1099 | $cntdata = count($data); |
| 1100 | 1100 | if ($cntdata > 10) { |
| 1101 | 1101 | $value = $data[9]; |
| 1102 | 1102 | |
| 1103 | - for ($i =10;$i < $cntdata;$i++) { |
|
| 1103 | + for ($i = 10; $i < $cntdata; $i++) { |
|
| 1104 | 1104 | $value .= ' '.$data[$i]; |
| 1105 | 1105 | } |
| 1106 | 1106 | $data[9] = $value; |
@@ -1110,8 +1110,8 @@ discard block |
||
| 1110 | 1110 | $query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)'; |
| 1111 | 1111 | try { |
| 1112 | 1112 | $sth = $Connection->db->prepare($query); |
| 1113 | - $sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1114 | - } catch(PDOException $e) { |
|
| 1113 | + $sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9])); |
|
| 1114 | + } catch (PDOException $e) { |
|
| 1115 | 1115 | return "error : ".$e->getMessage(); |
| 1116 | 1116 | } |
| 1117 | 1117 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | $Connection = new Connection(); |
| 1133 | 1133 | $sth = $Connection->db->prepare($query); |
| 1134 | 1134 | $sth->execute(); |
| 1135 | - } catch(PDOException $e) { |
|
| 1135 | + } catch (PDOException $e) { |
|
| 1136 | 1136 | return "error : ".$e->getMessage(); |
| 1137 | 1137 | } |
| 1138 | 1138 | |
@@ -1144,12 +1144,12 @@ discard block |
||
| 1144 | 1144 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 1145 | 1145 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1146 | { |
| 1147 | - if(count($row) > 1) { |
|
| 1147 | + if (count($row) > 1) { |
|
| 1148 | 1148 | $query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')"; |
| 1149 | 1149 | try { |
| 1150 | 1150 | $sth = $Connection->db->prepare($query); |
| 1151 | - $sth->execute(array(':name' => $row[1],':icao' => $row[0])); |
|
| 1152 | - } catch(PDOException $e) { |
|
| 1151 | + $sth->execute(array(':name' => $row[1], ':icao' => $row[0])); |
|
| 1152 | + } catch (PDOException $e) { |
|
| 1153 | 1153 | return "error : ".$e->getMessage(); |
| 1154 | 1154 | } |
| 1155 | 1155 | } |
@@ -1169,21 +1169,21 @@ discard block |
||
| 1169 | 1169 | try { |
| 1170 | 1170 | $sth = $Connection->db->prepare($query); |
| 1171 | 1171 | $sth->execute(); |
| 1172 | - } catch(PDOException $e) { |
|
| 1172 | + } catch (PDOException $e) { |
|
| 1173 | 1173 | return "error : ".$e->getMessage(); |
| 1174 | 1174 | } |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1178 | + if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1179 | 1179 | else { |
| 1180 | - update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1180 | + update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql'); |
|
| 1181 | 1181 | $query = "CREATE EXTENSION postgis"; |
| 1182 | - $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
|
| 1182 | + $Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']); |
|
| 1183 | 1183 | try { |
| 1184 | 1184 | $sth = $Connection->db->prepare($query); |
| 1185 | 1185 | $sth->execute(); |
| 1186 | - } catch(PDOException $e) { |
|
| 1186 | + } catch (PDOException $e) { |
|
| 1187 | 1187 | return "error : ".$e->getMessage(); |
| 1188 | 1188 | } |
| 1189 | 1189 | } |
@@ -1196,7 +1196,7 @@ discard block |
||
| 1196 | 1196 | include_once('class.create_db.php'); |
| 1197 | 1197 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | 1198 | if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
| 1199 | - update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
|
| 1199 | + update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz'); |
|
| 1200 | 1200 | $error = ''; |
| 1201 | 1201 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1202 | 1202 | if ($globalDebug) echo "Gunzip..."; |
@@ -1228,14 +1228,14 @@ discard block |
||
| 1228 | 1228 | try { |
| 1229 | 1229 | $sth = $Connection->db->prepare($query); |
| 1230 | 1230 | $sth->execute(); |
| 1231 | - } catch(PDOException $e) { |
|
| 1231 | + } catch (PDOException $e) { |
|
| 1232 | 1232 | echo "error : ".$e->getMessage(); |
| 1233 | 1233 | } |
| 1234 | 1234 | } |
| 1235 | 1235 | if ($globalDBdriver == 'mysql') { |
| 1236 | - update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1236 | + update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1237 | 1237 | } else { |
| 1238 | - update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql'); |
|
| 1238 | + update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql'); |
|
| 1239 | 1239 | } |
| 1240 | 1240 | $error = create_db::import_file($tmp_dir.'countries.sql'); |
| 1241 | 1241 | return $error; |
@@ -1248,7 +1248,7 @@ discard block |
||
| 1248 | 1248 | // update_db::unzip($tmp_dir.'AptNav.zip'); |
| 1249 | 1249 | // update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz'); |
| 1250 | 1250 | // update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
| 1251 | - update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net'); |
|
| 1251 | + update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net'); |
|
| 1252 | 1252 | update_db::gunzip($tmp_dir.'awy.dat.gz'); |
| 1253 | 1253 | $error = update_db::waypoints($tmp_dir.'awy.dat'); |
| 1254 | 1254 | return $error; |
@@ -1268,7 +1268,7 @@ discard block |
||
| 1268 | 1268 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1269 | 1269 | if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
| 1270 | 1270 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1271 | + if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1272 | 1272 | } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
| 1273 | 1273 | } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
| 1274 | 1274 | if ($error != '') { |
@@ -1281,7 +1281,7 @@ discard block |
||
| 1281 | 1281 | global $tmp_dir, $globalDebug; |
| 1282 | 1282 | $error = ''; |
| 1283 | 1283 | if ($globalDebug) echo "Routes : Download..."; |
| 1284 | - update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
|
| 1284 | + update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz'); |
|
| 1285 | 1285 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1286 | 1286 | if ($globalDebug) echo "Gunzip..."; |
| 1287 | 1287 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | global $tmp_dir, $globalDebug; |
| 1298 | 1298 | $error = ''; |
| 1299 | 1299 | if ($globalDebug) echo "Schedules Oneworld : Download..."; |
| 1300 | - update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
|
| 1300 | + update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz'); |
|
| 1301 | 1301 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1302 | 1302 | if ($globalDebug) echo "Gunzip..."; |
| 1303 | 1303 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | global $tmp_dir, $globalDebug; |
| 1314 | 1314 | $error = ''; |
| 1315 | 1315 | if ($globalDebug) echo "Schedules Skyteam : Download..."; |
| 1316 | - update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
|
| 1316 | + update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz'); |
|
| 1317 | 1317 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1318 | 1318 | if ($globalDebug) echo "Gunzip..."; |
| 1319 | 1319 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
@@ -1340,7 +1340,7 @@ discard block |
||
| 1340 | 1340 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1341 | */ |
| 1342 | 1342 | if ($globalDebug) echo "Modes : Download..."; |
| 1343 | - update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
|
| 1343 | + update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip', $tmp_dir.'basestation_latest.zip', 'http://planebase.biz/bstnsqb'); |
|
| 1344 | 1344 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1345 | 1345 | if ($globalDebug) echo "Unzip..."; |
| 1346 | 1346 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
@@ -1356,7 +1356,7 @@ discard block |
||
| 1356 | 1356 | public static function update_ModeS_flarm() { |
| 1357 | 1357 | global $tmp_dir, $globalDebug; |
| 1358 | 1358 | if ($globalDebug) echo "Modes Flarmnet: Download..."; |
| 1359 | - update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
|
| 1359 | + update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln'); |
|
| 1360 | 1360 | if (file_exists($tmp_dir.'data.fln')) { |
| 1361 | 1361 | if ($globalDebug) echo "Add to DB..."; |
| 1362 | 1362 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | public static function update_ModeS_ogn() { |
| 1371 | 1371 | global $tmp_dir, $globalDebug; |
| 1372 | 1372 | if ($globalDebug) echo "Modes OGN: Download..."; |
| 1373 | - update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
|
| 1373 | + update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv'); |
|
| 1374 | 1374 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1375 | 1375 | if ($globalDebug) echo "Add to DB..."; |
| 1376 | 1376 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
@@ -1385,173 +1385,173 @@ discard block |
||
| 1385 | 1385 | global $tmp_dir, $globalDebug; |
| 1386 | 1386 | |
| 1387 | 1387 | if ($globalDebug) echo "Owner France: Download..."; |
| 1388 | - update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
|
| 1388 | + update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv'); |
|
| 1389 | 1389 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1390 | 1390 | if ($globalDebug) echo "Add to DB..."; |
| 1391 | - $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
|
| 1391 | + $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F'); |
|
| 1392 | 1392 | } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
| 1393 | 1393 | if ($error != '') { |
| 1394 | 1394 | return $error; |
| 1395 | 1395 | } elseif ($globalDebug) echo "Done\n"; |
| 1396 | 1396 | |
| 1397 | 1397 | if ($globalDebug) echo "Owner Ireland: Download..."; |
| 1398 | - update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
|
| 1398 | + update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv'); |
|
| 1399 | 1399 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1400 | 1400 | if ($globalDebug) echo "Add to DB..."; |
| 1401 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
|
| 1401 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI'); |
|
| 1402 | 1402 | } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
| 1403 | 1403 | if ($error != '') { |
| 1404 | 1404 | return $error; |
| 1405 | 1405 | } elseif ($globalDebug) echo "Done\n"; |
| 1406 | 1406 | if ($globalDebug) echo "Owner Switzerland: Download..."; |
| 1407 | - update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
|
| 1407 | + update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv'); |
|
| 1408 | 1408 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1409 | 1409 | if ($globalDebug) echo "Add to DB..."; |
| 1410 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
|
| 1410 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB'); |
|
| 1411 | 1411 | } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
| 1412 | 1412 | if ($error != '') { |
| 1413 | 1413 | return $error; |
| 1414 | 1414 | } elseif ($globalDebug) echo "Done\n"; |
| 1415 | 1415 | if ($globalDebug) echo "Owner Czech Republic: Download..."; |
| 1416 | - update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
|
| 1416 | + update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv'); |
|
| 1417 | 1417 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1418 | 1418 | if ($globalDebug) echo "Add to DB..."; |
| 1419 | - $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
|
| 1419 | + $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK'); |
|
| 1420 | 1420 | } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
| 1421 | 1421 | if ($error != '') { |
| 1422 | 1422 | return $error; |
| 1423 | 1423 | } elseif ($globalDebug) echo "Done\n"; |
| 1424 | 1424 | if ($globalDebug) echo "Owner Australia: Download..."; |
| 1425 | - update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
|
| 1425 | + update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv'); |
|
| 1426 | 1426 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1427 | 1427 | if ($globalDebug) echo "Add to DB..."; |
| 1428 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
|
| 1428 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH'); |
|
| 1429 | 1429 | } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
| 1430 | 1430 | if ($error != '') { |
| 1431 | 1431 | return $error; |
| 1432 | 1432 | } elseif ($globalDebug) echo "Done\n"; |
| 1433 | 1433 | if ($globalDebug) echo "Owner Austria: Download..."; |
| 1434 | - update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
|
| 1434 | + update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv'); |
|
| 1435 | 1435 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1436 | 1436 | if ($globalDebug) echo "Add to DB..."; |
| 1437 | - $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
|
| 1437 | + $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE'); |
|
| 1438 | 1438 | } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
| 1439 | 1439 | if ($error != '') { |
| 1440 | 1440 | return $error; |
| 1441 | 1441 | } elseif ($globalDebug) echo "Done\n"; |
| 1442 | 1442 | if ($globalDebug) echo "Owner Chile: Download..."; |
| 1443 | - update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
|
| 1443 | + update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv'); |
|
| 1444 | 1444 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1445 | 1445 | if ($globalDebug) echo "Add to DB..."; |
| 1446 | - $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
|
| 1446 | + $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC'); |
|
| 1447 | 1447 | } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
| 1448 | 1448 | if ($error != '') { |
| 1449 | 1449 | return $error; |
| 1450 | 1450 | } elseif ($globalDebug) echo "Done\n"; |
| 1451 | 1451 | if ($globalDebug) echo "Owner Colombia: Download..."; |
| 1452 | - update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
|
| 1452 | + update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv'); |
|
| 1453 | 1453 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1454 | 1454 | if ($globalDebug) echo "Add to DB..."; |
| 1455 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
|
| 1455 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ'); |
|
| 1456 | 1456 | } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
| 1457 | 1457 | if ($error != '') { |
| 1458 | 1458 | return $error; |
| 1459 | 1459 | } elseif ($globalDebug) echo "Done\n"; |
| 1460 | 1460 | if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
| 1461 | - update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
|
| 1461 | + update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv'); |
|
| 1462 | 1462 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1463 | 1463 | if ($globalDebug) echo "Add to DB..."; |
| 1464 | - $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
|
| 1464 | + $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7'); |
|
| 1465 | 1465 | } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
| 1466 | 1466 | if ($error != '') { |
| 1467 | 1467 | return $error; |
| 1468 | 1468 | } elseif ($globalDebug) echo "Done\n"; |
| 1469 | 1469 | if ($globalDebug) echo "Owner Brazil: Download..."; |
| 1470 | - update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
|
| 1470 | + update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv'); |
|
| 1471 | 1471 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1472 | 1472 | if ($globalDebug) echo "Add to DB..."; |
| 1473 | - $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
|
| 1473 | + $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP'); |
|
| 1474 | 1474 | } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
| 1475 | 1475 | if ($error != '') { |
| 1476 | 1476 | return $error; |
| 1477 | 1477 | } elseif ($globalDebug) echo "Done\n"; |
| 1478 | 1478 | if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
| 1479 | - update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
|
| 1479 | + update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv'); |
|
| 1480 | 1480 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1481 | 1481 | if ($globalDebug) echo "Add to DB..."; |
| 1482 | - $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
|
| 1482 | + $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP'); |
|
| 1483 | 1483 | } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
| 1484 | 1484 | if ($error != '') { |
| 1485 | 1485 | return $error; |
| 1486 | 1486 | } elseif ($globalDebug) echo "Done\n"; |
| 1487 | 1487 | if ($globalDebug) echo "Owner Croatia: Download..."; |
| 1488 | - update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
|
| 1488 | + update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv'); |
|
| 1489 | 1489 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1490 | 1490 | if ($globalDebug) echo "Add to DB..."; |
| 1491 | - $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
|
| 1491 | + $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A'); |
|
| 1492 | 1492 | } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
| 1493 | 1493 | if ($error != '') { |
| 1494 | 1494 | return $error; |
| 1495 | 1495 | } elseif ($globalDebug) echo "Done\n"; |
| 1496 | 1496 | if ($globalDebug) echo "Owner Luxembourg: Download..."; |
| 1497 | - update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
|
| 1497 | + update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv'); |
|
| 1498 | 1498 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1499 | 1499 | if ($globalDebug) echo "Add to DB..."; |
| 1500 | - $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
|
| 1500 | + $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX'); |
|
| 1501 | 1501 | } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
| 1502 | 1502 | if ($error != '') { |
| 1503 | 1503 | return $error; |
| 1504 | 1504 | } elseif ($globalDebug) echo "Done\n"; |
| 1505 | 1505 | if ($globalDebug) echo "Owner Maldives: Download..."; |
| 1506 | - update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
|
| 1506 | + update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv'); |
|
| 1507 | 1507 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1508 | 1508 | if ($globalDebug) echo "Add to DB..."; |
| 1509 | - $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
|
| 1509 | + $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q'); |
|
| 1510 | 1510 | } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
| 1511 | 1511 | if ($error != '') { |
| 1512 | 1512 | return $error; |
| 1513 | 1513 | } elseif ($globalDebug) echo "Done\n"; |
| 1514 | 1514 | if ($globalDebug) echo "Owner New Zealand: Download..."; |
| 1515 | - update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
|
| 1515 | + update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv'); |
|
| 1516 | 1516 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1517 | 1517 | if ($globalDebug) echo "Add to DB..."; |
| 1518 | - $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
|
| 1518 | + $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK'); |
|
| 1519 | 1519 | } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
| 1520 | 1520 | if ($error != '') { |
| 1521 | 1521 | return $error; |
| 1522 | 1522 | } elseif ($globalDebug) echo "Done\n"; |
| 1523 | 1523 | if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
| 1524 | - update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
|
| 1524 | + update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv'); |
|
| 1525 | 1525 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1526 | 1526 | if ($globalDebug) echo "Add to DB..."; |
| 1527 | - $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
|
| 1527 | + $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2'); |
|
| 1528 | 1528 | } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
| 1529 | 1529 | if ($error != '') { |
| 1530 | 1530 | return $error; |
| 1531 | 1531 | } elseif ($globalDebug) echo "Done\n"; |
| 1532 | 1532 | if ($globalDebug) echo "Owner Slovakia: Download..."; |
| 1533 | - update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
|
| 1533 | + update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv'); |
|
| 1534 | 1534 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1535 | 1535 | if ($globalDebug) echo "Add to DB..."; |
| 1536 | - $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
|
| 1536 | + $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM'); |
|
| 1537 | 1537 | } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
| 1538 | 1538 | if ($error != '') { |
| 1539 | 1539 | return $error; |
| 1540 | 1540 | } elseif ($globalDebug) echo "Done\n"; |
| 1541 | 1541 | if ($globalDebug) echo "Owner Ecuador: Download..."; |
| 1542 | - update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
|
| 1542 | + update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv'); |
|
| 1543 | 1543 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1544 | 1544 | if ($globalDebug) echo "Add to DB..."; |
| 1545 | - $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
|
| 1545 | + $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC'); |
|
| 1546 | 1546 | } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
| 1547 | 1547 | if ($error != '') { |
| 1548 | 1548 | return $error; |
| 1549 | 1549 | } elseif ($globalDebug) echo "Done\n"; |
| 1550 | 1550 | if ($globalDebug) echo "Owner Iceland: Download..."; |
| 1551 | - update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
|
| 1551 | + update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv'); |
|
| 1552 | 1552 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1553 | 1553 | if ($globalDebug) echo "Add to DB..."; |
| 1554 | - $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
|
| 1554 | + $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF'); |
|
| 1555 | 1555 | } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
| 1556 | 1556 | if ($error != '') { |
| 1557 | 1557 | return $error; |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | global $tmp_dir, $globalDebug; |
| 1564 | 1564 | $error = ''; |
| 1565 | 1565 | if ($globalDebug) echo "Translation : Download..."; |
| 1566 | - update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
|
| 1566 | + update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip'); |
|
| 1567 | 1567 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1568 | 1568 | if ($globalDebug) echo "Unzip..."; |
| 1569 | 1569 | update_db::unzip($tmp_dir.'translation.zip'); |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | public static function update_translation_fam() { |
| 1580 | 1580 | global $tmp_dir, $globalDebug; |
| 1581 | 1581 | if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
| 1582 | - update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
|
| 1582 | + update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz'); |
|
| 1583 | 1583 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1584 | 1584 | if ($globalDebug) echo "Gunzip..."; |
| 1585 | 1585 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
@@ -1597,18 +1597,18 @@ discard block |
||
| 1597 | 1597 | include_once('class.create_db.php'); |
| 1598 | 1598 | if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
| 1599 | 1599 | if ($globalDBdriver == 'mysql') { |
| 1600 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1600 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1601 | 1601 | } else { |
| 1602 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
|
| 1602 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5'); |
|
| 1603 | 1603 | } |
| 1604 | 1604 | if (file_exists($tmp_dir.'airspace.sql.gz.md5')) { |
| 1605 | - $airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1605 | + $airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5')); |
|
| 1606 | 1606 | $airspace_md5 = $airspace_md5_file[0]; |
| 1607 | 1607 | if (!update_db::check_airspace_version($airspace_md5)) { |
| 1608 | 1608 | if ($globalDBdriver == 'mysql') { |
| 1609 | - update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1609 | + update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1610 | 1610 | } else { |
| 1611 | - update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
|
| 1611 | + update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz'); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1614 | 1614 | if ($globalDebug) echo "Gunzip..."; |
@@ -1620,7 +1620,7 @@ discard block |
||
| 1620 | 1620 | try { |
| 1621 | 1621 | $sth = $Connection->db->prepare($query); |
| 1622 | 1622 | $sth->execute(); |
| 1623 | - } catch(PDOException $e) { |
|
| 1623 | + } catch (PDOException $e) { |
|
| 1624 | 1624 | return "error : ".$e->getMessage(); |
| 1625 | 1625 | } |
| 1626 | 1626 | } |
@@ -1638,15 +1638,15 @@ discard block |
||
| 1638 | 1638 | public static function update_tle() { |
| 1639 | 1639 | global $tmp_dir, $globalDebug; |
| 1640 | 1640 | if ($globalDebug) echo "Download TLE : Download..."; |
| 1641 | - $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
|
| 1642 | - 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
|
| 1643 | - 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
|
| 1641 | + $alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt', |
|
| 1642 | + 'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt', |
|
| 1643 | + 'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt'); |
|
| 1644 | 1644 | foreach ($alltle as $filename) { |
| 1645 | 1645 | if ($globalDebug) echo "downloading ".$filename.'...'; |
| 1646 | - update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
|
| 1646 | + update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename); |
|
| 1647 | 1647 | if (file_exists($tmp_dir.$filename)) { |
| 1648 | 1648 | if ($globalDebug) echo "Add to DB ".$filename."..."; |
| 1649 | - $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
|
| 1649 | + $error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename)); |
|
| 1650 | 1650 | } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
| 1651 | 1651 | if ($error != '') { |
| 1652 | 1652 | echo $error."\n"; |
@@ -1659,32 +1659,32 @@ discard block |
||
| 1659 | 1659 | global $tmp_dir, $globalDebug; |
| 1660 | 1660 | $error = ''; |
| 1661 | 1661 | if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
| 1662 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
|
| 1662 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum'); |
|
| 1663 | 1663 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1664 | 1664 | if ($globalDebug) echo "Check files...\n"; |
| 1665 | 1665 | $newmodelsdb = array(); |
| 1666 | - if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
|
| 1667 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1666 | + if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) { |
|
| 1667 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1668 | 1668 | $model = trim($row[2]); |
| 1669 | 1669 | $newmodelsdb[$model] = trim($row[0]); |
| 1670 | 1670 | } |
| 1671 | 1671 | } |
| 1672 | 1672 | $modelsdb = array(); |
| 1673 | 1673 | if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) { |
| 1674 | - if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) { |
|
| 1675 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1674 | + if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) { |
|
| 1675 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1676 | 1676 | $model = trim($row[2]); |
| 1677 | 1677 | $modelsdb[$model] = trim($row[0]); |
| 1678 | 1678 | } |
| 1679 | 1679 | } |
| 1680 | 1680 | } |
| 1681 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1681 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1682 | 1682 | foreach ($diff as $key => $value) { |
| 1683 | 1683 | if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
| 1684 | - update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
|
| 1684 | + update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key); |
|
| 1685 | 1685 | |
| 1686 | 1686 | } |
| 1687 | - update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1687 | + update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum'); |
|
| 1688 | 1688 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1689 | 1689 | if ($error != '') { |
| 1690 | 1690 | return $error; |
@@ -1696,32 +1696,32 @@ discard block |
||
| 1696 | 1696 | global $tmp_dir, $globalDebug; |
| 1697 | 1697 | $error = ''; |
| 1698 | 1698 | if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
| 1699 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
|
| 1699 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum'); |
|
| 1700 | 1700 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1701 | 1701 | if ($globalDebug) echo "Check files...\n"; |
| 1702 | 1702 | $newmodelsdb = array(); |
| 1703 | - if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
|
| 1704 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1703 | + if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) { |
|
| 1704 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1705 | 1705 | $model = trim($row[2]); |
| 1706 | 1706 | $newmodelsdb[$model] = trim($row[0]); |
| 1707 | 1707 | } |
| 1708 | 1708 | } |
| 1709 | 1709 | $modelsdb = array(); |
| 1710 | 1710 | if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) { |
| 1711 | - if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) { |
|
| 1712 | - while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
|
| 1711 | + if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) { |
|
| 1712 | + while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) { |
|
| 1713 | 1713 | $model = trim($row[2]); |
| 1714 | 1714 | $modelsdb[$model] = trim($row[0]); |
| 1715 | 1715 | } |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | - $diff = array_diff($newmodelsdb,$modelsdb); |
|
| 1718 | + $diff = array_diff($newmodelsdb, $modelsdb); |
|
| 1719 | 1719 | foreach ($diff as $key => $value) { |
| 1720 | 1720 | if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
| 1721 | - update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
|
| 1721 | + update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key); |
|
| 1722 | 1722 | |
| 1723 | 1723 | } |
| 1724 | - update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1724 | + update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum'); |
|
| 1725 | 1725 | } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
| 1726 | 1726 | if ($error != '') { |
| 1727 | 1727 | return $error; |
@@ -1744,8 +1744,8 @@ discard block |
||
| 1744 | 1744 | */ |
| 1745 | 1745 | if (file_exists($tmp_dir.'aircrafts.html')) { |
| 1746 | 1746 | //var_dump(file_get_html($tmp_dir.'aircrafts.html')); |
| 1747 | - $fh = fopen($tmp_dir.'aircrafts.html',"r"); |
|
| 1748 | - $result = fread($fh,100000000); |
|
| 1747 | + $fh = fopen($tmp_dir.'aircrafts.html', "r"); |
|
| 1748 | + $result = fread($fh, 100000000); |
|
| 1749 | 1749 | //echo $result; |
| 1750 | 1750 | //var_dump(str_get_html($result)); |
| 1751 | 1751 | //print_r(self::table2array($result)); |
@@ -1763,23 +1763,23 @@ discard block |
||
| 1763 | 1763 | $Connection = new Connection(); |
| 1764 | 1764 | $sth = $Connection->db->prepare($query); |
| 1765 | 1765 | $sth->execute(); |
| 1766 | - } catch(PDOException $e) { |
|
| 1766 | + } catch (PDOException $e) { |
|
| 1767 | 1767 | return "error : ".$e->getMessage(); |
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | $error = ''; |
| 1771 | 1771 | if ($globalDebug) echo "Notam : Download..."; |
| 1772 | - update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
|
| 1772 | + update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss'); |
|
| 1773 | 1773 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1774 | - $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
|
| 1774 | + $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true); |
|
| 1775 | 1775 | foreach ($notams['channel']['item'] as $notam) { |
| 1776 | - $title = explode(':',$notam['title']); |
|
| 1776 | + $title = explode(':', $notam['title']); |
|
| 1777 | 1777 | $data['ref'] = trim($title[0]); |
| 1778 | 1778 | unset($title[0]); |
| 1779 | - $data['title'] = trim(implode(':',$title)); |
|
| 1780 | - $description = strip_tags($notam['description'],'<pre>'); |
|
| 1781 | - preg_match(':^(.*?)<pre>:',$description,$match); |
|
| 1782 | - $q = explode('/',$match[1]); |
|
| 1779 | + $data['title'] = trim(implode(':', $title)); |
|
| 1780 | + $description = strip_tags($notam['description'], '<pre>'); |
|
| 1781 | + preg_match(':^(.*?)<pre>:', $description, $match); |
|
| 1782 | + $q = explode('/', $match[1]); |
|
| 1783 | 1783 | $data['fir'] = $q[0]; |
| 1784 | 1784 | $data['code'] = $q[1]; |
| 1785 | 1785 | $ifrvfr = $q[2]; |
@@ -1795,30 +1795,30 @@ discard block |
||
| 1795 | 1795 | $data['lower_limit'] = $q[5]; |
| 1796 | 1796 | $data['upper_limit'] = $q[6]; |
| 1797 | 1797 | $latlonrad = $q[7]; |
| 1798 | - sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
|
| 1799 | - $latitude = $Common->convertDec($las,'latitude'); |
|
| 1800 | - $longitude = $Common->convertDec($lns,'longitude'); |
|
| 1798 | + sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius); |
|
| 1799 | + $latitude = $Common->convertDec($las, 'latitude'); |
|
| 1800 | + $longitude = $Common->convertDec($lns, 'longitude'); |
|
| 1801 | 1801 | if ($lac == 'S') $latitude = '-'.$latitude; |
| 1802 | 1802 | if ($lnc == 'W') $longitude = '-'.$longitude; |
| 1803 | 1803 | $data['center_latitude'] = $latitude; |
| 1804 | 1804 | $data['center_longitude'] = $longitude; |
| 1805 | 1805 | $data['radius'] = intval($radius); |
| 1806 | 1806 | |
| 1807 | - preg_match(':<pre>(.*?)</pre>:',$description,$match); |
|
| 1807 | + preg_match(':<pre>(.*?)</pre>:', $description, $match); |
|
| 1808 | 1808 | $data['text'] = $match[1]; |
| 1809 | - preg_match(':</pre>(.*?)$:',$description,$match); |
|
| 1809 | + preg_match(':</pre>(.*?)$:', $description, $match); |
|
| 1810 | 1810 | $fromto = $match[1]; |
| 1811 | - preg_match('#FROM:(.*?)TO:#',$fromto,$match); |
|
| 1811 | + preg_match('#FROM:(.*?)TO:#', $fromto, $match); |
|
| 1812 | 1812 | $fromall = trim($match[1]); |
| 1813 | - preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match); |
|
| 1813 | + preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match); |
|
| 1814 | 1814 | $from = trim($match[1]); |
| 1815 | - $data['date_begin'] = date("Y-m-d H:i:s",strtotime($from)); |
|
| 1816 | - preg_match('#TO:(.*?)$#',$fromto,$match); |
|
| 1815 | + $data['date_begin'] = date("Y-m-d H:i:s", strtotime($from)); |
|
| 1816 | + preg_match('#TO:(.*?)$#', $fromto, $match); |
|
| 1817 | 1817 | $toall = trim($match[1]); |
| 1818 | - if (!preg_match(':Permanent:',$toall)) { |
|
| 1819 | - preg_match('#^(.*?) \((.*?)\)#',$toall,$match); |
|
| 1818 | + if (!preg_match(':Permanent:', $toall)) { |
|
| 1819 | + preg_match('#^(.*?) \((.*?)\)#', $toall, $match); |
|
| 1820 | 1820 | $to = trim($match[1]); |
| 1821 | - $data['date_end'] = date("Y-m-d H:i:s",strtotime($to)); |
|
| 1821 | + $data['date_end'] = date("Y-m-d H:i:s", strtotime($to)); |
|
| 1822 | 1822 | $data['permanent'] = 0; |
| 1823 | 1823 | } else { |
| 1824 | 1824 | $data['date_end'] = NULL; |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | } |
| 1827 | 1827 | $data['full_notam'] = $notam['title'].'<br>'.$notam['description']; |
| 1828 | 1828 | $NOTAM = new NOTAM(); |
| 1829 | - $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
|
| 1829 | + $NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']); |
|
| 1830 | 1830 | unset($data); |
| 1831 | 1831 | } |
| 1832 | 1832 | } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
@@ -1849,16 +1849,16 @@ discard block |
||
| 1849 | 1849 | $Connection = new Connection(); |
| 1850 | 1850 | $sth = $Connection->db->prepare($query); |
| 1851 | 1851 | $sth->execute(); |
| 1852 | - } catch(PDOException $e) { |
|
| 1852 | + } catch (PDOException $e) { |
|
| 1853 | 1853 | return "error : ".$e->getMessage(); |
| 1854 | 1854 | } |
| 1855 | 1855 | } |
| 1856 | 1856 | $Common = new Common(); |
| 1857 | 1857 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1858 | - $airspace_json = json_decode($airspace_lst,true); |
|
| 1858 | + $airspace_json = json_decode($airspace_lst, true); |
|
| 1859 | 1859 | foreach ($airspace_json['records'] as $airspace) { |
| 1860 | 1860 | if ($globalDebug) echo $airspace['name']."...\n"; |
| 1861 | - update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
|
| 1861 | + update_db::download($airspace['uri'], $tmp_dir.$airspace['name']); |
|
| 1862 | 1862 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1863 | 1863 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
| 1864 | 1864 | //system('recode l9..utf8 '.$tmp_dir.$airspace['name']); |
@@ -1882,7 +1882,7 @@ discard block |
||
| 1882 | 1882 | $Connection = new Connection(); |
| 1883 | 1883 | $sth = $Connection->db->prepare($query); |
| 1884 | 1884 | $sth->execute(); |
| 1885 | - } catch(PDOException $e) { |
|
| 1885 | + } catch (PDOException $e) { |
|
| 1886 | 1886 | return "error : ".$e->getMessage(); |
| 1887 | 1887 | } |
| 1888 | 1888 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | $Connection = new Connection(); |
| 1898 | 1898 | $sth = $Connection->db->prepare($query); |
| 1899 | 1899 | $sth->execute(); |
| 1900 | - } catch(PDOException $e) { |
|
| 1900 | + } catch (PDOException $e) { |
|
| 1901 | 1901 | return "error : ".$e->getMessage(); |
| 1902 | 1902 | } |
| 1903 | 1903 | } |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | $Connection = new Connection(); |
| 1909 | 1909 | $sth = $Connection->db->prepare($query); |
| 1910 | 1910 | $sth->execute(array(':version' => $version)); |
| 1911 | - } catch(PDOException $e) { |
|
| 1911 | + } catch (PDOException $e) { |
|
| 1912 | 1912 | return "error : ".$e->getMessage(); |
| 1913 | 1913 | } |
| 1914 | 1914 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1924,7 +1924,7 @@ discard block |
||
| 1924 | 1924 | $Connection = new Connection(); |
| 1925 | 1925 | $sth = $Connection->db->prepare($query); |
| 1926 | 1926 | $sth->execute(array(':version' => $version)); |
| 1927 | - } catch(PDOException $e) { |
|
| 1927 | + } catch (PDOException $e) { |
|
| 1928 | 1928 | return "error : ".$e->getMessage(); |
| 1929 | 1929 | } |
| 1930 | 1930 | } |
@@ -1940,7 +1940,7 @@ discard block |
||
| 1940 | 1940 | $Connection = new Connection(); |
| 1941 | 1941 | $sth = $Connection->db->prepare($query); |
| 1942 | 1942 | $sth->execute(); |
| 1943 | - } catch(PDOException $e) { |
|
| 1943 | + } catch (PDOException $e) { |
|
| 1944 | 1944 | return "error : ".$e->getMessage(); |
| 1945 | 1945 | } |
| 1946 | 1946 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1955,7 +1955,7 @@ discard block |
||
| 1955 | 1955 | $Connection = new Connection(); |
| 1956 | 1956 | $sth = $Connection->db->prepare($query); |
| 1957 | 1957 | $sth->execute(); |
| 1958 | - } catch(PDOException $e) { |
|
| 1958 | + } catch (PDOException $e) { |
|
| 1959 | 1959 | return "error : ".$e->getMessage(); |
| 1960 | 1960 | } |
| 1961 | 1961 | } |
@@ -1970,7 +1970,7 @@ discard block |
||
| 1970 | 1970 | $Connection = new Connection(); |
| 1971 | 1971 | $sth = $Connection->db->prepare($query); |
| 1972 | 1972 | $sth->execute(); |
| 1973 | - } catch(PDOException $e) { |
|
| 1973 | + } catch (PDOException $e) { |
|
| 1974 | 1974 | return "error : ".$e->getMessage(); |
| 1975 | 1975 | } |
| 1976 | 1976 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -1985,7 +1985,7 @@ discard block |
||
| 1985 | 1985 | $Connection = new Connection(); |
| 1986 | 1986 | $sth = $Connection->db->prepare($query); |
| 1987 | 1987 | $sth->execute(); |
| 1988 | - } catch(PDOException $e) { |
|
| 1988 | + } catch (PDOException $e) { |
|
| 1989 | 1989 | return "error : ".$e->getMessage(); |
| 1990 | 1990 | } |
| 1991 | 1991 | } |
@@ -2001,7 +2001,7 @@ discard block |
||
| 2001 | 2001 | $Connection = new Connection(); |
| 2002 | 2002 | $sth = $Connection->db->prepare($query); |
| 2003 | 2003 | $sth->execute(); |
| 2004 | - } catch(PDOException $e) { |
|
| 2004 | + } catch (PDOException $e) { |
|
| 2005 | 2005 | return "error : ".$e->getMessage(); |
| 2006 | 2006 | } |
| 2007 | 2007 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2016,7 +2016,7 @@ discard block |
||
| 2016 | 2016 | $Connection = new Connection(); |
| 2017 | 2017 | $sth = $Connection->db->prepare($query); |
| 2018 | 2018 | $sth->execute(); |
| 2019 | - } catch(PDOException $e) { |
|
| 2019 | + } catch (PDOException $e) { |
|
| 2020 | 2020 | return "error : ".$e->getMessage(); |
| 2021 | 2021 | } |
| 2022 | 2022 | } |
@@ -2031,7 +2031,7 @@ discard block |
||
| 2031 | 2031 | $Connection = new Connection(); |
| 2032 | 2032 | $sth = $Connection->db->prepare($query); |
| 2033 | 2033 | $sth->execute(); |
| 2034 | - } catch(PDOException $e) { |
|
| 2034 | + } catch (PDOException $e) { |
|
| 2035 | 2035 | return "error : ".$e->getMessage(); |
| 2036 | 2036 | } |
| 2037 | 2037 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2046,7 +2046,7 @@ discard block |
||
| 2046 | 2046 | $Connection = new Connection(); |
| 2047 | 2047 | $sth = $Connection->db->prepare($query); |
| 2048 | 2048 | $sth->execute(); |
| 2049 | - } catch(PDOException $e) { |
|
| 2049 | + } catch (PDOException $e) { |
|
| 2050 | 2050 | return "error : ".$e->getMessage(); |
| 2051 | 2051 | } |
| 2052 | 2052 | } |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | $Connection = new Connection(); |
| 2062 | 2062 | $sth = $Connection->db->prepare($query); |
| 2063 | 2063 | $sth->execute(); |
| 2064 | - } catch(PDOException $e) { |
|
| 2064 | + } catch (PDOException $e) { |
|
| 2065 | 2065 | return "error : ".$e->getMessage(); |
| 2066 | 2066 | } |
| 2067 | 2067 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -2076,7 +2076,7 @@ discard block |
||
| 2076 | 2076 | $Connection = new Connection(); |
| 2077 | 2077 | $sth = $Connection->db->prepare($query); |
| 2078 | 2078 | $sth->execute(); |
| 2079 | - } catch(PDOException $e) { |
|
| 2079 | + } catch (PDOException $e) { |
|
| 2080 | 2080 | return "error : ".$e->getMessage(); |
| 2081 | 2081 | } |
| 2082 | 2082 | } |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | curl_setopt($ch, CURLOPT_URL, $url); |
| 17 | 17 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
| 18 | 18 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 19 | - if ($referer != '') curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 19 | + if ($referer != '') { |
|
| 20 | + curl_setopt($ch, CURLOPT_REFERER, $referer); |
|
| 21 | + } |
|
| 20 | 22 | curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 21 | 23 | curl_setopt($ch, CURLOPT_FILE, $fp); |
| 22 | 24 | curl_exec($ch); |
@@ -27,12 +29,16 @@ discard block |
||
| 27 | 29 | public static function gunzip($in_file,$out_file_name = '') { |
| 28 | 30 | //echo $in_file.' -> '.$out_file_name."\n"; |
| 29 | 31 | $buffer_size = 4096; // read 4kb at a time |
| 30 | - if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); |
|
| 32 | + if ($out_file_name == '') { |
|
| 33 | + $out_file_name = str_replace('.gz', '', $in_file); |
|
| 34 | + } |
|
| 31 | 35 | if ($in_file != '' && file_exists($in_file)) { |
| 32 | 36 | // PHP version of Ubuntu use gzopen64 instead of gzopen |
| 33 | - if (function_exists('gzopen')) $file = gzopen($in_file,'rb'); |
|
| 34 | - elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb'); |
|
| 35 | - else { |
|
| 37 | + if (function_exists('gzopen')) { |
|
| 38 | + $file = gzopen($in_file,'rb'); |
|
| 39 | + } elseif (function_exists('gzopen64')) { |
|
| 40 | + $file = gzopen64($in_file,'rb'); |
|
| 41 | + } else { |
|
| 36 | 42 | echo 'gzopen not available'; |
| 37 | 43 | die; |
| 38 | 44 | } |
@@ -53,8 +59,12 @@ discard block |
||
| 53 | 59 | if ($res === TRUE) { |
| 54 | 60 | $zip->extractTo($path); |
| 55 | 61 | $zip->close(); |
| 56 | - } else return false; |
|
| 57 | - } else return false; |
|
| 62 | + } else { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | + } else { |
|
| 66 | + return false; |
|
| 67 | + } |
|
| 58 | 68 | } |
| 59 | 69 | |
| 60 | 70 | public static function connect_sqlite($database) { |
@@ -69,7 +79,9 @@ discard block |
||
| 69 | 79 | public static function retrieve_route_sqlite_to_dest($database_file) { |
| 70 | 80 | global $globalDebug, $globalTransaction; |
| 71 | 81 | //$query = 'TRUNCATE TABLE routes'; |
| 72 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 82 | + if ($globalDebug) { |
|
| 83 | + echo " - Delete previous routes from DB -"; |
|
| 84 | + } |
|
| 73 | 85 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 74 | 86 | $Connection = new Connection(); |
| 75 | 87 | try { |
@@ -80,7 +92,9 @@ discard block |
||
| 80 | 92 | return "error : ".$e->getMessage(); |
| 81 | 93 | } |
| 82 | 94 | |
| 83 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 95 | + if ($globalDebug) { |
|
| 96 | + echo " - Add routes to DB -"; |
|
| 97 | + } |
|
| 84 | 98 | update_db::connect_sqlite($database_file); |
| 85 | 99 | //$query = 'select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID'; |
| 86 | 100 | $query = "select Route.RouteID, Route.callsign, operator.Icao AS operator_icao, FromAir.Icao AS FromAirportIcao, ToAir.Icao AS ToAirportIcao, rstp.allstop AS AllStop from Route inner join operator ON Route.operatorId = operator.operatorId LEFT JOIN Airport AS FromAir ON route.FromAirportId = FromAir.AirportId LEFT JOIN Airport AS ToAir ON ToAir.AirportID = route.ToAirportID LEFT JOIN (select RouteId,GROUP_CONCAT(icao,' ') as allstop from routestop left join Airport as air ON routestop.AirportId = air.AirportID group by RouteID) AS rstp ON Route.RouteID = rstp.RouteID"; |
@@ -95,15 +109,21 @@ discard block |
||
| 95 | 109 | $Connection = new Connection(); |
| 96 | 110 | $sth_dest = $Connection->db->prepare($query_dest); |
| 97 | 111 | try { |
| 98 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 112 | + if ($globalTransaction) { |
|
| 113 | + $Connection->db->beginTransaction(); |
|
| 114 | + } |
|
| 99 | 115 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 100 | 116 | //$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 101 | 117 | $query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file); |
| 102 | 118 | $sth_dest->execute($query_dest_values); |
| 103 | 119 | } |
| 104 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 120 | + if ($globalTransaction) { |
|
| 121 | + $Connection->db->commit(); |
|
| 122 | + } |
|
| 105 | 123 | } catch(PDOException $e) { |
| 106 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 124 | + if ($globalTransaction) { |
|
| 125 | + $Connection->db->rollBack(); |
|
| 126 | + } |
|
| 107 | 127 | return "error : ".$e->getMessage(); |
| 108 | 128 | } |
| 109 | 129 | return ''; |
@@ -111,7 +131,9 @@ discard block |
||
| 111 | 131 | public static function retrieve_route_oneworld($database_file) { |
| 112 | 132 | global $globalDebug, $globalTransaction; |
| 113 | 133 | //$query = 'TRUNCATE TABLE routes'; |
| 114 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 134 | + if ($globalDebug) { |
|
| 135 | + echo " - Delete previous routes from DB -"; |
|
| 136 | + } |
|
| 115 | 137 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 116 | 138 | $Connection = new Connection(); |
| 117 | 139 | try { |
@@ -122,14 +144,18 @@ discard block |
||
| 122 | 144 | return "error : ".$e->getMessage(); |
| 123 | 145 | } |
| 124 | 146 | |
| 125 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 147 | + if ($globalDebug) { |
|
| 148 | + echo " - Add routes to DB -"; |
|
| 149 | + } |
|
| 126 | 150 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 127 | 151 | $Spotter = new Spotter(); |
| 128 | 152 | if ($fh = fopen($database_file,"r")) { |
| 129 | 153 | $query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)'; |
| 130 | 154 | $Connection = new Connection(); |
| 131 | 155 | $sth_dest = $Connection->db->prepare($query_dest); |
| 132 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 156 | + if ($globalTransaction) { |
|
| 157 | + $Connection->db->beginTransaction(); |
|
| 158 | + } |
|
| 133 | 159 | while (!feof($fh)) { |
| 134 | 160 | $line = fgetcsv($fh,9999,','); |
| 135 | 161 | if ($line[0] != '') { |
@@ -138,13 +164,17 @@ discard block |
||
| 138 | 164 | $query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld'); |
| 139 | 165 | $sth_dest->execute($query_dest_values); |
| 140 | 166 | } catch(PDOException $e) { |
| 141 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 167 | + if ($globalTransaction) { |
|
| 168 | + $Connection->db->rollBack(); |
|
| 169 | + } |
|
| 142 | 170 | return "error : ".$e->getMessage(); |
| 143 | 171 | } |
| 144 | 172 | } |
| 145 | 173 | } |
| 146 | 174 | } |
| 147 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 175 | + if ($globalTransaction) { |
|
| 176 | + $Connection->db->commit(); |
|
| 177 | + } |
|
| 148 | 178 | } |
| 149 | 179 | return ''; |
| 150 | 180 | } |
@@ -152,7 +182,9 @@ discard block |
||
| 152 | 182 | public static function retrieve_route_skyteam($database_file) { |
| 153 | 183 | global $globalDebug, $globalTransaction; |
| 154 | 184 | //$query = 'TRUNCATE TABLE routes'; |
| 155 | - if ($globalDebug) echo " - Delete previous routes from DB -"; |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo " - Delete previous routes from DB -"; |
|
| 187 | + } |
|
| 156 | 188 | $query = "DELETE FROM routes WHERE Source = '' OR Source = :source"; |
| 157 | 189 | $Connection = new Connection(); |
| 158 | 190 | try { |
@@ -163,7 +195,9 @@ discard block |
||
| 163 | 195 | return "error : ".$e->getMessage(); |
| 164 | 196 | } |
| 165 | 197 | |
| 166 | - if ($globalDebug) echo " - Add routes to DB -"; |
|
| 198 | + if ($globalDebug) { |
|
| 199 | + echo " - Add routes to DB -"; |
|
| 200 | + } |
|
| 167 | 201 | |
| 168 | 202 | require_once(dirname(__FILE__).'/../require/class.Spotter.php'); |
| 169 | 203 | $Spotter = new Spotter(); |
@@ -172,7 +206,9 @@ discard block |
||
| 172 | 206 | $Connection = new Connection(); |
| 173 | 207 | $sth_dest = $Connection->db->prepare($query_dest); |
| 174 | 208 | try { |
| 175 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 209 | + if ($globalTransaction) { |
|
| 210 | + $Connection->db->beginTransaction(); |
|
| 211 | + } |
|
| 176 | 212 | while (!feof($fh)) { |
| 177 | 213 | $line = fgetcsv($fh,9999,','); |
| 178 | 214 | if ($line[0] != '') { |
@@ -183,9 +219,13 @@ discard block |
||
| 183 | 219 | //} |
| 184 | 220 | } |
| 185 | 221 | } |
| 186 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 222 | + if ($globalTransaction) { |
|
| 223 | + $Connection->db->commit(); |
|
| 224 | + } |
|
| 187 | 225 | } catch(PDOException $e) { |
| 188 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 226 | + if ($globalTransaction) { |
|
| 227 | + $Connection->db->rollBack(); |
|
| 228 | + } |
|
| 189 | 229 | return "error : ".$e->getMessage(); |
| 190 | 230 | } |
| 191 | 231 | } |
@@ -228,11 +268,16 @@ discard block |
||
| 228 | 268 | $sth_dest = $Connection->db->prepare($query_dest); |
| 229 | 269 | $sth_dest_owner = $Connection->db->prepare($query_dest_owner); |
| 230 | 270 | try { |
| 231 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 271 | + if ($globalTransaction) { |
|
| 272 | + $Connection->db->beginTransaction(); |
|
| 273 | + } |
|
| 232 | 274 | while ($values = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 233 | 275 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
| 234 | - if ($values['UserString4'] == 'M') $type = 'military'; |
|
| 235 | - else $type = null; |
|
| 276 | + if ($values['UserString4'] == 'M') { |
|
| 277 | + $type = 'military'; |
|
| 278 | + } else { |
|
| 279 | + $type = null; |
|
| 280 | + } |
|
| 236 | 281 | $query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type); |
| 237 | 282 | $sth_dest->execute($query_dest_values); |
| 238 | 283 | if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') { |
@@ -240,7 +285,9 @@ discard block |
||
| 240 | 285 | $sth_dest_owner->execute($query_dest_owner_values); |
| 241 | 286 | } |
| 242 | 287 | } |
| 243 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 288 | + if ($globalTransaction) { |
|
| 289 | + $Connection->db->commit(); |
|
| 290 | + } |
|
| 244 | 291 | } catch(PDOException $e) { |
| 245 | 292 | return "error : ".$e->getMessage(); |
| 246 | 293 | } |
@@ -276,7 +323,9 @@ discard block |
||
| 276 | 323 | $Connection = new Connection(); |
| 277 | 324 | $sth_dest = $Connection->db->prepare($query_dest); |
| 278 | 325 | try { |
| 279 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 326 | + if ($globalTransaction) { |
|
| 327 | + $Connection->db->beginTransaction(); |
|
| 328 | + } |
|
| 280 | 329 | while (!feof($fh)) { |
| 281 | 330 | $values = array(); |
| 282 | 331 | $line = $Common->hex2str(fgets($fh,9999)); |
@@ -287,7 +336,9 @@ discard block |
||
| 287 | 336 | // Check if we can find ICAO, else set it to GLID |
| 288 | 337 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 289 | 338 | $search_more = ''; |
| 290 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 339 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 340 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 341 | + } |
|
| 291 | 342 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 292 | 343 | $sth_search = $Connection->db->prepare($query_search); |
| 293 | 344 | try { |
@@ -300,7 +351,9 @@ discard block |
||
| 300 | 351 | } catch(PDOException $e) { |
| 301 | 352 | return "error : ".$e->getMessage(); |
| 302 | 353 | } |
| 303 | - if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID'; |
|
| 354 | + if (!isset($values['ICAOTypeCode'])) { |
|
| 355 | + $values['ICAOTypeCode'] = 'GLID'; |
|
| 356 | + } |
|
| 304 | 357 | // Add data to db |
| 305 | 358 | if ($values['ModeS'] != '' && $values['Registration'] != '' && $values['Registration'] != '0000') { |
| 306 | 359 | //$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']); |
@@ -309,7 +362,9 @@ discard block |
||
| 309 | 362 | $sth_dest->execute($query_dest_values); |
| 310 | 363 | } |
| 311 | 364 | } |
| 312 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 365 | + if ($globalTransaction) { |
|
| 366 | + $Connection->db->commit(); |
|
| 367 | + } |
|
| 313 | 368 | } catch(PDOException $e) { |
| 314 | 369 | return "error : ".$e->getMessage(); |
| 315 | 370 | } |
@@ -345,7 +400,9 @@ discard block |
||
| 345 | 400 | $Connection = new Connection(); |
| 346 | 401 | $sth_dest = $Connection->db->prepare($query_dest); |
| 347 | 402 | try { |
| 348 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 403 | + if ($globalTransaction) { |
|
| 404 | + $Connection->db->beginTransaction(); |
|
| 405 | + } |
|
| 349 | 406 | $tmp = fgetcsv($fh,9999,',',"'"); |
| 350 | 407 | while (!feof($fh)) { |
| 351 | 408 | $line = fgetcsv($fh,9999,',',"'"); |
@@ -358,13 +415,17 @@ discard block |
||
| 358 | 415 | // Check if we can find ICAO, else set it to GLID |
| 359 | 416 | $aircraft_name_split = explode(' ',$aircraft_name); |
| 360 | 417 | $search_more = ''; |
| 361 | - if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 418 | + if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) { |
|
| 419 | + $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'"; |
|
| 420 | + } |
|
| 362 | 421 | $query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more; |
| 363 | 422 | $sth_search = $Connection->db->prepare($query_search); |
| 364 | 423 | try { |
| 365 | 424 | $sth_search->execute(); |
| 366 | 425 | $result = $sth_search->fetch(PDO::FETCH_ASSOC); |
| 367 | - if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao']; |
|
| 426 | + if (isset($result['icao']) && $result['icao'] != '') { |
|
| 427 | + $values['ICAOTypeCode'] = $result['icao']; |
|
| 428 | + } |
|
| 368 | 429 | } catch(PDOException $e) { |
| 369 | 430 | return "error : ".$e->getMessage(); |
| 370 | 431 | } |
@@ -377,7 +438,9 @@ discard block |
||
| 377 | 438 | $sth_dest->execute($query_dest_values); |
| 378 | 439 | } |
| 379 | 440 | } |
| 380 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 441 | + if ($globalTransaction) { |
|
| 442 | + $Connection->db->commit(); |
|
| 443 | + } |
|
| 381 | 444 | } catch(PDOException $e) { |
| 382 | 445 | return "error : ".$e->getMessage(); |
| 383 | 446 | } |
@@ -413,7 +476,9 @@ discard block |
||
| 413 | 476 | $Connection = new Connection(); |
| 414 | 477 | $sth_dest = $Connection->db->prepare($query_dest); |
| 415 | 478 | try { |
| 416 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 479 | + if ($globalTransaction) { |
|
| 480 | + $Connection->db->beginTransaction(); |
|
| 481 | + } |
|
| 417 | 482 | $tmp = fgetcsv($fh,9999,',','"'); |
| 418 | 483 | while (!feof($fh)) { |
| 419 | 484 | $line = fgetcsv($fh,9999,',','"'); |
@@ -423,16 +488,22 @@ discard block |
||
| 423 | 488 | $values['registration'] = $line[0]; |
| 424 | 489 | $values['base'] = $line[4]; |
| 425 | 490 | $values['owner'] = $line[5]; |
| 426 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 427 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 491 | + if ($line[6] == '') { |
|
| 492 | + $values['date_first_reg'] = null; |
|
| 493 | + } else { |
|
| 494 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 495 | + } |
|
| 428 | 496 | $values['cancel'] = $line[7]; |
| 429 | 497 | } elseif ($country == 'EI') { |
| 430 | 498 | // TODO : add modeS & reg to aircraft_modes |
| 431 | 499 | $values['registration'] = $line[0]; |
| 432 | 500 | $values['base'] = $line[3]; |
| 433 | 501 | $values['owner'] = $line[2]; |
| 434 | - if ($line[1] == '') $values['date_first_reg'] = null; |
|
| 435 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 502 | + if ($line[1] == '') { |
|
| 503 | + $values['date_first_reg'] = null; |
|
| 504 | + } else { |
|
| 505 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[1])); |
|
| 506 | + } |
|
| 436 | 507 | $values['cancel'] = ''; |
| 437 | 508 | } elseif ($country == 'HB') { |
| 438 | 509 | // TODO : add modeS & reg to aircraft_modes |
@@ -446,16 +517,22 @@ discard block |
||
| 446 | 517 | $values['registration'] = $line[3]; |
| 447 | 518 | $values['base'] = null; |
| 448 | 519 | $values['owner'] = $line[5]; |
| 449 | - if ($line[18] == '') $values['date_first_reg'] = null; |
|
| 450 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 520 | + if ($line[18] == '') { |
|
| 521 | + $values['date_first_reg'] = null; |
|
| 522 | + } else { |
|
| 523 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[18])); |
|
| 524 | + } |
|
| 451 | 525 | $values['cancel'] = ''; |
| 452 | 526 | } elseif ($country == 'VH') { |
| 453 | 527 | // TODO : add modeS & reg to aircraft_modes |
| 454 | 528 | $values['registration'] = $line[0]; |
| 455 | 529 | $values['base'] = null; |
| 456 | 530 | $values['owner'] = $line[12]; |
| 457 | - if ($line[28] == '') $values['date_first_reg'] = null; |
|
| 458 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 531 | + if ($line[28] == '') { |
|
| 532 | + $values['date_first_reg'] = null; |
|
| 533 | + } else { |
|
| 534 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[28])); |
|
| 535 | + } |
|
| 459 | 536 | |
| 460 | 537 | $values['cancel'] = $line[39]; |
| 461 | 538 | } elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') { |
@@ -474,29 +551,41 @@ discard block |
||
| 474 | 551 | $values['registration'] = $line[0]; |
| 475 | 552 | $values['base'] = null; |
| 476 | 553 | $values['owner'] = $line[8]; |
| 477 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 478 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 554 | + if ($line[7] == '') { |
|
| 555 | + $values['date_first_reg'] = null; |
|
| 556 | + } else { |
|
| 557 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 558 | + } |
|
| 479 | 559 | $values['cancel'] = ''; |
| 480 | 560 | } elseif ($country == 'PP') { |
| 481 | 561 | $values['registration'] = $line[0]; |
| 482 | 562 | $values['base'] = null; |
| 483 | 563 | $values['owner'] = $line[4]; |
| 484 | - if ($line[6] == '') $values['date_first_reg'] = null; |
|
| 485 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 564 | + if ($line[6] == '') { |
|
| 565 | + $values['date_first_reg'] = null; |
|
| 566 | + } else { |
|
| 567 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[6])); |
|
| 568 | + } |
|
| 486 | 569 | $values['cancel'] = $line[7]; |
| 487 | 570 | } elseif ($country == 'E7') { |
| 488 | 571 | $values['registration'] = $line[0]; |
| 489 | 572 | $values['base'] = null; |
| 490 | 573 | $values['owner'] = $line[4]; |
| 491 | - if ($line[5] == '') $values['date_first_reg'] = null; |
|
| 492 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 574 | + if ($line[5] == '') { |
|
| 575 | + $values['date_first_reg'] = null; |
|
| 576 | + } else { |
|
| 577 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[5])); |
|
| 578 | + } |
|
| 493 | 579 | $values['cancel'] = ''; |
| 494 | 580 | } elseif ($country == '8Q') { |
| 495 | 581 | $values['registration'] = $line[0]; |
| 496 | 582 | $values['base'] = null; |
| 497 | 583 | $values['owner'] = $line[3]; |
| 498 | - if ($line[7] == '') $values['date_first_reg'] = null; |
|
| 499 | - else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 584 | + if ($line[7] == '') { |
|
| 585 | + $values['date_first_reg'] = null; |
|
| 586 | + } else { |
|
| 587 | + $values['date_first_reg'] = date("Y-m-d",strtotime($line[7])); |
|
| 588 | + } |
|
| 500 | 589 | $values['cancel'] = ''; |
| 501 | 590 | } elseif ($country == 'ZK' || $country == 'OM' || $country == 'TF') { |
| 502 | 591 | $values['registration'] = $line[0]; |
@@ -510,7 +599,9 @@ discard block |
||
| 510 | 599 | $sth_dest->execute($query_dest_values); |
| 511 | 600 | } |
| 512 | 601 | } |
| 513 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 602 | + if ($globalTransaction) { |
|
| 603 | + $Connection->db->commit(); |
|
| 604 | + } |
|
| 514 | 605 | } catch(PDOException $e) { |
| 515 | 606 | return "error : ".$e->getMessage(); |
| 516 | 607 | } |
@@ -644,25 +735,45 @@ discard block |
||
| 644 | 735 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image_thumb, :image)"; |
| 645 | 736 | $Connection = new Connection(); |
| 646 | 737 | $sth_dest = $Connection->db->prepare($query_dest); |
| 647 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 738 | + if ($globalTransaction) { |
|
| 739 | + $Connection->db->beginTransaction(); |
|
| 740 | + } |
|
| 648 | 741 | |
| 649 | 742 | $i = 0; |
| 650 | 743 | while($row = sparql_fetch_array($result)) |
| 651 | 744 | { |
| 652 | 745 | if ($i >= 1) { |
| 653 | 746 | //print_r($row); |
| 654 | - if (!isset($row['iata'])) $row['iata'] = ''; |
|
| 655 | - if (!isset($row['icao'])) $row['icao'] = ''; |
|
| 656 | - if (!isset($row['type'])) $row['type'] = ''; |
|
| 657 | - if (!isset($row['altitude'])) $row['altitude'] = ''; |
|
| 747 | + if (!isset($row['iata'])) { |
|
| 748 | + $row['iata'] = ''; |
|
| 749 | + } |
|
| 750 | + if (!isset($row['icao'])) { |
|
| 751 | + $row['icao'] = ''; |
|
| 752 | + } |
|
| 753 | + if (!isset($row['type'])) { |
|
| 754 | + $row['type'] = ''; |
|
| 755 | + } |
|
| 756 | + if (!isset($row['altitude'])) { |
|
| 757 | + $row['altitude'] = ''; |
|
| 758 | + } |
|
| 658 | 759 | if (isset($row['city_bis'])) { |
| 659 | 760 | $row['city'] = $row['city_bis']; |
| 660 | 761 | } |
| 661 | - if (!isset($row['city'])) $row['city'] = ''; |
|
| 662 | - if (!isset($row['country'])) $row['country'] = ''; |
|
| 663 | - if (!isset($row['homepage'])) $row['homepage'] = ''; |
|
| 664 | - if (!isset($row['wikipedia_page'])) $row['wikipedia_page'] = ''; |
|
| 665 | - if (!isset($row['name'])) continue; |
|
| 762 | + if (!isset($row['city'])) { |
|
| 763 | + $row['city'] = ''; |
|
| 764 | + } |
|
| 765 | + if (!isset($row['country'])) { |
|
| 766 | + $row['country'] = ''; |
|
| 767 | + } |
|
| 768 | + if (!isset($row['homepage'])) { |
|
| 769 | + $row['homepage'] = ''; |
|
| 770 | + } |
|
| 771 | + if (!isset($row['wikipedia_page'])) { |
|
| 772 | + $row['wikipedia_page'] = ''; |
|
| 773 | + } |
|
| 774 | + if (!isset($row['name'])) { |
|
| 775 | + continue; |
|
| 776 | + } |
|
| 666 | 777 | if (!isset($row['image'])) { |
| 667 | 778 | $row['image'] = ''; |
| 668 | 779 | $row['image_thumb'] = ''; |
@@ -698,7 +809,9 @@ discard block |
||
| 698 | 809 | |
| 699 | 810 | $i++; |
| 700 | 811 | } |
| 701 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 812 | + if ($globalTransaction) { |
|
| 813 | + $Connection->db->commit(); |
|
| 814 | + } |
|
| 702 | 815 | echo "Delete duplicate rows...\n"; |
| 703 | 816 | $query = 'ALTER IGNORE TABLE airport ADD UNIQUE INDEX icaoidx (icao)'; |
| 704 | 817 | try { |
@@ -710,7 +823,9 @@ discard block |
||
| 710 | 823 | } |
| 711 | 824 | |
| 712 | 825 | |
| 713 | - if ($globalDebug) echo "Insert Not available Airport...\n"; |
|
| 826 | + if ($globalDebug) { |
|
| 827 | + echo "Insert Not available Airport...\n"; |
|
| 828 | + } |
|
| 714 | 829 | $query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`) |
| 715 | 830 | VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)"; |
| 716 | 831 | $query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => ''); |
@@ -737,7 +852,9 @@ discard block |
||
| 737 | 852 | $delimiter = ','; |
| 738 | 853 | $out_file = $tmp_dir.'airports.csv'; |
| 739 | 854 | update_db::download('http://ourairports.com/data/airports.csv',$out_file); |
| 740 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 855 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 856 | + return FALSE; |
|
| 857 | + } |
|
| 741 | 858 | echo "Add data from ourairports.com...\n"; |
| 742 | 859 | |
| 743 | 860 | $header = NULL; |
@@ -747,8 +864,9 @@ discard block |
||
| 747 | 864 | //$Connection->db->beginTransaction(); |
| 748 | 865 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 749 | 866 | { |
| 750 | - if(!$header) $header = $row; |
|
| 751 | - else { |
|
| 867 | + if(!$header) { |
|
| 868 | + $header = $row; |
|
| 869 | + } else { |
|
| 752 | 870 | $data = array(); |
| 753 | 871 | $data = array_combine($header, $row); |
| 754 | 872 | try { |
@@ -786,7 +904,9 @@ discard block |
||
| 786 | 904 | echo "Download data from another free database...\n"; |
| 787 | 905 | $out_file = $tmp_dir.'GlobalAirportDatabase.zip'; |
| 788 | 906 | update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file); |
| 789 | - if (!file_exists($out_file) || !is_readable($out_file)) return FALSE; |
|
| 907 | + if (!file_exists($out_file) || !is_readable($out_file)) { |
|
| 908 | + return FALSE; |
|
| 909 | + } |
|
| 790 | 910 | update_db::unzip($out_file); |
| 791 | 911 | $header = NULL; |
| 792 | 912 | echo "Add data from another free database...\n"; |
@@ -797,8 +917,9 @@ discard block |
||
| 797 | 917 | //$Connection->db->beginTransaction(); |
| 798 | 918 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 799 | 919 | { |
| 800 | - if(!$header) $header = $row; |
|
| 801 | - else { |
|
| 920 | + if(!$header) { |
|
| 921 | + $header = $row; |
|
| 922 | + } else { |
|
| 802 | 923 | $data = $row; |
| 803 | 924 | |
| 804 | 925 | $query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao'; |
@@ -1090,7 +1211,9 @@ discard block |
||
| 1090 | 1211 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1091 | 1212 | { |
| 1092 | 1213 | $i = 0; |
| 1093 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1214 | + if ($globalTransaction) { |
|
| 1215 | + $Connection->db->beginTransaction(); |
|
| 1216 | + } |
|
| 1094 | 1217 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1095 | 1218 | { |
| 1096 | 1219 | $i++; |
@@ -1118,7 +1241,9 @@ discard block |
||
| 1118 | 1241 | } |
| 1119 | 1242 | } |
| 1120 | 1243 | fclose($handle); |
| 1121 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1244 | + if ($globalTransaction) { |
|
| 1245 | + $Connection->db->commit(); |
|
| 1246 | + } |
|
| 1122 | 1247 | } |
| 1123 | 1248 | return ''; |
| 1124 | 1249 | } |
@@ -1141,7 +1266,9 @@ discard block |
||
| 1141 | 1266 | $Connection = new Connection(); |
| 1142 | 1267 | if (($handle = fopen($filename, 'r')) !== FALSE) |
| 1143 | 1268 | { |
| 1144 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 1269 | + if ($globalTransaction) { |
|
| 1270 | + $Connection->db->beginTransaction(); |
|
| 1271 | + } |
|
| 1145 | 1272 | while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) |
| 1146 | 1273 | { |
| 1147 | 1274 | if(count($row) > 1) { |
@@ -1155,7 +1282,9 @@ discard block |
||
| 1155 | 1282 | } |
| 1156 | 1283 | } |
| 1157 | 1284 | fclose($handle); |
| 1158 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 1285 | + if ($globalTransaction) { |
|
| 1286 | + $Connection->db->commit(); |
|
| 1287 | + } |
|
| 1159 | 1288 | } |
| 1160 | 1289 | return ''; |
| 1161 | 1290 | } |
@@ -1175,8 +1304,9 @@ discard block |
||
| 1175 | 1304 | } |
| 1176 | 1305 | |
| 1177 | 1306 | |
| 1178 | - if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1179 | - else { |
|
| 1307 | + if ($globalDBdriver == 'mysql') { |
|
| 1308 | + update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
|
| 1309 | + } else { |
|
| 1180 | 1310 | update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql'); |
| 1181 | 1311 | $query = "CREATE EXTENSION postgis"; |
| 1182 | 1312 | $Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']); |
@@ -1195,20 +1325,30 @@ discard block |
||
| 1195 | 1325 | global $tmp_dir, $globalDebug; |
| 1196 | 1326 | include_once('class.create_db.php'); |
| 1197 | 1327 | require_once(dirname(__FILE__).'/../require/class.NOTAM.php'); |
| 1198 | - if ($globalDebug) echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1328 | + if ($globalDebug) { |
|
| 1329 | + echo "NOTAM from FlightAirMap website : Download..."; |
|
| 1330 | + } |
|
| 1199 | 1331 | update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz'); |
| 1200 | 1332 | $error = ''; |
| 1201 | 1333 | if (file_exists($tmp_dir.'notam.txt.gz')) { |
| 1202 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1334 | + if ($globalDebug) { |
|
| 1335 | + echo "Gunzip..."; |
|
| 1336 | + } |
|
| 1203 | 1337 | update_db::gunzip($tmp_dir.'notam.txt.gz'); |
| 1204 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1338 | + if ($globalDebug) { |
|
| 1339 | + echo "Add to DB..."; |
|
| 1340 | + } |
|
| 1205 | 1341 | //$error = create_db::import_file($tmp_dir.'notam.sql'); |
| 1206 | 1342 | $NOTAM = new NOTAM(); |
| 1207 | 1343 | $NOTAM->updateNOTAMfromTextFile($tmp_dir.'notam.txt'); |
| 1208 | - } else $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1344 | + } else { |
|
| 1345 | + $error = "File ".$tmp_dir.'notam.txt.gz'." doesn't exist. Download failed."; |
|
| 1346 | + } |
|
| 1209 | 1347 | if ($error != '') { |
| 1210 | 1348 | return $error; |
| 1211 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1349 | + } elseif ($globalDebug) { |
|
| 1350 | + echo "Done\n"; |
|
| 1351 | + } |
|
| 1212 | 1352 | return ''; |
| 1213 | 1353 | } |
| 1214 | 1354 | |
@@ -1262,67 +1402,111 @@ discard block |
||
| 1262 | 1402 | //if ($globalDebug) echo "IVAO : Download..."; |
| 1263 | 1403 | //update_db::download('http://fr.mirror.ivao.aero/software/ivae_feb2013.zip',$tmp_dir.'ivae_feb2013.zip'); |
| 1264 | 1404 | if (file_exists($tmp_dir.'ivae_feb2013.zip')) { |
| 1265 | - if ($globalDebug) echo "Unzip..."; |
|
| 1405 | + if ($globalDebug) { |
|
| 1406 | + echo "Unzip..."; |
|
| 1407 | + } |
|
| 1266 | 1408 | update_db::unzip($tmp_dir.'ivae_feb2013.zip'); |
| 1267 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1409 | + if ($globalDebug) { |
|
| 1410 | + echo "Add to DB..."; |
|
| 1411 | + } |
|
| 1268 | 1412 | update_db::ivao_airlines($tmp_dir.'data/airlines.dat'); |
| 1269 | - if ($globalDebug) echo "Copy airlines logos to airlines images directory..."; |
|
| 1413 | + if ($globalDebug) { |
|
| 1414 | + echo "Copy airlines logos to airlines images directory..."; |
|
| 1415 | + } |
|
| 1270 | 1416 | if (is_writable(dirname(__FILE__).'/../images/airlines')) { |
| 1271 | - if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo."; |
|
| 1272 | - } else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1273 | - } else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1417 | + if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) { |
|
| 1418 | + $error = "Failed to copy airlines logo."; |
|
| 1419 | + } |
|
| 1420 | + } else { |
|
| 1421 | + $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable"; |
|
| 1422 | + } |
|
| 1423 | + } else { |
|
| 1424 | + $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed."; |
|
| 1425 | + } |
|
| 1274 | 1426 | if ($error != '') { |
| 1275 | 1427 | return $error; |
| 1276 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1428 | + } elseif ($globalDebug) { |
|
| 1429 | + echo "Done\n"; |
|
| 1430 | + } |
|
| 1277 | 1431 | return ''; |
| 1278 | 1432 | } |
| 1279 | 1433 | |
| 1280 | 1434 | public static function update_routes() { |
| 1281 | 1435 | global $tmp_dir, $globalDebug; |
| 1282 | 1436 | $error = ''; |
| 1283 | - if ($globalDebug) echo "Routes : Download..."; |
|
| 1437 | + if ($globalDebug) { |
|
| 1438 | + echo "Routes : Download..."; |
|
| 1439 | + } |
|
| 1284 | 1440 | update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz'); |
| 1285 | 1441 | if (file_exists($tmp_dir.'StandingData.sqb.gz')) { |
| 1286 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1442 | + if ($globalDebug) { |
|
| 1443 | + echo "Gunzip..."; |
|
| 1444 | + } |
|
| 1287 | 1445 | update_db::gunzip($tmp_dir.'StandingData.sqb.gz'); |
| 1288 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1446 | + if ($globalDebug) { |
|
| 1447 | + echo "Add to DB..."; |
|
| 1448 | + } |
|
| 1289 | 1449 | $error = update_db::retrieve_route_sqlite_to_dest($tmp_dir.'StandingData.sqb'); |
| 1290 | - } else $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1450 | + } else { |
|
| 1451 | + $error = "File ".$tmp_dir.'StandingData.sqb.gz'." doesn't exist. Download failed."; |
|
| 1452 | + } |
|
| 1291 | 1453 | if ($error != '') { |
| 1292 | 1454 | return $error; |
| 1293 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1455 | + } elseif ($globalDebug) { |
|
| 1456 | + echo "Done\n"; |
|
| 1457 | + } |
|
| 1294 | 1458 | return ''; |
| 1295 | 1459 | } |
| 1296 | 1460 | public static function update_oneworld() { |
| 1297 | 1461 | global $tmp_dir, $globalDebug; |
| 1298 | 1462 | $error = ''; |
| 1299 | - if ($globalDebug) echo "Schedules Oneworld : Download..."; |
|
| 1463 | + if ($globalDebug) { |
|
| 1464 | + echo "Schedules Oneworld : Download..."; |
|
| 1465 | + } |
|
| 1300 | 1466 | update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz'); |
| 1301 | 1467 | if (file_exists($tmp_dir.'oneworld.csv.gz')) { |
| 1302 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1468 | + if ($globalDebug) { |
|
| 1469 | + echo "Gunzip..."; |
|
| 1470 | + } |
|
| 1303 | 1471 | update_db::gunzip($tmp_dir.'oneworld.csv.gz'); |
| 1304 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1472 | + if ($globalDebug) { |
|
| 1473 | + echo "Add to DB..."; |
|
| 1474 | + } |
|
| 1305 | 1475 | $error = update_db::retrieve_route_oneworld($tmp_dir.'oneworld.csv'); |
| 1306 | - } else $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1476 | + } else { |
|
| 1477 | + $error = "File ".$tmp_dir.'oneworld.csv.gz'." doesn't exist. Download failed."; |
|
| 1478 | + } |
|
| 1307 | 1479 | if ($error != '') { |
| 1308 | 1480 | return $error; |
| 1309 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1481 | + } elseif ($globalDebug) { |
|
| 1482 | + echo "Done\n"; |
|
| 1483 | + } |
|
| 1310 | 1484 | return ''; |
| 1311 | 1485 | } |
| 1312 | 1486 | public static function update_skyteam() { |
| 1313 | 1487 | global $tmp_dir, $globalDebug; |
| 1314 | 1488 | $error = ''; |
| 1315 | - if ($globalDebug) echo "Schedules Skyteam : Download..."; |
|
| 1489 | + if ($globalDebug) { |
|
| 1490 | + echo "Schedules Skyteam : Download..."; |
|
| 1491 | + } |
|
| 1316 | 1492 | update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz'); |
| 1317 | 1493 | if (file_exists($tmp_dir.'skyteam.csv.gz')) { |
| 1318 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1494 | + if ($globalDebug) { |
|
| 1495 | + echo "Gunzip..."; |
|
| 1496 | + } |
|
| 1319 | 1497 | update_db::gunzip($tmp_dir.'skyteam.csv.gz'); |
| 1320 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1498 | + if ($globalDebug) { |
|
| 1499 | + echo "Add to DB..."; |
|
| 1500 | + } |
|
| 1321 | 1501 | $error = update_db::retrieve_route_skyteam($tmp_dir.'skyteam.csv'); |
| 1322 | - } else $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1502 | + } else { |
|
| 1503 | + $error = "File ".$tmp_dir.'skyteam.csv.gz'." doesn't exist. Download failed."; |
|
| 1504 | + } |
|
| 1323 | 1505 | if ($error != '') { |
| 1324 | 1506 | return $error; |
| 1325 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1507 | + } elseif ($globalDebug) { |
|
| 1508 | + echo "Done\n"; |
|
| 1509 | + } |
|
| 1326 | 1510 | return ''; |
| 1327 | 1511 | } |
| 1328 | 1512 | public static function update_ModeS() { |
@@ -1339,263 +1523,463 @@ discard block |
||
| 1339 | 1523 | exit; |
| 1340 | 1524 | } elseif ($globalDebug) echo "Done\n"; |
| 1341 | 1525 | */ |
| 1342 | - if ($globalDebug) echo "Modes : Download..."; |
|
| 1526 | + if ($globalDebug) { |
|
| 1527 | + echo "Modes : Download..."; |
|
| 1528 | + } |
|
| 1343 | 1529 | update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb'); |
| 1344 | 1530 | if (file_exists($tmp_dir.'basestation_latest.zip')) { |
| 1345 | - if ($globalDebug) echo "Unzip..."; |
|
| 1531 | + if ($globalDebug) { |
|
| 1532 | + echo "Unzip..."; |
|
| 1533 | + } |
|
| 1346 | 1534 | update_db::unzip($tmp_dir.'basestation_latest.zip'); |
| 1347 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1535 | + if ($globalDebug) { |
|
| 1536 | + echo "Add to DB..."; |
|
| 1537 | + } |
|
| 1348 | 1538 | $error = update_db::retrieve_modes_sqlite_to_dest($tmp_dir.'BaseStation.sqb'); |
| 1349 | - } else $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1539 | + } else { |
|
| 1540 | + $error = "File ".$tmp_dir.'basestation_latest.zip'." doesn't exist. Download failed."; |
|
| 1541 | + } |
|
| 1350 | 1542 | if ($error != '') { |
| 1351 | 1543 | return $error; |
| 1352 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1544 | + } elseif ($globalDebug) { |
|
| 1545 | + echo "Done\n"; |
|
| 1546 | + } |
|
| 1353 | 1547 | return ''; |
| 1354 | 1548 | } |
| 1355 | 1549 | |
| 1356 | 1550 | public static function update_ModeS_flarm() { |
| 1357 | 1551 | global $tmp_dir, $globalDebug; |
| 1358 | - if ($globalDebug) echo "Modes Flarmnet: Download..."; |
|
| 1552 | + if ($globalDebug) { |
|
| 1553 | + echo "Modes Flarmnet: Download..."; |
|
| 1554 | + } |
|
| 1359 | 1555 | update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln'); |
| 1360 | 1556 | if (file_exists($tmp_dir.'data.fln')) { |
| 1361 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1557 | + if ($globalDebug) { |
|
| 1558 | + echo "Add to DB..."; |
|
| 1559 | + } |
|
| 1362 | 1560 | $error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln'); |
| 1363 | - } else $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1561 | + } else { |
|
| 1562 | + $error = "File ".$tmp_dir.'data.fln'." doesn't exist. Download failed."; |
|
| 1563 | + } |
|
| 1364 | 1564 | if ($error != '') { |
| 1365 | 1565 | return $error; |
| 1366 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1566 | + } elseif ($globalDebug) { |
|
| 1567 | + echo "Done\n"; |
|
| 1568 | + } |
|
| 1367 | 1569 | return ''; |
| 1368 | 1570 | } |
| 1369 | 1571 | |
| 1370 | 1572 | public static function update_ModeS_ogn() { |
| 1371 | 1573 | global $tmp_dir, $globalDebug; |
| 1372 | - if ($globalDebug) echo "Modes OGN: Download..."; |
|
| 1574 | + if ($globalDebug) { |
|
| 1575 | + echo "Modes OGN: Download..."; |
|
| 1576 | + } |
|
| 1373 | 1577 | update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv'); |
| 1374 | 1578 | if (file_exists($tmp_dir.'ogn.csv')) { |
| 1375 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1579 | + if ($globalDebug) { |
|
| 1580 | + echo "Add to DB..."; |
|
| 1581 | + } |
|
| 1376 | 1582 | $error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv'); |
| 1377 | - } else $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1583 | + } else { |
|
| 1584 | + $error = "File ".$tmp_dir.'ogn.csv'." doesn't exist. Download failed."; |
|
| 1585 | + } |
|
| 1378 | 1586 | if ($error != '') { |
| 1379 | 1587 | return $error; |
| 1380 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1588 | + } elseif ($globalDebug) { |
|
| 1589 | + echo "Done\n"; |
|
| 1590 | + } |
|
| 1381 | 1591 | return ''; |
| 1382 | 1592 | } |
| 1383 | 1593 | |
| 1384 | 1594 | public static function update_owner() { |
| 1385 | 1595 | global $tmp_dir, $globalDebug; |
| 1386 | 1596 | |
| 1387 | - if ($globalDebug) echo "Owner France: Download..."; |
|
| 1597 | + if ($globalDebug) { |
|
| 1598 | + echo "Owner France: Download..."; |
|
| 1599 | + } |
|
| 1388 | 1600 | update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv'); |
| 1389 | 1601 | if (file_exists($tmp_dir.'owner_f.csv')) { |
| 1390 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1602 | + if ($globalDebug) { |
|
| 1603 | + echo "Add to DB..."; |
|
| 1604 | + } |
|
| 1391 | 1605 | $error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F'); |
| 1392 | - } else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1606 | + } else { |
|
| 1607 | + $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed."; |
|
| 1608 | + } |
|
| 1393 | 1609 | if ($error != '') { |
| 1394 | 1610 | return $error; |
| 1395 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1611 | + } elseif ($globalDebug) { |
|
| 1612 | + echo "Done\n"; |
|
| 1613 | + } |
|
| 1396 | 1614 | |
| 1397 | - if ($globalDebug) echo "Owner Ireland: Download..."; |
|
| 1615 | + if ($globalDebug) { |
|
| 1616 | + echo "Owner Ireland: Download..."; |
|
| 1617 | + } |
|
| 1398 | 1618 | update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv'); |
| 1399 | 1619 | if (file_exists($tmp_dir.'owner_ei.csv')) { |
| 1400 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1620 | + if ($globalDebug) { |
|
| 1621 | + echo "Add to DB..."; |
|
| 1622 | + } |
|
| 1401 | 1623 | $error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI'); |
| 1402 | - } else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1624 | + } else { |
|
| 1625 | + $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed."; |
|
| 1626 | + } |
|
| 1403 | 1627 | if ($error != '') { |
| 1404 | 1628 | return $error; |
| 1405 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1406 | - if ($globalDebug) echo "Owner Switzerland: Download..."; |
|
| 1629 | + } elseif ($globalDebug) { |
|
| 1630 | + echo "Done\n"; |
|
| 1631 | + } |
|
| 1632 | + if ($globalDebug) { |
|
| 1633 | + echo "Owner Switzerland: Download..."; |
|
| 1634 | + } |
|
| 1407 | 1635 | update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv'); |
| 1408 | 1636 | if (file_exists($tmp_dir.'owner_hb.csv')) { |
| 1409 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1637 | + if ($globalDebug) { |
|
| 1638 | + echo "Add to DB..."; |
|
| 1639 | + } |
|
| 1410 | 1640 | $error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB'); |
| 1411 | - } else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1641 | + } else { |
|
| 1642 | + $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed."; |
|
| 1643 | + } |
|
| 1412 | 1644 | if ($error != '') { |
| 1413 | 1645 | return $error; |
| 1414 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1415 | - if ($globalDebug) echo "Owner Czech Republic: Download..."; |
|
| 1646 | + } elseif ($globalDebug) { |
|
| 1647 | + echo "Done\n"; |
|
| 1648 | + } |
|
| 1649 | + if ($globalDebug) { |
|
| 1650 | + echo "Owner Czech Republic: Download..."; |
|
| 1651 | + } |
|
| 1416 | 1652 | update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv'); |
| 1417 | 1653 | if (file_exists($tmp_dir.'owner_ok.csv')) { |
| 1418 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1654 | + if ($globalDebug) { |
|
| 1655 | + echo "Add to DB..."; |
|
| 1656 | + } |
|
| 1419 | 1657 | $error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK'); |
| 1420 | - } else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1658 | + } else { |
|
| 1659 | + $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed."; |
|
| 1660 | + } |
|
| 1421 | 1661 | if ($error != '') { |
| 1422 | 1662 | return $error; |
| 1423 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1424 | - if ($globalDebug) echo "Owner Australia: Download..."; |
|
| 1663 | + } elseif ($globalDebug) { |
|
| 1664 | + echo "Done\n"; |
|
| 1665 | + } |
|
| 1666 | + if ($globalDebug) { |
|
| 1667 | + echo "Owner Australia: Download..."; |
|
| 1668 | + } |
|
| 1425 | 1669 | update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv'); |
| 1426 | 1670 | if (file_exists($tmp_dir.'owner_vh.csv')) { |
| 1427 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1671 | + if ($globalDebug) { |
|
| 1672 | + echo "Add to DB..."; |
|
| 1673 | + } |
|
| 1428 | 1674 | $error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH'); |
| 1429 | - } else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1675 | + } else { |
|
| 1676 | + $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed."; |
|
| 1677 | + } |
|
| 1430 | 1678 | if ($error != '') { |
| 1431 | 1679 | return $error; |
| 1432 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1433 | - if ($globalDebug) echo "Owner Austria: Download..."; |
|
| 1680 | + } elseif ($globalDebug) { |
|
| 1681 | + echo "Done\n"; |
|
| 1682 | + } |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo "Owner Austria: Download..."; |
|
| 1685 | + } |
|
| 1434 | 1686 | update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv'); |
| 1435 | 1687 | if (file_exists($tmp_dir.'owner_oe.csv')) { |
| 1436 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1688 | + if ($globalDebug) { |
|
| 1689 | + echo "Add to DB..."; |
|
| 1690 | + } |
|
| 1437 | 1691 | $error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE'); |
| 1438 | - } else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1692 | + } else { |
|
| 1693 | + $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed."; |
|
| 1694 | + } |
|
| 1439 | 1695 | if ($error != '') { |
| 1440 | 1696 | return $error; |
| 1441 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1442 | - if ($globalDebug) echo "Owner Chile: Download..."; |
|
| 1697 | + } elseif ($globalDebug) { |
|
| 1698 | + echo "Done\n"; |
|
| 1699 | + } |
|
| 1700 | + if ($globalDebug) { |
|
| 1701 | + echo "Owner Chile: Download..."; |
|
| 1702 | + } |
|
| 1443 | 1703 | update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv'); |
| 1444 | 1704 | if (file_exists($tmp_dir.'owner_cc.csv')) { |
| 1445 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1705 | + if ($globalDebug) { |
|
| 1706 | + echo "Add to DB..."; |
|
| 1707 | + } |
|
| 1446 | 1708 | $error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC'); |
| 1447 | - } else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1709 | + } else { |
|
| 1710 | + $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed."; |
|
| 1711 | + } |
|
| 1448 | 1712 | if ($error != '') { |
| 1449 | 1713 | return $error; |
| 1450 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1451 | - if ($globalDebug) echo "Owner Colombia: Download..."; |
|
| 1714 | + } elseif ($globalDebug) { |
|
| 1715 | + echo "Done\n"; |
|
| 1716 | + } |
|
| 1717 | + if ($globalDebug) { |
|
| 1718 | + echo "Owner Colombia: Download..."; |
|
| 1719 | + } |
|
| 1452 | 1720 | update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv'); |
| 1453 | 1721 | if (file_exists($tmp_dir.'owner_hj.csv')) { |
| 1454 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1722 | + if ($globalDebug) { |
|
| 1723 | + echo "Add to DB..."; |
|
| 1724 | + } |
|
| 1455 | 1725 | $error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ'); |
| 1456 | - } else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1726 | + } else { |
|
| 1727 | + $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed."; |
|
| 1728 | + } |
|
| 1457 | 1729 | if ($error != '') { |
| 1458 | 1730 | return $error; |
| 1459 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1460 | - if ($globalDebug) echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1731 | + } elseif ($globalDebug) { |
|
| 1732 | + echo "Done\n"; |
|
| 1733 | + } |
|
| 1734 | + if ($globalDebug) { |
|
| 1735 | + echo "Owner Bosnia Herzegobina: Download..."; |
|
| 1736 | + } |
|
| 1461 | 1737 | update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv'); |
| 1462 | 1738 | if (file_exists($tmp_dir.'owner_e7.csv')) { |
| 1463 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1739 | + if ($globalDebug) { |
|
| 1740 | + echo "Add to DB..."; |
|
| 1741 | + } |
|
| 1464 | 1742 | $error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7'); |
| 1465 | - } else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1743 | + } else { |
|
| 1744 | + $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed."; |
|
| 1745 | + } |
|
| 1466 | 1746 | if ($error != '') { |
| 1467 | 1747 | return $error; |
| 1468 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1469 | - if ($globalDebug) echo "Owner Brazil: Download..."; |
|
| 1748 | + } elseif ($globalDebug) { |
|
| 1749 | + echo "Done\n"; |
|
| 1750 | + } |
|
| 1751 | + if ($globalDebug) { |
|
| 1752 | + echo "Owner Brazil: Download..."; |
|
| 1753 | + } |
|
| 1470 | 1754 | update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv'); |
| 1471 | 1755 | if (file_exists($tmp_dir.'owner_pp.csv')) { |
| 1472 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1756 | + if ($globalDebug) { |
|
| 1757 | + echo "Add to DB..."; |
|
| 1758 | + } |
|
| 1473 | 1759 | $error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP'); |
| 1474 | - } else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1760 | + } else { |
|
| 1761 | + $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed."; |
|
| 1762 | + } |
|
| 1475 | 1763 | if ($error != '') { |
| 1476 | 1764 | return $error; |
| 1477 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1478 | - if ($globalDebug) echo "Owner Cayman Islands: Download..."; |
|
| 1765 | + } elseif ($globalDebug) { |
|
| 1766 | + echo "Done\n"; |
|
| 1767 | + } |
|
| 1768 | + if ($globalDebug) { |
|
| 1769 | + echo "Owner Cayman Islands: Download..."; |
|
| 1770 | + } |
|
| 1479 | 1771 | update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv'); |
| 1480 | 1772 | if (file_exists($tmp_dir.'owner_vp.csv')) { |
| 1481 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1773 | + if ($globalDebug) { |
|
| 1774 | + echo "Add to DB..."; |
|
| 1775 | + } |
|
| 1482 | 1776 | $error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP'); |
| 1483 | - } else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1777 | + } else { |
|
| 1778 | + $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed."; |
|
| 1779 | + } |
|
| 1484 | 1780 | if ($error != '') { |
| 1485 | 1781 | return $error; |
| 1486 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1487 | - if ($globalDebug) echo "Owner Croatia: Download..."; |
|
| 1782 | + } elseif ($globalDebug) { |
|
| 1783 | + echo "Done\n"; |
|
| 1784 | + } |
|
| 1785 | + if ($globalDebug) { |
|
| 1786 | + echo "Owner Croatia: Download..."; |
|
| 1787 | + } |
|
| 1488 | 1788 | update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv'); |
| 1489 | 1789 | if (file_exists($tmp_dir.'owner_9a.csv')) { |
| 1490 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1790 | + if ($globalDebug) { |
|
| 1791 | + echo "Add to DB..."; |
|
| 1792 | + } |
|
| 1491 | 1793 | $error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A'); |
| 1492 | - } else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1794 | + } else { |
|
| 1795 | + $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed."; |
|
| 1796 | + } |
|
| 1493 | 1797 | if ($error != '') { |
| 1494 | 1798 | return $error; |
| 1495 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1496 | - if ($globalDebug) echo "Owner Luxembourg: Download..."; |
|
| 1799 | + } elseif ($globalDebug) { |
|
| 1800 | + echo "Done\n"; |
|
| 1801 | + } |
|
| 1802 | + if ($globalDebug) { |
|
| 1803 | + echo "Owner Luxembourg: Download..."; |
|
| 1804 | + } |
|
| 1497 | 1805 | update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv'); |
| 1498 | 1806 | if (file_exists($tmp_dir.'owner_lx.csv')) { |
| 1499 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1807 | + if ($globalDebug) { |
|
| 1808 | + echo "Add to DB..."; |
|
| 1809 | + } |
|
| 1500 | 1810 | $error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX'); |
| 1501 | - } else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1811 | + } else { |
|
| 1812 | + $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed."; |
|
| 1813 | + } |
|
| 1502 | 1814 | if ($error != '') { |
| 1503 | 1815 | return $error; |
| 1504 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1505 | - if ($globalDebug) echo "Owner Maldives: Download..."; |
|
| 1816 | + } elseif ($globalDebug) { |
|
| 1817 | + echo "Done\n"; |
|
| 1818 | + } |
|
| 1819 | + if ($globalDebug) { |
|
| 1820 | + echo "Owner Maldives: Download..."; |
|
| 1821 | + } |
|
| 1506 | 1822 | update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv'); |
| 1507 | 1823 | if (file_exists($tmp_dir.'owner_8q.csv')) { |
| 1508 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1824 | + if ($globalDebug) { |
|
| 1825 | + echo "Add to DB..."; |
|
| 1826 | + } |
|
| 1509 | 1827 | $error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q'); |
| 1510 | - } else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1828 | + } else { |
|
| 1829 | + $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed."; |
|
| 1830 | + } |
|
| 1511 | 1831 | if ($error != '') { |
| 1512 | 1832 | return $error; |
| 1513 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1514 | - if ($globalDebug) echo "Owner New Zealand: Download..."; |
|
| 1833 | + } elseif ($globalDebug) { |
|
| 1834 | + echo "Done\n"; |
|
| 1835 | + } |
|
| 1836 | + if ($globalDebug) { |
|
| 1837 | + echo "Owner New Zealand: Download..."; |
|
| 1838 | + } |
|
| 1515 | 1839 | update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv'); |
| 1516 | 1840 | if (file_exists($tmp_dir.'owner_zk.csv')) { |
| 1517 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1841 | + if ($globalDebug) { |
|
| 1842 | + echo "Add to DB..."; |
|
| 1843 | + } |
|
| 1518 | 1844 | $error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK'); |
| 1519 | - } else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1845 | + } else { |
|
| 1846 | + $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed."; |
|
| 1847 | + } |
|
| 1520 | 1848 | if ($error != '') { |
| 1521 | 1849 | return $error; |
| 1522 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1523 | - if ($globalDebug) echo "Owner Papua New Guinea: Download..."; |
|
| 1850 | + } elseif ($globalDebug) { |
|
| 1851 | + echo "Done\n"; |
|
| 1852 | + } |
|
| 1853 | + if ($globalDebug) { |
|
| 1854 | + echo "Owner Papua New Guinea: Download..."; |
|
| 1855 | + } |
|
| 1524 | 1856 | update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv'); |
| 1525 | 1857 | if (file_exists($tmp_dir.'owner_p2.csv')) { |
| 1526 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1858 | + if ($globalDebug) { |
|
| 1859 | + echo "Add to DB..."; |
|
| 1860 | + } |
|
| 1527 | 1861 | $error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2'); |
| 1528 | - } else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1862 | + } else { |
|
| 1863 | + $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed."; |
|
| 1864 | + } |
|
| 1529 | 1865 | if ($error != '') { |
| 1530 | 1866 | return $error; |
| 1531 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1532 | - if ($globalDebug) echo "Owner Slovakia: Download..."; |
|
| 1867 | + } elseif ($globalDebug) { |
|
| 1868 | + echo "Done\n"; |
|
| 1869 | + } |
|
| 1870 | + if ($globalDebug) { |
|
| 1871 | + echo "Owner Slovakia: Download..."; |
|
| 1872 | + } |
|
| 1533 | 1873 | update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv'); |
| 1534 | 1874 | if (file_exists($tmp_dir.'owner_om.csv')) { |
| 1535 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1875 | + if ($globalDebug) { |
|
| 1876 | + echo "Add to DB..."; |
|
| 1877 | + } |
|
| 1536 | 1878 | $error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM'); |
| 1537 | - } else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1879 | + } else { |
|
| 1880 | + $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed."; |
|
| 1881 | + } |
|
| 1538 | 1882 | if ($error != '') { |
| 1539 | 1883 | return $error; |
| 1540 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1541 | - if ($globalDebug) echo "Owner Ecuador: Download..."; |
|
| 1884 | + } elseif ($globalDebug) { |
|
| 1885 | + echo "Done\n"; |
|
| 1886 | + } |
|
| 1887 | + if ($globalDebug) { |
|
| 1888 | + echo "Owner Ecuador: Download..."; |
|
| 1889 | + } |
|
| 1542 | 1890 | update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv'); |
| 1543 | 1891 | if (file_exists($tmp_dir.'owner_hc.csv')) { |
| 1544 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1892 | + if ($globalDebug) { |
|
| 1893 | + echo "Add to DB..."; |
|
| 1894 | + } |
|
| 1545 | 1895 | $error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC'); |
| 1546 | - } else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1896 | + } else { |
|
| 1897 | + $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed."; |
|
| 1898 | + } |
|
| 1547 | 1899 | if ($error != '') { |
| 1548 | 1900 | return $error; |
| 1549 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1550 | - if ($globalDebug) echo "Owner Iceland: Download..."; |
|
| 1901 | + } elseif ($globalDebug) { |
|
| 1902 | + echo "Done\n"; |
|
| 1903 | + } |
|
| 1904 | + if ($globalDebug) { |
|
| 1905 | + echo "Owner Iceland: Download..."; |
|
| 1906 | + } |
|
| 1551 | 1907 | update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv'); |
| 1552 | 1908 | if (file_exists($tmp_dir.'owner_tf.csv')) { |
| 1553 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1909 | + if ($globalDebug) { |
|
| 1910 | + echo "Add to DB..."; |
|
| 1911 | + } |
|
| 1554 | 1912 | $error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF'); |
| 1555 | - } else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1913 | + } else { |
|
| 1914 | + $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed."; |
|
| 1915 | + } |
|
| 1556 | 1916 | if ($error != '') { |
| 1557 | 1917 | return $error; |
| 1558 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1918 | + } elseif ($globalDebug) { |
|
| 1919 | + echo "Done\n"; |
|
| 1920 | + } |
|
| 1559 | 1921 | return ''; |
| 1560 | 1922 | } |
| 1561 | 1923 | |
| 1562 | 1924 | public static function update_translation() { |
| 1563 | 1925 | global $tmp_dir, $globalDebug; |
| 1564 | 1926 | $error = ''; |
| 1565 | - if ($globalDebug) echo "Translation : Download..."; |
|
| 1927 | + if ($globalDebug) { |
|
| 1928 | + echo "Translation : Download..."; |
|
| 1929 | + } |
|
| 1566 | 1930 | update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip'); |
| 1567 | 1931 | if (file_exists($tmp_dir.'translation.zip')) { |
| 1568 | - if ($globalDebug) echo "Unzip..."; |
|
| 1932 | + if ($globalDebug) { |
|
| 1933 | + echo "Unzip..."; |
|
| 1934 | + } |
|
| 1569 | 1935 | update_db::unzip($tmp_dir.'translation.zip'); |
| 1570 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1936 | + if ($globalDebug) { |
|
| 1937 | + echo "Add to DB..."; |
|
| 1938 | + } |
|
| 1571 | 1939 | $error = update_db::translation(); |
| 1572 | - } else $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1940 | + } else { |
|
| 1941 | + $error = "File ".$tmp_dir.'translation.zip'." doesn't exist. Download failed."; |
|
| 1942 | + } |
|
| 1573 | 1943 | if ($error != '') { |
| 1574 | 1944 | return $error; |
| 1575 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1945 | + } elseif ($globalDebug) { |
|
| 1946 | + echo "Done\n"; |
|
| 1947 | + } |
|
| 1576 | 1948 | return ''; |
| 1577 | 1949 | } |
| 1578 | 1950 | |
| 1579 | 1951 | public static function update_translation_fam() { |
| 1580 | 1952 | global $tmp_dir, $globalDebug; |
| 1581 | - if ($globalDebug) echo "Translation from FlightAirMap website : Download..."; |
|
| 1953 | + if ($globalDebug) { |
|
| 1954 | + echo "Translation from FlightAirMap website : Download..."; |
|
| 1955 | + } |
|
| 1582 | 1956 | update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz'); |
| 1583 | 1957 | if (file_exists($tmp_dir.'translation.tsv.gz')) { |
| 1584 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1958 | + if ($globalDebug) { |
|
| 1959 | + echo "Gunzip..."; |
|
| 1960 | + } |
|
| 1585 | 1961 | update_db::gunzip($tmp_dir.'translation.tsv.gz'); |
| 1586 | - if ($globalDebug) echo "Add to DB..."; |
|
| 1962 | + if ($globalDebug) { |
|
| 1963 | + echo "Add to DB..."; |
|
| 1964 | + } |
|
| 1587 | 1965 | $error = update_db::translation_fam(); |
| 1588 | - } else $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1966 | + } else { |
|
| 1967 | + $error = "File ".$tmp_dir.'translation.tsv.gz'." doesn't exist. Download failed."; |
|
| 1968 | + } |
|
| 1589 | 1969 | if ($error != '') { |
| 1590 | 1970 | return $error; |
| 1591 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 1971 | + } elseif ($globalDebug) { |
|
| 1972 | + echo "Done\n"; |
|
| 1973 | + } |
|
| 1592 | 1974 | return ''; |
| 1593 | 1975 | } |
| 1594 | 1976 | |
| 1595 | 1977 | public static function update_airspace_fam() { |
| 1596 | 1978 | global $tmp_dir, $globalDebug, $globalDBdriver; |
| 1597 | 1979 | include_once('class.create_db.php'); |
| 1598 | - if ($globalDebug) echo "Airspace from FlightAirMap website : Download..."; |
|
| 1980 | + if ($globalDebug) { |
|
| 1981 | + echo "Airspace from FlightAirMap website : Download..."; |
|
| 1982 | + } |
|
| 1599 | 1983 | if ($globalDBdriver == 'mysql') { |
| 1600 | 1984 | update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5'); |
| 1601 | 1985 | } else { |
@@ -1611,9 +1995,13 @@ discard block |
||
| 1611 | 1995 | update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz'); |
| 1612 | 1996 | } |
| 1613 | 1997 | if (file_exists($tmp_dir.'airspace.sql.gz')) { |
| 1614 | - if ($globalDebug) echo "Gunzip..."; |
|
| 1998 | + if ($globalDebug) { |
|
| 1999 | + echo "Gunzip..."; |
|
| 2000 | + } |
|
| 1615 | 2001 | update_db::gunzip($tmp_dir.'airspace.sql.gz'); |
| 1616 | - if ($globalDebug) echo "Add to DB..."; |
|
| 2002 | + if ($globalDebug) { |
|
| 2003 | + echo "Add to DB..."; |
|
| 2004 | + } |
|
| 1617 | 2005 | $Connection = new Connection(); |
| 1618 | 2006 | if ($Connection->tableExists('airspace')) { |
| 1619 | 2007 | $query = 'DROP TABLE airspace'; |
@@ -1626,31 +2014,47 @@ discard block |
||
| 1626 | 2014 | } |
| 1627 | 2015 | $error = create_db::import_file($tmp_dir.'airspace.sql'); |
| 1628 | 2016 | update_db::insert_airspace_version($airspace_md5); |
| 1629 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2017 | + } else { |
|
| 2018 | + $error = "File ".$tmp_dir.'airpsace.sql.gz'." doesn't exist. Download failed."; |
|
| 2019 | + } |
|
| 1630 | 2020 | } |
| 1631 | - } else $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2021 | + } else { |
|
| 2022 | + $error = "File ".$tmp_dir.'airpsace.sql.gz.md5'." doesn't exist. Download failed."; |
|
| 2023 | + } |
|
| 1632 | 2024 | if ($error != '') { |
| 1633 | 2025 | return $error; |
| 1634 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2026 | + } elseif ($globalDebug) { |
|
| 2027 | + echo "Done\n"; |
|
| 2028 | + } |
|
| 1635 | 2029 | return ''; |
| 1636 | 2030 | } |
| 1637 | 2031 | |
| 1638 | 2032 | public static function update_tle() { |
| 1639 | 2033 | global $tmp_dir, $globalDebug; |
| 1640 | - if ($globalDebug) echo "Download TLE : Download..."; |
|
| 2034 | + if ($globalDebug) { |
|
| 2035 | + echo "Download TLE : Download..."; |
|
| 2036 | + } |
|
| 1641 | 2037 | $alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt', |
| 1642 | 2038 | 'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt', |
| 1643 | 2039 | 'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt'); |
| 1644 | 2040 | foreach ($alltle as $filename) { |
| 1645 | - if ($globalDebug) echo "downloading ".$filename.'...'; |
|
| 2041 | + if ($globalDebug) { |
|
| 2042 | + echo "downloading ".$filename.'...'; |
|
| 2043 | + } |
|
| 1646 | 2044 | update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename); |
| 1647 | 2045 | if (file_exists($tmp_dir.$filename)) { |
| 1648 | - if ($globalDebug) echo "Add to DB ".$filename."..."; |
|
| 2046 | + if ($globalDebug) { |
|
| 2047 | + echo "Add to DB ".$filename."..."; |
|
| 2048 | + } |
|
| 1649 | 2049 | $error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename)); |
| 1650 | - } else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2050 | + } else { |
|
| 2051 | + $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed."; |
|
| 2052 | + } |
|
| 1651 | 2053 | if ($error != '') { |
| 1652 | 2054 | echo $error."\n"; |
| 1653 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2055 | + } elseif ($globalDebug) { |
|
| 2056 | + echo "Done\n"; |
|
| 2057 | + } |
|
| 1654 | 2058 | } |
| 1655 | 2059 | return ''; |
| 1656 | 2060 | } |
@@ -1658,10 +2062,14 @@ discard block |
||
| 1658 | 2062 | public static function update_models() { |
| 1659 | 2063 | global $tmp_dir, $globalDebug; |
| 1660 | 2064 | $error = ''; |
| 1661 | - if ($globalDebug) echo "Models from FlightAirMap website : Download..."; |
|
| 2065 | + if ($globalDebug) { |
|
| 2066 | + echo "Models from FlightAirMap website : Download..."; |
|
| 2067 | + } |
|
| 1662 | 2068 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum'); |
| 1663 | 2069 | if (file_exists($tmp_dir.'models.md5sum')) { |
| 1664 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2070 | + if ($globalDebug) { |
|
| 2071 | + echo "Check files...\n"; |
|
| 2072 | + } |
|
| 1665 | 2073 | $newmodelsdb = array(); |
| 1666 | 2074 | if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) { |
| 1667 | 2075 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1680,25 +2088,35 @@ discard block |
||
| 1680 | 2088 | } |
| 1681 | 2089 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1682 | 2090 | foreach ($diff as $key => $value) { |
| 1683 | - if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2091 | + if ($globalDebug) { |
|
| 2092 | + echo 'Downloading model '.$key.' ...'."\n"; |
|
| 2093 | + } |
|
| 1684 | 2094 | update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key); |
| 1685 | 2095 | |
| 1686 | 2096 | } |
| 1687 | 2097 | update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum'); |
| 1688 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2098 | + } else { |
|
| 2099 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2100 | + } |
|
| 1689 | 2101 | if ($error != '') { |
| 1690 | 2102 | return $error; |
| 1691 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2103 | + } elseif ($globalDebug) { |
|
| 2104 | + echo "Done\n"; |
|
| 2105 | + } |
|
| 1692 | 2106 | return ''; |
| 1693 | 2107 | } |
| 1694 | 2108 | |
| 1695 | 2109 | public static function update_space_models() { |
| 1696 | 2110 | global $tmp_dir, $globalDebug; |
| 1697 | 2111 | $error = ''; |
| 1698 | - if ($globalDebug) echo "Space models from FlightAirMap website : Download..."; |
|
| 2112 | + if ($globalDebug) { |
|
| 2113 | + echo "Space models from FlightAirMap website : Download..."; |
|
| 2114 | + } |
|
| 1699 | 2115 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum'); |
| 1700 | 2116 | if (file_exists($tmp_dir.'space_models.md5sum')) { |
| 1701 | - if ($globalDebug) echo "Check files...\n"; |
|
| 2117 | + if ($globalDebug) { |
|
| 2118 | + echo "Check files...\n"; |
|
| 2119 | + } |
|
| 1702 | 2120 | $newmodelsdb = array(); |
| 1703 | 2121 | if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) { |
| 1704 | 2122 | while (($row = fgetcsv($handle,1000," ")) !== FALSE) { |
@@ -1717,15 +2135,21 @@ discard block |
||
| 1717 | 2135 | } |
| 1718 | 2136 | $diff = array_diff($newmodelsdb,$modelsdb); |
| 1719 | 2137 | foreach ($diff as $key => $value) { |
| 1720 | - if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2138 | + if ($globalDebug) { |
|
| 2139 | + echo 'Downloading space model '.$key.' ...'."\n"; |
|
| 2140 | + } |
|
| 1721 | 2141 | update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key); |
| 1722 | 2142 | |
| 1723 | 2143 | } |
| 1724 | 2144 | update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum'); |
| 1725 | - } else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2145 | + } else { |
|
| 2146 | + $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed."; |
|
| 2147 | + } |
|
| 1726 | 2148 | if ($error != '') { |
| 1727 | 2149 | return $error; |
| 1728 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2150 | + } elseif ($globalDebug) { |
|
| 2151 | + echo "Done\n"; |
|
| 2152 | + } |
|
| 1729 | 2153 | return ''; |
| 1730 | 2154 | } |
| 1731 | 2155 | |
@@ -1768,7 +2192,9 @@ discard block |
||
| 1768 | 2192 | } |
| 1769 | 2193 | |
| 1770 | 2194 | $error = ''; |
| 1771 | - if ($globalDebug) echo "Notam : Download..."; |
|
| 2195 | + if ($globalDebug) { |
|
| 2196 | + echo "Notam : Download..."; |
|
| 2197 | + } |
|
| 1772 | 2198 | update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss'); |
| 1773 | 2199 | if (file_exists($tmp_dir.'notam.rss')) { |
| 1774 | 2200 | $notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true); |
@@ -1783,14 +2209,30 @@ discard block |
||
| 1783 | 2209 | $data['fir'] = $q[0]; |
| 1784 | 2210 | $data['code'] = $q[1]; |
| 1785 | 2211 | $ifrvfr = $q[2]; |
| 1786 | - if ($ifrvfr == 'IV') $data['rules'] = 'IFR/VFR'; |
|
| 1787 | - if ($ifrvfr == 'I') $data['rules'] = 'IFR'; |
|
| 1788 | - if ($ifrvfr == 'V') $data['rules'] = 'VFR'; |
|
| 1789 | - if ($q[4] == 'A') $data['scope'] = 'Airport warning'; |
|
| 1790 | - if ($q[4] == 'E') $data['scope'] = 'Enroute warning'; |
|
| 1791 | - if ($q[4] == 'W') $data['scope'] = 'Navigation warning'; |
|
| 1792 | - if ($q[4] == 'AE') $data['scope'] = 'Airport/Enroute warning'; |
|
| 1793 | - if ($q[4] == 'AW') $data['scope'] = 'Airport/Navigation warning'; |
|
| 2212 | + if ($ifrvfr == 'IV') { |
|
| 2213 | + $data['rules'] = 'IFR/VFR'; |
|
| 2214 | + } |
|
| 2215 | + if ($ifrvfr == 'I') { |
|
| 2216 | + $data['rules'] = 'IFR'; |
|
| 2217 | + } |
|
| 2218 | + if ($ifrvfr == 'V') { |
|
| 2219 | + $data['rules'] = 'VFR'; |
|
| 2220 | + } |
|
| 2221 | + if ($q[4] == 'A') { |
|
| 2222 | + $data['scope'] = 'Airport warning'; |
|
| 2223 | + } |
|
| 2224 | + if ($q[4] == 'E') { |
|
| 2225 | + $data['scope'] = 'Enroute warning'; |
|
| 2226 | + } |
|
| 2227 | + if ($q[4] == 'W') { |
|
| 2228 | + $data['scope'] = 'Navigation warning'; |
|
| 2229 | + } |
|
| 2230 | + if ($q[4] == 'AE') { |
|
| 2231 | + $data['scope'] = 'Airport/Enroute warning'; |
|
| 2232 | + } |
|
| 2233 | + if ($q[4] == 'AW') { |
|
| 2234 | + $data['scope'] = 'Airport/Navigation warning'; |
|
| 2235 | + } |
|
| 1794 | 2236 | //$data['scope'] = $q[4]; |
| 1795 | 2237 | $data['lower_limit'] = $q[5]; |
| 1796 | 2238 | $data['upper_limit'] = $q[6]; |
@@ -1798,8 +2240,12 @@ discard block |
||
| 1798 | 2240 | sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius); |
| 1799 | 2241 | $latitude = $Common->convertDec($las,'latitude'); |
| 1800 | 2242 | $longitude = $Common->convertDec($lns,'longitude'); |
| 1801 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 1802 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 2243 | + if ($lac == 'S') { |
|
| 2244 | + $latitude = '-'.$latitude; |
|
| 2245 | + } |
|
| 2246 | + if ($lnc == 'W') { |
|
| 2247 | + $longitude = '-'.$longitude; |
|
| 2248 | + } |
|
| 1803 | 2249 | $data['center_latitude'] = $latitude; |
| 1804 | 2250 | $data['center_longitude'] = $longitude; |
| 1805 | 2251 | $data['radius'] = intval($radius); |
@@ -1829,10 +2275,14 @@ discard block |
||
| 1829 | 2275 | $NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']); |
| 1830 | 2276 | unset($data); |
| 1831 | 2277 | } |
| 1832 | - } else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2278 | + } else { |
|
| 2279 | + $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed."; |
|
| 2280 | + } |
|
| 1833 | 2281 | if ($error != '') { |
| 1834 | 2282 | return $error; |
| 1835 | - } elseif ($globalDebug) echo "Done\n"; |
|
| 2283 | + } elseif ($globalDebug) { |
|
| 2284 | + echo "Done\n"; |
|
| 2285 | + } |
|
| 1836 | 2286 | return ''; |
| 1837 | 2287 | } |
| 1838 | 2288 | |
@@ -1857,7 +2307,9 @@ discard block |
||
| 1857 | 2307 | $airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json'); |
| 1858 | 2308 | $airspace_json = json_decode($airspace_lst,true); |
| 1859 | 2309 | foreach ($airspace_json['records'] as $airspace) { |
| 1860 | - if ($globalDebug) echo $airspace['name']."...\n"; |
|
| 2310 | + if ($globalDebug) { |
|
| 2311 | + echo $airspace['name']."...\n"; |
|
| 2312 | + } |
|
| 1861 | 2313 | update_db::download($airspace['uri'],$tmp_dir.$airspace['name']); |
| 1862 | 2314 | if (file_exists($tmp_dir.$airspace['name'])) { |
| 1863 | 2315 | file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name']))); |
@@ -1886,8 +2338,11 @@ discard block |
||
| 1886 | 2338 | return "error : ".$e->getMessage(); |
| 1887 | 2339 | } |
| 1888 | 2340 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1889 | - if ($row['nb'] > 0) return false; |
|
| 1890 | - else return true; |
|
| 2341 | + if ($row['nb'] > 0) { |
|
| 2342 | + return false; |
|
| 2343 | + } else { |
|
| 2344 | + return true; |
|
| 2345 | + } |
|
| 1891 | 2346 | } |
| 1892 | 2347 | |
| 1893 | 2348 | public static function insert_last_update() { |
@@ -1912,8 +2367,11 @@ discard block |
||
| 1912 | 2367 | return "error : ".$e->getMessage(); |
| 1913 | 2368 | } |
| 1914 | 2369 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1915 | - if ($row['nb'] > 0) return true; |
|
| 1916 | - else return false; |
|
| 2370 | + if ($row['nb'] > 0) { |
|
| 2371 | + return true; |
|
| 2372 | + } else { |
|
| 2373 | + return false; |
|
| 2374 | + } |
|
| 1917 | 2375 | } |
| 1918 | 2376 | |
| 1919 | 2377 | |
@@ -1944,8 +2402,11 @@ discard block |
||
| 1944 | 2402 | return "error : ".$e->getMessage(); |
| 1945 | 2403 | } |
| 1946 | 2404 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1947 | - if ($row['nb'] > 0) return false; |
|
| 1948 | - else return true; |
|
| 2405 | + if ($row['nb'] > 0) { |
|
| 2406 | + return false; |
|
| 2407 | + } else { |
|
| 2408 | + return true; |
|
| 2409 | + } |
|
| 1949 | 2410 | } |
| 1950 | 2411 | |
| 1951 | 2412 | public static function insert_last_notam_update() { |
@@ -1974,8 +2435,11 @@ discard block |
||
| 1974 | 2435 | return "error : ".$e->getMessage(); |
| 1975 | 2436 | } |
| 1976 | 2437 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 1977 | - if ($row['nb'] > 0) return false; |
|
| 1978 | - else return true; |
|
| 2438 | + if ($row['nb'] > 0) { |
|
| 2439 | + return false; |
|
| 2440 | + } else { |
|
| 2441 | + return true; |
|
| 2442 | + } |
|
| 1979 | 2443 | } |
| 1980 | 2444 | |
| 1981 | 2445 | public static function insert_last_airspace_update() { |
@@ -2005,8 +2469,11 @@ discard block |
||
| 2005 | 2469 | return "error : ".$e->getMessage(); |
| 2006 | 2470 | } |
| 2007 | 2471 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2008 | - if ($row['nb'] > 0) return false; |
|
| 2009 | - else return true; |
|
| 2472 | + if ($row['nb'] > 0) { |
|
| 2473 | + return false; |
|
| 2474 | + } else { |
|
| 2475 | + return true; |
|
| 2476 | + } |
|
| 2010 | 2477 | } |
| 2011 | 2478 | |
| 2012 | 2479 | public static function insert_last_owner_update() { |
@@ -2035,8 +2502,11 @@ discard block |
||
| 2035 | 2502 | return "error : ".$e->getMessage(); |
| 2036 | 2503 | } |
| 2037 | 2504 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2038 | - if ($row['nb'] > 0) return false; |
|
| 2039 | - else return true; |
|
| 2505 | + if ($row['nb'] > 0) { |
|
| 2506 | + return false; |
|
| 2507 | + } else { |
|
| 2508 | + return true; |
|
| 2509 | + } |
|
| 2040 | 2510 | } |
| 2041 | 2511 | |
| 2042 | 2512 | public static function insert_last_schedules_update() { |
@@ -2065,8 +2535,11 @@ discard block |
||
| 2065 | 2535 | return "error : ".$e->getMessage(); |
| 2066 | 2536 | } |
| 2067 | 2537 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 2068 | - if ($row['nb'] > 0) return false; |
|
| 2069 | - else return true; |
|
| 2538 | + if ($row['nb'] > 0) { |
|
| 2539 | + return false; |
|
| 2540 | + } else { |
|
| 2541 | + return true; |
|
| 2542 | + } |
|
| 2070 | 2543 | } |
| 2071 | 2544 | |
| 2072 | 2545 | public static function insert_last_tle_update() { |
@@ -146,20 +146,6 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | /** Predict first pass after a certain time. |
| 148 | 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 | 149 | */ |
| 164 | 150 | public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
| 165 | 151 | { |
@@ -407,7 +393,7 @@ discard block |
||
| 407 | 393 | * @param Predict_QTH $qth The observer's location (QTH) data. |
| 408 | 394 | * @param float $start The julian date where calculation should start. |
| 409 | 395 | * @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. |
|
| 396 | + * @return double julain date of the next AOS or 0.0 if the satellite has no AOS. |
|
| 411 | 397 | * |
| 412 | 398 | * This function finds the time of AOS for the first coming pass taking place |
| 413 | 399 | * no earlier that start. |
@@ -563,7 +549,7 @@ discard block |
||
| 563 | 549 | * @param Predict_QTH $qth The QTH observer location data. |
| 564 | 550 | * @param float $start The time where calculation should start. (Julian Date) |
| 565 | 551 | * @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. |
|
| 552 | + * @return double time (julian date) of the next LOS or 0.0 if the satellite has no LOS. |
|
| 567 | 553 | * |
| 568 | 554 | * This function finds the time of LOS for the first coming pass taking place |
| 569 | 555 | * no earlier that start. |
@@ -648,7 +634,7 @@ discard block |
||
| 648 | 634 | * @param Predict_Sat $sat The satellite to find AOS for. |
| 649 | 635 | * @param Predict_QTH $qth The ground station. |
| 650 | 636 | * @param float $start Start time, prefereably now. |
| 651 | - * @return The time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 637 | + * @return double time of the previous AOS or 0.0 if the satellite has no AOS. |
|
| 652 | 638 | * |
| 653 | 639 | * This function can be used to find the AOS time in the past of the |
| 654 | 640 | * current pass. |
@@ -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 | } |
@@ -52,60 +52,60 @@ discard block |
||
| 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; |
|
| 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 | 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)*/ |
|
| 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 | 109 | |
| 110 | 110 | /* visibility constants */ |
| 111 | 111 | const SAT_VIS_NONE = 0; |
@@ -163,18 +163,18 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | public function get_pass(Predict_Sat $sat_in, Predict_QTH $qth, $start, $maxdt) |
| 165 | 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 */ |
|
| 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 | 171 | $t0 = $start; |
| 172 | - $tres = 0.0; /* required time resolution */ |
|
| 172 | + $tres = 0.0; /* required time resolution */ |
|
| 173 | 173 | $max_el = 0.0; /* maximum elevation */ |
| 174 | 174 | $pass = null; |
| 175 | 175 | $detail = null; |
| 176 | 176 | $done = false; |
| 177 | - $iter = 0; /* number of iterations */ |
|
| 177 | + $iter = 0; /* number of iterations */ |
|
| 178 | 178 | /* FIXME: watchdog */ |
| 179 | 179 | |
| 180 | 180 | /*copy sat_in to a working structure*/ |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | $sat_working = clone $sat_in; |
| 183 | 183 | |
| 184 | 184 | /* get time resolution; sat-cfg stores it in seconds */ |
| 185 | - $tres = $this->timeRes / 86400.0; |
|
| 185 | + $tres = $this->timeRes/86400.0; |
|
| 186 | 186 | |
| 187 | 187 | /* loop until we find a pass with elevation > SAT_CFG_INT_PRED_MIN_EL |
| 188 | 188 | or we run out of time |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | /* aos = 0.0 means no aos */ |
| 208 | 208 | if ($aos == 0.0) { |
| 209 | 209 | $done = true; |
| 210 | - } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt)) ) { |
|
| 210 | + } else if (($maxdt > 0.0) && ($aos > ($start + $maxdt))) { |
|
| 211 | 211 | /* check whether we are within time limits; |
| 212 | 212 | maxdt = 0 mean no time limit. |
| 213 | 213 | */ |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $dt = $los - $aos; |
| 218 | 218 | |
| 219 | 219 | /* get time step, which will give us the max number of entries */ |
| 220 | - $step = $dt / $this->numEntries; |
|
| 220 | + $step = $dt/$this->numEntries; |
|
| 221 | 221 | |
| 222 | 222 | /* but if this is smaller than the required resolution |
| 223 | 223 | we go with the resolution |
@@ -369,9 +369,9 @@ discard block |
||
| 369 | 369 | $solar_set = new Predict_ObsSet(); |
| 370 | 370 | |
| 371 | 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; |
|
| 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 | 375 | $obs_geodetic->theta = 0; |
| 376 | 376 | |
| 377 | 377 | Predict_Solar::Calculate_Solar_Position($jul_utc, $solar_vector); |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | |
| 453 | 453 | /* coarse time steps */ |
| 454 | 454 | while (($sat->el < -1.0) && ($t <= ($start + $maxdt))) { |
| 455 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 455 | + $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0); |
|
| 456 | 456 | $this->predict_calc($sat, $qth, $t); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | if (abs($sat->el) < 0.005) { |
| 463 | 463 | $aostime = $t; |
| 464 | 464 | } else { |
| 465 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 465 | + $t -= $sat->el*sqrt($sat->alt)/530000.0; |
|
| 466 | 466 | $this->predict_calc($sat, $qth, $t); |
| 467 | 467 | } |
| 468 | 468 | } |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | /* coarse time steps */ |
| 473 | 473 | while ($sat->el < -1.0) { |
| 474 | 474 | |
| 475 | - $t -= 0.00035 * ($sat->el * (($sat->alt / 8400.0) + 0.46) - 2.0); |
|
| 475 | + $t -= 0.00035*($sat->el*(($sat->alt/8400.0) + 0.46) - 2.0); |
|
| 476 | 476 | $this->predict_calc($sat, $qth, $t); |
| 477 | 477 | } |
| 478 | 478 | |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | if (abs($sat->el) < 0.005) { |
| 483 | 483 | $aostime = $t; |
| 484 | 484 | } else { |
| 485 | - $t -= $sat->el * sqrt($sat->alt) / 530000.0; |
|
| 485 | + $t -= $sat->el*sqrt($sat->alt)/530000.0; |
|
| 486 | 486 | $this->predict_calc($sat, $qth, $t); |
| 487 | 487 | } |
| 488 | 488 | |
@@ -504,17 +504,17 @@ discard block |
||
| 504 | 504 | $sat_geodetic = new Predict_Geodetic(); |
| 505 | 505 | $obs_geodetic = new Predict_Geodetic(); |
| 506 | 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; |
|
| 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 | 510 | $obs_geodetic->theta = 0; |
| 511 | 511 | |
| 512 | 512 | $sat->jul_utc = $t; |
| 513 | - $sat->tsince = ($sat->jul_utc - $sat->jul_epoch) * self::xmnpda; |
|
| 513 | + $sat->tsince = ($sat->jul_utc - $sat->jul_epoch)*self::xmnpda; |
|
| 514 | 514 | |
| 515 | 515 | /* call the norad routines according to the deep-space flag */ |
| 516 | 516 | $sgpsdp = Predict_SGPSDP::getInstance($sat); |
| 517 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 517 | + if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 518 | 518 | $sgpsdp->SDP4($sat, $sat->tsince); |
| 519 | 519 | } else { |
| 520 | 520 | $sgpsdp->SGP4($sat, $sat->tsince); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
| 524 | 524 | |
| 525 | 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); |
|
| 526 | + $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z); |
|
| 527 | 527 | $sat->velo = $sat->vel->w; |
| 528 | 528 | Predict_SGPObs::Calculate_Obs($sat->jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
| 529 | 529 | Predict_SGPObs::Calculate_LatLonAlt($sat->jul_utc, $sat->pos, $sat_geodetic); |
@@ -544,16 +544,16 @@ discard block |
||
| 544 | 544 | $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
| 545 | 545 | $sat->alt = $sat_geodetic->alt; |
| 546 | 546 | $sat->ma = Predict_Math::Degrees($sat->phase); |
| 547 | - $sat->ma *= 256.0 / 360.0; |
|
| 547 | + $sat->ma *= 256.0/360.0; |
|
| 548 | 548 | $sat->phase = Predict_Math::Degrees($sat->phase); |
| 549 | 549 | |
| 550 | 550 | /* same formulas, but the one from predict is nicer */ |
| 551 | 551 | //sat->footprint = 2.0 * xkmper * acos (xkmper/sat->pos.w); |
| 552 | - $sat->footprint = 12756.33 * acos(self::xkmper / (self::xkmper + $sat->alt)); |
|
| 552 | + $sat->footprint = 12756.33*acos(self::xkmper/(self::xkmper + $sat->alt)); |
|
| 553 | 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; |
|
| 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 | 557 | } |
| 558 | 558 | |
| 559 | 559 | /** Find the LOS time of the next pass. |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | /* check whether satellite has aos */ |
| 586 | 586 | if (($sat->otype == Predict_SGPSDP::ORBIT_TYPE_GEO) || |
| 587 | 587 | ($sat->otype == Predict_SGPSDP::ORBIT_TYPE_DECAYED) || |
| 588 | - !$this->has_aos ($sat, $qth)) { |
|
| 588 | + !$this->has_aos($sat, $qth)) { |
|
| 589 | 589 | |
| 590 | 590 | return 0.0; |
| 591 | 591 | } |
@@ -607,14 +607,14 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | /* coarse steps */ |
| 609 | 609 | while (($sat->el >= 1.0) && ($t <= ($start + $maxdt))) { |
| 610 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 610 | + $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0; |
|
| 611 | 611 | $this->predict_calc($sat, $qth, $t); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | /* fine steps */ |
| 615 | - while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 615 | + while (($lostime == 0.0) && ($t <= ($start + $maxdt))) { |
|
| 616 | 616 | |
| 617 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 617 | + $t += $sat->el*sqrt($sat->alt)/502500.0; |
|
| 618 | 618 | $this->predict_calc($sat, $qth, $t); |
| 619 | 619 | |
| 620 | 620 | if (abs($sat->el) < 0.005) { |
@@ -626,14 +626,14 @@ discard block |
||
| 626 | 626 | |
| 627 | 627 | /* coarse steps */ |
| 628 | 628 | while ($sat->el >= 1.0) { |
| 629 | - $t += cos(($sat->el - 1.0) * self::de2ra) * sqrt($sat->alt) / 25000.0; |
|
| 629 | + $t += cos(($sat->el - 1.0)*self::de2ra)*sqrt($sat->alt)/25000.0; |
|
| 630 | 630 | $this->predict_calc($sat, $qth, $t); |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | /* fine steps */ |
| 634 | 634 | while ($lostime == 0.0) { |
| 635 | 635 | |
| 636 | - $t += $sat->el * sqrt($sat->alt) / 502500.0; |
|
| 636 | + $t += $sat->el*sqrt($sat->alt)/502500.0; |
|
| 637 | 637 | $this->predict_calc($sat, $qth, $t); |
| 638 | 638 | |
| 639 | 639 | if (abs($sat->el) < 0.005) |
@@ -701,10 +701,10 @@ discard block |
||
| 701 | 701 | $lin = self::pi - $lin; |
| 702 | 702 | } |
| 703 | 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; |
|
| 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 | 706 | |
| 707 | - if ((acos(self::xkmper / ($apogee + self::xkmper)) + ($lin)) > abs($qth->lat * self::de2ra)) { |
|
| 707 | + if ((acos(self::xkmper/($apogee + self::xkmper)) + ($lin)) > abs($qth->lat*self::de2ra)) { |
|
| 708 | 708 | $retcode = true; |
| 709 | 709 | } else { |
| 710 | 710 | $retcode = false; |
@@ -866,10 +866,10 @@ discard block |
||
| 866 | 866 | */ |
| 867 | 867 | public function azDegreesToDirection($az = 0) |
| 868 | 868 | { |
| 869 | - $i = floor($az / 22.5); |
|
| 870 | - $m = (22.5 * (2 * $i + 1)) / 2; |
|
| 869 | + $i = floor($az/22.5); |
|
| 870 | + $m = (22.5*(2*$i + 1))/2; |
|
| 871 | 871 | $i = ($az >= $m) ? $i + 1 : $i; |
| 872 | 872 | |
| 873 | - return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i * 3, 3)); |
|
| 873 | + return trim(substr('N NNENE ENEE ESESE SSES SSWSW WSWW WNWNW NNWN ', $i*3, 3)); |
|
| 874 | 874 | } |
| 875 | 875 | } |
@@ -636,8 +636,9 @@ |
||
| 636 | 636 | $t += $sat->el * sqrt($sat->alt) / 502500.0; |
| 637 | 637 | $this->predict_calc($sat, $qth, $t); |
| 638 | 638 | |
| 639 | - if (abs($sat->el) < 0.005) |
|
| 640 | - $lostime = $t; |
|
| 639 | + if (abs($sat->el) < 0.005) { |
|
| 640 | + $lostime = $t; |
|
| 641 | + } |
|
| 641 | 642 | } |
| 642 | 643 | } |
| 643 | 644 | |
@@ -42,6 +42,10 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /* Returns arccosine of rgument */ |
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param double $arg |
|
| 48 | + */ |
|
| 45 | 49 | public static function ArcCos($arg) |
| 46 | 50 | { |
| 47 | 51 | return Predict::pio2 - self::ArcSin($arg); |
@@ -68,6 +72,10 @@ discard block |
||
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param integer $k |
|
| 78 | + */ |
|
| 71 | 79 | public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
| 72 | 80 | { |
| 73 | 81 | $v2->x = $k * $v1->x; |
@@ -155,6 +163,10 @@ discard block |
||
| 155 | 163 | } |
| 156 | 164 | |
| 157 | 165 | /* Returns arg1 mod arg2 */ |
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @param double $arg1 |
|
| 169 | + */ |
|
| 158 | 170 | public static function Modulus($arg1, $arg2) |
| 159 | 171 | { |
| 160 | 172 | $ret_val = $arg1; |
@@ -169,6 +181,10 @@ discard block |
||
| 169 | 181 | } |
| 170 | 182 | |
| 171 | 183 | /* Returns fractional part of double argument */ |
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @param double $arg |
|
| 187 | + */ |
|
| 172 | 188 | public static function Frac($arg) |
| 173 | 189 | { |
| 174 | 190 | return $arg - floor($arg); |
@@ -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 | } |
@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | /* Returns sign of a float */ |
| 23 | 23 | public static function Sign($arg) |
| 24 | 24 | { |
| 25 | - if ($arg > 0 ) { |
|
| 25 | + if ($arg > 0) { |
|
| 26 | 26 | return 1; |
| 27 | - } else if ($arg < 0 ) { |
|
| 27 | + } else if ($arg < 0) { |
|
| 28 | 28 | return -1; |
| 29 | 29 | } else { |
| 30 | 30 | return 0; |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | /* Returns the arcsine of the argument */ |
| 35 | 35 | public static function ArcSin($arg) |
| 36 | 36 | { |
| 37 | - if (abs($arg) >= 1 ) { |
|
| 38 | - return (self::Sign($arg) * Predict::pio2); |
|
| 37 | + if (abs($arg) >= 1) { |
|
| 38 | + return (self::Sign($arg)*Predict::pio2); |
|
| 39 | 39 | } else { |
| 40 | - return(atan($arg / sqrt(1 - $arg * $arg))); |
|
| 40 | + return(atan($arg/sqrt(1 - $arg*$arg))); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $v3->y = $v1->y + $v2->y; |
| 55 | 55 | $v3->z = $v1->z + $v2->z; |
| 56 | 56 | |
| 57 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 57 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /* Subtracts vector v2 from v1 to produce v3 */ |
@@ -64,16 +64,16 @@ discard block |
||
| 64 | 64 | $v3->y = $v1->y - $v2->y; |
| 65 | 65 | $v3->z = $v1->z - $v2->z; |
| 66 | 66 | |
| 67 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 67 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /* Multiplies the vector v1 by the scalar k to produce the vector v2 */ |
| 71 | 71 | public static function Scalar_Multiply($k, Predict_Vector $v1, Predict_Vector $v2) |
| 72 | 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; |
|
| 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 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /* Multiplies the vector v1 by the scalar k */ |
@@ -83,35 +83,35 @@ discard block |
||
| 83 | 83 | $v->y *= $k; |
| 84 | 84 | $v->z *= $k; |
| 85 | 85 | |
| 86 | - $v->w = sqrt($v->x * $v->x + $v->y * $v->y + $v->z * $v->z); |
|
| 86 | + $v->w = sqrt($v->x*$v->x + $v->y*$v->y + $v->z*$v->z); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /* Returns the dot product of two vectors */ |
| 90 | 90 | public static function Dot(Predict_Vector $v1, Predict_Vector $v2) |
| 91 | 91 | { |
| 92 | - return ($v1->x * $v2->x + $v1->y * $v2->y + $v1->z * $v2->z); |
|
| 92 | + return ($v1->x*$v2->x + $v1->y*$v2->y + $v1->z*$v2->z); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /* Calculates the angle between vectors v1 and v2 */ |
| 96 | 96 | public static function Angle(Predict_Vector $v1, Predict_Vector $v2) |
| 97 | 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))); |
|
| 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 | 101 | } |
| 102 | 102 | |
| 103 | 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) |
|
| 104 | + public static function Cross(Predict_Vector $v1, Predict_Vector $v2, Predict_Vector $v3) |
|
| 105 | 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; |
|
| 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 | 109 | |
| 110 | - $v3->w = sqrt($v3->x * $v3->x + $v3->y * $v3->y + $v3->z * $v3->z); |
|
| 110 | + $v3->w = sqrt($v3->x*$v3->x + $v3->y*$v3->y + $v3->z*$v3->z); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /* Normalizes a vector */ |
| 114 | - public static function Normalize(Predict_Vector $v ) |
|
| 114 | + public static function Normalize(Predict_Vector $v) |
|
| 115 | 115 | { |
| 116 | 116 | $v->x /= $v->w; |
| 117 | 117 | $v->y /= $v->w; |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | } else { |
| 131 | 131 | if ($cosx > 0) { |
| 132 | 132 | if ($sinx > 0) { |
| 133 | - return atan($sinx / $cosx); |
|
| 133 | + return atan($sinx/$cosx); |
|
| 134 | 134 | } else { |
| 135 | - return Predict::twopi + atan($sinx / $cosx); |
|
| 135 | + return Predict::twopi + atan($sinx/$cosx); |
|
| 136 | 136 | } |
| 137 | 137 | } else { |
| 138 | - return Predict::pi + atan($sinx / $cosx); |
|
| 138 | + return Predict::pi + atan($sinx/$cosx); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -144,8 +144,8 @@ discard block |
||
| 144 | 144 | public static function FMod2p($x) |
| 145 | 145 | { |
| 146 | 146 | $ret_val = $x; |
| 147 | - $i = (int) ($ret_val / Predict::twopi); |
|
| 148 | - $ret_val -= $i * Predict::twopi; |
|
| 147 | + $i = (int) ($ret_val/Predict::twopi); |
|
| 148 | + $ret_val -= $i*Predict::twopi; |
|
| 149 | 149 | |
| 150 | 150 | if ($ret_val < 0) { |
| 151 | 151 | $ret_val += Predict::twopi; |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | public static function Modulus($arg1, $arg2) |
| 159 | 159 | { |
| 160 | 160 | $ret_val = $arg1; |
| 161 | - $i = (int) ($ret_val / $arg2); |
|
| 162 | - $ret_val -= $i * $arg2; |
|
| 161 | + $i = (int) ($ret_val/$arg2); |
|
| 162 | + $ret_val -= $i*$arg2; |
|
| 163 | 163 | |
| 164 | 164 | if ($ret_val < 0) { |
| 165 | 165 | $ret_val += $arg2; |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | public static function Convert_Sat_State(Predict_Vector $pos, Predict_Vector $vel) |
| 180 | 180 | { |
| 181 | 181 | self::Scale_Vector(Predict::xkmper, $pos); |
| 182 | - self::Scale_Vector(Predict::xkmper * Predict::xmnpda / Predict::secday, $vel); |
|
| 182 | + self::Scale_Vector(Predict::xkmper*Predict::xmnpda/Predict::secday, $vel); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /* Returns angle in radians from arg in degrees */ |
| 186 | 186 | public static function Radians($arg) |
| 187 | 187 | { |
| 188 | - return $arg * Predict::de2ra; |
|
| 188 | + return $arg*Predict::de2ra; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | /* Returns angle in degrees from arg in rads */ |
| 192 | 192 | public static function Degrees($arg) |
| 193 | 193 | { |
| 194 | - return $arg / Predict::de2ra; |
|
| 194 | + return $arg/Predict::de2ra; |
|
| 195 | 195 | } |
| 196 | 196 | } |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** Initialise satellite data. |
| 127 | - * @param sat The satellite to initialise. |
|
| 128 | - * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 127 | + * @param sat Predict_Sat satellite to initialise. |
|
| 128 | + * @param qth Predict_QTH QTH info, use (0,0) if NULL. |
|
| 129 | 129 | * |
| 130 | 130 | * This function calculates the satellite data at t = 0, ie. epoch time |
| 131 | 131 | * The function is called automatically by gtk_sat_data_read_sat. |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | /** Determinte whether satellite is in geostationary orbit. |
| 218 | 218 | * @author John A. Magliacane, KD2BD |
| 219 | - * @param sat Pointer to satellite data. |
|
| 220 | - * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 219 | + * @param sat Predict_Sat to satellite data. |
|
| 220 | + * @return boolean if the satellite appears to be in geostationary orbit, |
|
| 221 | 221 | * FALSE otherwise. |
| 222 | 222 | * |
| 223 | 223 | * A satellite is in geostationary orbit if |
@@ -239,8 +239,8 @@ discard block |
||
| 239 | 239 | /** Determine whether satellite has decayed. |
| 240 | 240 | * @author John A. Magliacane, KD2BD |
| 241 | 241 | * @author Alexandru Csete, OZ9AEC |
| 242 | - * @param sat Pointer to satellite data. |
|
| 243 | - * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 242 | + * @param sat Predict_Sat to satellite data. |
|
| 243 | + * @return boolean if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | 244 | * @bug Modified version of the predict code but it is not tested. |
| 245 | 245 | * |
| 246 | 246 | * A satellite is decayed if |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * @param float $time The daynum the satellite is calculated for |
| 274 | 274 | * @param Predict_QTH $qth The observer location |
| 275 | 275 | * |
| 276 | - * @return null on failure, float otherwise |
|
| 276 | + * @return null|double on failure, float otherwise |
|
| 277 | 277 | */ |
| 278 | 278 | public function calculateApparentMagnitude($time, Predict_QTH $qth) |
| 279 | 279 | { |
@@ -22,304 +22,304 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Predict_Sat |
| 24 | 24 | { |
| 25 | - // Fifth root of a hundred, used for magnitude calculation |
|
| 26 | - const POGSONS_RATIO = 2.5118864315096; |
|
| 27 | - |
|
| 28 | - public $name = null; |
|
| 29 | - public $nickname = null; |
|
| 30 | - public $website = null; |
|
| 31 | - |
|
| 32 | - public $tle = null; /*!< Keplerian elements */ |
|
| 33 | - public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | - public $sgps = null; |
|
| 35 | - public $dps = null; |
|
| 36 | - public $deep_arg = null; |
|
| 37 | - public $pos = null; /*!< Raw position and range */ |
|
| 38 | - public $vel = null; /*!< Raw velocity */ |
|
| 39 | - |
|
| 40 | - /*** FIXME: REMOVE */ |
|
| 41 | - public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | - public $astro = null; /*!< Ra and Decl */ |
|
| 43 | - /*** END */ |
|
| 44 | - |
|
| 45 | - /* time keeping fields */ |
|
| 46 | - public $jul_epoch = null; |
|
| 47 | - public $jul_utc = null; |
|
| 48 | - public $tsince = null; |
|
| 49 | - public $aos = null; /*!< Next AOS. */ |
|
| 50 | - public $los = null; /*!< Next LOS */ |
|
| 51 | - |
|
| 52 | - public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | - public $el = null; /*!< Elevation [deg] */ |
|
| 54 | - public $range = null; /*!< Range [km] */ |
|
| 55 | - public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | - public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | - public $dec = null; /*!< Declination [deg] */ |
|
| 58 | - public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | - public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | - public $alt = null; /*!< altitude [km] */ |
|
| 61 | - public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | - public $ma = null; /*!< mean anomaly */ |
|
| 63 | - public $footprint = null; /*!< footprint */ |
|
| 64 | - public $phase = null; /*!< orbit phase */ |
|
| 65 | - public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | - public $orbit = null; /*!< orbit number */ |
|
| 67 | - public $otype = null; /*!< orbit type. */ |
|
| 68 | - |
|
| 69 | - public function __construct(Predict_TLE $tle) |
|
| 70 | - { |
|
| 71 | - $headerParts = explode(' ', $tle->header); |
|
| 72 | - $this->name = $headerParts[0]; |
|
| 73 | - $this->nickname = $this->name; |
|
| 74 | - $this->tle = $tle; |
|
| 75 | - $this->pos = new Predict_Vector(); |
|
| 76 | - $this->vel = new Predict_Vector(); |
|
| 77 | - $this->sgps = new Predict_SGSDPStatic(); |
|
| 78 | - $this->deep_arg = new Predict_DeepArg(); |
|
| 79 | - $this->dps = new Predict_DeepStatic(); |
|
| 80 | - |
|
| 81 | - $this->select_ephemeris(); |
|
| 82 | - $this->sat_data_init_sat($this); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /* Selects the apropriate ephemeris type to be used */ |
|
| 86 | - /* for predictions according to the data in the TLE */ |
|
| 87 | - /* It also processes values in the tle set so that */ |
|
| 88 | - /* they are apropriate for the sgp4/sdp4 routines */ |
|
| 89 | - public function select_ephemeris() |
|
| 90 | - { |
|
| 91 | - /* Preprocess tle set */ |
|
| 92 | - $this->tle->xnodeo *= Predict::de2ra; |
|
| 93 | - $this->tle->omegao *= Predict::de2ra; |
|
| 94 | - $this->tle->xmo *= Predict::de2ra; |
|
| 95 | - $this->tle->xincl *= Predict::de2ra; |
|
| 96 | - $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 97 | - |
|
| 98 | - /* store mean motion before conversion */ |
|
| 99 | - $this->meanmo = $this->tle->xno; |
|
| 100 | - $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 101 | - $this->tle->xndt2o *= $temp; |
|
| 102 | - $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 103 | - $this->tle->bstar /= Predict::ae; |
|
| 104 | - |
|
| 105 | - /* Period > 225 minutes is deep space */ |
|
| 106 | - $dd1 = Predict::xke / $this->tle->xno; |
|
| 107 | - $dd2 = Predict::tothrd; |
|
| 108 | - $a1 = pow($dd1, $dd2); |
|
| 109 | - $r1 = cos($this->tle->xincl); |
|
| 110 | - $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | - $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | - $del1 = $temp / ($a1 * $a1); |
|
| 113 | - $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | - ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | - $delo = $temp / ($ao * $ao); |
|
| 116 | - $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 117 | - |
|
| 118 | - /* Select a deep-space/near-earth ephemeris */ |
|
| 119 | - if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 120 | - $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 121 | - } else { |
|
| 122 | - $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** Initialise satellite data. |
|
| 127 | - * @param sat The satellite to initialise. |
|
| 128 | - * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 129 | - * |
|
| 130 | - * This function calculates the satellite data at t = 0, ie. epoch time |
|
| 131 | - * The function is called automatically by gtk_sat_data_read_sat. |
|
| 132 | - */ |
|
| 133 | - public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
| 134 | - { |
|
| 135 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 136 | - $obs_set = new Predict_ObsSet(); |
|
| 137 | - $sat_geodetic = new Predict_Geodetic(); |
|
| 138 | - /* double jul_utc, age; */ |
|
| 139 | - |
|
| 140 | - $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
| 141 | - $sat->jul_epoch = $jul_utc; |
|
| 142 | - |
|
| 143 | - /* initialise observer location */ |
|
| 144 | - if ($qth != null) { |
|
| 145 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 148 | - $obs_geodetic->theta = 0; |
|
| 149 | - } |
|
| 150 | - else { |
|
| 151 | - $obs_geodetic->lon = 0.0; |
|
| 152 | - $obs_geodetic->lat = 0.0; |
|
| 153 | - $obs_geodetic->alt = 0.0; |
|
| 154 | - $obs_geodetic->theta = 0; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /* execute computations */ |
|
| 158 | - $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
| 159 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | - $sdpsgp->SDP4($sat, 0.0); |
|
| 161 | - } else { |
|
| 162 | - $sdpsgp->SGP4($sat, 0.0); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /* scale position and velocity to km and km/sec */ |
|
| 166 | - Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 167 | - |
|
| 168 | - /* get the velocity of the satellite */ |
|
| 169 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 170 | - $sat->velo = $sat->vel->w; |
|
| 171 | - Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 172 | - Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
| 173 | - |
|
| 174 | - while ($sat_geodetic->lon < -Predict::pi) { |
|
| 175 | - $sat_geodetic->lon += Predict::twopi; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - while ($sat_geodetic->lon > Predict::pi) { |
|
| 179 | - $sat_geodetic->lon -= Predict::twopi; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 183 | - $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 184 | - $sat->range = $obs_set->range; |
|
| 185 | - $sat->range_rate = $obs_set->range_rate; |
|
| 186 | - $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 187 | - $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 188 | - $sat->alt = $sat_geodetic->alt; |
|
| 189 | - $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 190 | - $sat->ma *= 256.0 / 360.0; |
|
| 191 | - $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 192 | - $age = 0.0; |
|
| 193 | - $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | - $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | - $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | - |
|
| 197 | - /* orbit type */ |
|
| 198 | - $sat->otype = $sat->get_orbit_type($sat); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - public function get_orbit_type(Predict_Sat $sat) |
|
| 202 | - { |
|
| 203 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 204 | - |
|
| 205 | - if ($this->geostationary($sat)) { |
|
| 206 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
| 207 | - } else if ($this->decayed($sat)) { |
|
| 208 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
| 209 | - } else { |
|
| 210 | - $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return $orbit; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - |
|
| 217 | - /** Determinte whether satellite is in geostationary orbit. |
|
| 218 | - * @author John A. Magliacane, KD2BD |
|
| 219 | - * @param sat Pointer to satellite data. |
|
| 220 | - * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 221 | - * FALSE otherwise. |
|
| 222 | - * |
|
| 223 | - * A satellite is in geostationary orbit if |
|
| 224 | - * |
|
| 225 | - * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
| 226 | - * |
|
| 227 | - * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
| 228 | - */ |
|
| 229 | - public function geostationary(Predict_Sat $sat) |
|
| 230 | - { |
|
| 231 | - if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
| 232 | - return true; |
|
| 233 | - } else { |
|
| 234 | - return false; |
|
| 235 | - } |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** Determine whether satellite has decayed. |
|
| 240 | - * @author John A. Magliacane, KD2BD |
|
| 241 | - * @author Alexandru Csete, OZ9AEC |
|
| 242 | - * @param sat Pointer to satellite data. |
|
| 243 | - * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | - * @bug Modified version of the predict code but it is not tested. |
|
| 245 | - * |
|
| 246 | - * A satellite is decayed if |
|
| 247 | - * |
|
| 248 | - * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
| 249 | - * |
|
| 250 | - */ |
|
| 251 | - public function decayed(Predict_Sat $sat) |
|
| 252 | - { |
|
| 253 | - /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
| 25 | + // Fifth root of a hundred, used for magnitude calculation |
|
| 26 | + const POGSONS_RATIO = 2.5118864315096; |
|
| 27 | + |
|
| 28 | + public $name = null; |
|
| 29 | + public $nickname = null; |
|
| 30 | + public $website = null; |
|
| 31 | + |
|
| 32 | + public $tle = null; /*!< Keplerian elements */ |
|
| 33 | + public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | + public $sgps = null; |
|
| 35 | + public $dps = null; |
|
| 36 | + public $deep_arg = null; |
|
| 37 | + public $pos = null; /*!< Raw position and range */ |
|
| 38 | + public $vel = null; /*!< Raw velocity */ |
|
| 39 | + |
|
| 40 | + /*** FIXME: REMOVE */ |
|
| 41 | + public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | + public $astro = null; /*!< Ra and Decl */ |
|
| 43 | + /*** END */ |
|
| 44 | + |
|
| 45 | + /* time keeping fields */ |
|
| 46 | + public $jul_epoch = null; |
|
| 47 | + public $jul_utc = null; |
|
| 48 | + public $tsince = null; |
|
| 49 | + public $aos = null; /*!< Next AOS. */ |
|
| 50 | + public $los = null; /*!< Next LOS */ |
|
| 51 | + |
|
| 52 | + public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | + public $el = null; /*!< Elevation [deg] */ |
|
| 54 | + public $range = null; /*!< Range [km] */ |
|
| 55 | + public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | + public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | + public $dec = null; /*!< Declination [deg] */ |
|
| 58 | + public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | + public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | + public $alt = null; /*!< altitude [km] */ |
|
| 61 | + public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | + public $ma = null; /*!< mean anomaly */ |
|
| 63 | + public $footprint = null; /*!< footprint */ |
|
| 64 | + public $phase = null; /*!< orbit phase */ |
|
| 65 | + public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | + public $orbit = null; /*!< orbit number */ |
|
| 67 | + public $otype = null; /*!< orbit type. */ |
|
| 68 | + |
|
| 69 | + public function __construct(Predict_TLE $tle) |
|
| 70 | + { |
|
| 71 | + $headerParts = explode(' ', $tle->header); |
|
| 72 | + $this->name = $headerParts[0]; |
|
| 73 | + $this->nickname = $this->name; |
|
| 74 | + $this->tle = $tle; |
|
| 75 | + $this->pos = new Predict_Vector(); |
|
| 76 | + $this->vel = new Predict_Vector(); |
|
| 77 | + $this->sgps = new Predict_SGSDPStatic(); |
|
| 78 | + $this->deep_arg = new Predict_DeepArg(); |
|
| 79 | + $this->dps = new Predict_DeepStatic(); |
|
| 80 | + |
|
| 81 | + $this->select_ephemeris(); |
|
| 82 | + $this->sat_data_init_sat($this); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /* Selects the apropriate ephemeris type to be used */ |
|
| 86 | + /* for predictions according to the data in the TLE */ |
|
| 87 | + /* It also processes values in the tle set so that */ |
|
| 88 | + /* they are apropriate for the sgp4/sdp4 routines */ |
|
| 89 | + public function select_ephemeris() |
|
| 90 | + { |
|
| 91 | + /* Preprocess tle set */ |
|
| 92 | + $this->tle->xnodeo *= Predict::de2ra; |
|
| 93 | + $this->tle->omegao *= Predict::de2ra; |
|
| 94 | + $this->tle->xmo *= Predict::de2ra; |
|
| 95 | + $this->tle->xincl *= Predict::de2ra; |
|
| 96 | + $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 97 | + |
|
| 98 | + /* store mean motion before conversion */ |
|
| 99 | + $this->meanmo = $this->tle->xno; |
|
| 100 | + $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 101 | + $this->tle->xndt2o *= $temp; |
|
| 102 | + $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 103 | + $this->tle->bstar /= Predict::ae; |
|
| 104 | + |
|
| 105 | + /* Period > 225 minutes is deep space */ |
|
| 106 | + $dd1 = Predict::xke / $this->tle->xno; |
|
| 107 | + $dd2 = Predict::tothrd; |
|
| 108 | + $a1 = pow($dd1, $dd2); |
|
| 109 | + $r1 = cos($this->tle->xincl); |
|
| 110 | + $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | + $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | + $del1 = $temp / ($a1 * $a1); |
|
| 113 | + $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | + ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | + $delo = $temp / ($ao * $ao); |
|
| 116 | + $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 117 | + |
|
| 118 | + /* Select a deep-space/near-earth ephemeris */ |
|
| 119 | + if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 120 | + $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 121 | + } else { |
|
| 122 | + $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** Initialise satellite data. |
|
| 127 | + * @param sat The satellite to initialise. |
|
| 128 | + * @param qth Optional QTH info, use (0,0) if NULL. |
|
| 129 | + * |
|
| 130 | + * This function calculates the satellite data at t = 0, ie. epoch time |
|
| 131 | + * The function is called automatically by gtk_sat_data_read_sat. |
|
| 132 | + */ |
|
| 133 | + public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) |
|
| 134 | + { |
|
| 135 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 136 | + $obs_set = new Predict_ObsSet(); |
|
| 137 | + $sat_geodetic = new Predict_Geodetic(); |
|
| 138 | + /* double jul_utc, age; */ |
|
| 139 | + |
|
| 140 | + $jul_utc = Predict_Time::Julian_Date_of_Epoch($sat->tle->epoch); // => tsince = 0.0 |
|
| 141 | + $sat->jul_epoch = $jul_utc; |
|
| 142 | + |
|
| 143 | + /* initialise observer location */ |
|
| 144 | + if ($qth != null) { |
|
| 145 | + $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | + $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 148 | + $obs_geodetic->theta = 0; |
|
| 149 | + } |
|
| 150 | + else { |
|
| 151 | + $obs_geodetic->lon = 0.0; |
|
| 152 | + $obs_geodetic->lat = 0.0; |
|
| 153 | + $obs_geodetic->alt = 0.0; |
|
| 154 | + $obs_geodetic->theta = 0; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /* execute computations */ |
|
| 158 | + $sdpsgp = Predict_SGPSDP::getInstance($sat); |
|
| 159 | + if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | + $sdpsgp->SDP4($sat, 0.0); |
|
| 161 | + } else { |
|
| 162 | + $sdpsgp->SGP4($sat, 0.0); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /* scale position and velocity to km and km/sec */ |
|
| 166 | + Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
|
| 167 | + |
|
| 168 | + /* get the velocity of the satellite */ |
|
| 169 | + $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 170 | + $sat->velo = $sat->vel->w; |
|
| 171 | + Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
|
| 172 | + Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
|
| 173 | + |
|
| 174 | + while ($sat_geodetic->lon < -Predict::pi) { |
|
| 175 | + $sat_geodetic->lon += Predict::twopi; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + while ($sat_geodetic->lon > Predict::pi) { |
|
| 179 | + $sat_geodetic->lon -= Predict::twopi; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $sat->az = Predict_Math::Degrees($obs_set->az); |
|
| 183 | + $sat->el = Predict_Math::Degrees($obs_set->el); |
|
| 184 | + $sat->range = $obs_set->range; |
|
| 185 | + $sat->range_rate = $obs_set->range_rate; |
|
| 186 | + $sat->ssplat = Predict_Math::Degrees($sat_geodetic->lat); |
|
| 187 | + $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
|
| 188 | + $sat->alt = $sat_geodetic->alt; |
|
| 189 | + $sat->ma = Predict_Math::Degrees($sat->phase); |
|
| 190 | + $sat->ma *= 256.0 / 360.0; |
|
| 191 | + $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 192 | + $age = 0.0; |
|
| 193 | + $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | + $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | + $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | + |
|
| 197 | + /* orbit type */ |
|
| 198 | + $sat->otype = $sat->get_orbit_type($sat); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + public function get_orbit_type(Predict_Sat $sat) |
|
| 202 | + { |
|
| 203 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 204 | + |
|
| 205 | + if ($this->geostationary($sat)) { |
|
| 206 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_GEO; |
|
| 207 | + } else if ($this->decayed($sat)) { |
|
| 208 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_DECAYED; |
|
| 209 | + } else { |
|
| 210 | + $orbit = Predict_SGPSDP::ORBIT_TYPE_UNKNOWN; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return $orbit; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + |
|
| 217 | + /** Determinte whether satellite is in geostationary orbit. |
|
| 218 | + * @author John A. Magliacane, KD2BD |
|
| 219 | + * @param sat Pointer to satellite data. |
|
| 220 | + * @return TRUE if the satellite appears to be in geostationary orbit, |
|
| 221 | + * FALSE otherwise. |
|
| 222 | + * |
|
| 223 | + * A satellite is in geostationary orbit if |
|
| 224 | + * |
|
| 225 | + * fabs (sat.meanmotion - 1.0027) < 0.0002 |
|
| 226 | + * |
|
| 227 | + * Note: Appearantly, the mean motion can deviate much more from 1.0027 than 0.0002 |
|
| 228 | + */ |
|
| 229 | + public function geostationary(Predict_Sat $sat) |
|
| 230 | + { |
|
| 231 | + if (abs($sat->meanmo - 1.0027) < 0.0002) { |
|
| 232 | + return true; |
|
| 233 | + } else { |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** Determine whether satellite has decayed. |
|
| 240 | + * @author John A. Magliacane, KD2BD |
|
| 241 | + * @author Alexandru Csete, OZ9AEC |
|
| 242 | + * @param sat Pointer to satellite data. |
|
| 243 | + * @return TRUE if the satellite appears to have decayed, FALSE otherwise. |
|
| 244 | + * @bug Modified version of the predict code but it is not tested. |
|
| 245 | + * |
|
| 246 | + * A satellite is decayed if |
|
| 247 | + * |
|
| 248 | + * satepoch + ((16.666666 - sat.meanmo) / (10.0*fabs(sat.drag))) < "now" |
|
| 249 | + * |
|
| 250 | + */ |
|
| 251 | + public function decayed(Predict_Sat $sat) |
|
| 252 | + { |
|
| 253 | + /* tle.xndt2o/(twopi/xmnpda/xmnpda) is the value before converted the |
|
| 254 | 254 | value matches up with the value in predict 2.2.3 */ |
| 255 | - /*** FIXME decayed is treated as a static quantity. |
|
| 255 | + /*** FIXME decayed is treated as a static quantity. |
|
| 256 | 256 | It is time dependent. Also sat->jul_utc is often zero |
| 257 | 257 | when this function is called |
| 258 | 258 | ***/ |
| 259 | - if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 260 | - return true; |
|
| 261 | - } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | - (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | - return true; |
|
| 264 | - } else { |
|
| 265 | - return false; |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
| 271 | - * magnitudes are listed inside the function for now. |
|
| 272 | - * |
|
| 273 | - * @param float $time The daynum the satellite is calculated for |
|
| 274 | - * @param Predict_QTH $qth The observer location |
|
| 275 | - * |
|
| 276 | - * @return null on failure, float otherwise |
|
| 277 | - */ |
|
| 278 | - public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
| 279 | - { |
|
| 280 | - // Recorded intrinsic magnitudes and their respective |
|
| 281 | - // illumination and distance from heavens-above.com |
|
| 282 | - static $intrinsicMagnitudes = array( |
|
| 283 | - '25544' => array( |
|
| 284 | - 'mag' => -1.3, |
|
| 285 | - 'illum' => .5, |
|
| 286 | - 'distance' => 1000, |
|
| 287 | - ) |
|
| 288 | - ); |
|
| 289 | - |
|
| 290 | - // Return null if we don't have a record of the intrinsic mag |
|
| 291 | - if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
| 292 | - return null; |
|
| 293 | - } |
|
| 294 | - $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
| 295 | - |
|
| 296 | - // Convert the observer's geodetic info to radians and km so |
|
| 297 | - // we can compare vectors |
|
| 298 | - $observerGeo = new Predict_Geodetic(); |
|
| 299 | - $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
| 300 | - $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
| 301 | - $observerGeo->alt = $qth->alt * 1000; |
|
| 302 | - |
|
| 303 | - // Now determine the sun and observer positions |
|
| 304 | - $observerPos = new Predict_Vector(); |
|
| 305 | - $observerVel = new Predict_Vector(); |
|
| 306 | - $solarVector = new Predict_Vector(); |
|
| 307 | - Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
| 308 | - Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
| 309 | - |
|
| 310 | - // Determine the solar phase and and thus the percent illumination |
|
| 311 | - $observerSatPos = new Predict_Vector(); |
|
| 312 | - Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
| 313 | - $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
| 314 | - $illum = $phaseAngle / 180; |
|
| 315 | - |
|
| 316 | - $illuminationChange = $illum / $imag['illum']; |
|
| 317 | - $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 318 | - $changeInMagnitude = log( |
|
| 319 | - $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 320 | - self::POGSONS_RATIO |
|
| 321 | - ); |
|
| 322 | - |
|
| 323 | - return $imag['mag'] - $changeInMagnitude; |
|
| 324 | - } |
|
| 259 | + if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 260 | + return true; |
|
| 261 | + } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | + (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | + return true; |
|
| 264 | + } else { |
|
| 265 | + return false; |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Experimental attempt at calculating apparent magnitude. Known intrinsic |
|
| 271 | + * magnitudes are listed inside the function for now. |
|
| 272 | + * |
|
| 273 | + * @param float $time The daynum the satellite is calculated for |
|
| 274 | + * @param Predict_QTH $qth The observer location |
|
| 275 | + * |
|
| 276 | + * @return null on failure, float otherwise |
|
| 277 | + */ |
|
| 278 | + public function calculateApparentMagnitude($time, Predict_QTH $qth) |
|
| 279 | + { |
|
| 280 | + // Recorded intrinsic magnitudes and their respective |
|
| 281 | + // illumination and distance from heavens-above.com |
|
| 282 | + static $intrinsicMagnitudes = array( |
|
| 283 | + '25544' => array( |
|
| 284 | + 'mag' => -1.3, |
|
| 285 | + 'illum' => .5, |
|
| 286 | + 'distance' => 1000, |
|
| 287 | + ) |
|
| 288 | + ); |
|
| 289 | + |
|
| 290 | + // Return null if we don't have a record of the intrinsic mag |
|
| 291 | + if (!isset($intrinsicMagnitudes[$this->tle->catnr])) { |
|
| 292 | + return null; |
|
| 293 | + } |
|
| 294 | + $imag = $intrinsicMagnitudes[$this->tle->catnr]; |
|
| 295 | + |
|
| 296 | + // Convert the observer's geodetic info to radians and km so |
|
| 297 | + // we can compare vectors |
|
| 298 | + $observerGeo = new Predict_Geodetic(); |
|
| 299 | + $observerGeo->lat = Predict_Math::Radians($qth->lat); |
|
| 300 | + $observerGeo->lon = Predict_Math::Radians($qth->lon); |
|
| 301 | + $observerGeo->alt = $qth->alt * 1000; |
|
| 302 | + |
|
| 303 | + // Now determine the sun and observer positions |
|
| 304 | + $observerPos = new Predict_Vector(); |
|
| 305 | + $observerVel = new Predict_Vector(); |
|
| 306 | + $solarVector = new Predict_Vector(); |
|
| 307 | + Predict_Solar::Calculate_Solar_Position($time, $solarVector); |
|
| 308 | + Predict_SGPObs::Calculate_User_PosVel($time, $observerGeo, $observerPos, $observerVel); |
|
| 309 | + |
|
| 310 | + // Determine the solar phase and and thus the percent illumination |
|
| 311 | + $observerSatPos = new Predict_Vector(); |
|
| 312 | + Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
|
| 313 | + $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
|
| 314 | + $illum = $phaseAngle / 180; |
|
| 315 | + |
|
| 316 | + $illuminationChange = $illum / $imag['illum']; |
|
| 317 | + $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 318 | + $changeInMagnitude = log( |
|
| 319 | + $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 320 | + self::POGSONS_RATIO |
|
| 321 | + ); |
|
| 322 | + |
|
| 323 | + return $imag['mag'] - $changeInMagnitude; |
|
| 324 | + } |
|
| 325 | 325 | } |
@@ -29,42 +29,42 @@ discard block |
||
| 29 | 29 | public $nickname = null; |
| 30 | 30 | public $website = null; |
| 31 | 31 | |
| 32 | - public $tle = null; /*!< Keplerian elements */ |
|
| 33 | - public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 32 | + public $tle = null; /*!< Keplerian elements */ |
|
| 33 | + public $flags = 0; /*!< Flags for algo ctrl */ |
|
| 34 | 34 | public $sgps = null; |
| 35 | 35 | public $dps = null; |
| 36 | 36 | public $deep_arg = null; |
| 37 | - public $pos = null; /*!< Raw position and range */ |
|
| 38 | - public $vel = null; /*!< Raw velocity */ |
|
| 37 | + public $pos = null; /*!< Raw position and range */ |
|
| 38 | + public $vel = null; /*!< Raw velocity */ |
|
| 39 | 39 | |
| 40 | 40 | /*** FIXME: REMOVE */ |
| 41 | - public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | - public $astro = null; /*!< Ra and Decl */ |
|
| 41 | + public $bearing = null; /*!< Az, El, range and vel */ |
|
| 42 | + public $astro = null; /*!< Ra and Decl */ |
|
| 43 | 43 | /*** END */ |
| 44 | 44 | |
| 45 | 45 | /* time keeping fields */ |
| 46 | 46 | public $jul_epoch = null; |
| 47 | 47 | public $jul_utc = null; |
| 48 | 48 | public $tsince = null; |
| 49 | - public $aos = null; /*!< Next AOS. */ |
|
| 50 | - public $los = null; /*!< Next LOS */ |
|
| 51 | - |
|
| 52 | - public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | - public $el = null; /*!< Elevation [deg] */ |
|
| 54 | - public $range = null; /*!< Range [km] */ |
|
| 55 | - public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | - public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | - public $dec = null; /*!< Declination [deg] */ |
|
| 58 | - public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | - public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | - public $alt = null; /*!< altitude [km] */ |
|
| 61 | - public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | - public $ma = null; /*!< mean anomaly */ |
|
| 63 | - public $footprint = null; /*!< footprint */ |
|
| 64 | - public $phase = null; /*!< orbit phase */ |
|
| 65 | - public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | - public $orbit = null; /*!< orbit number */ |
|
| 67 | - public $otype = null; /*!< orbit type. */ |
|
| 49 | + public $aos = null; /*!< Next AOS. */ |
|
| 50 | + public $los = null; /*!< Next LOS */ |
|
| 51 | + |
|
| 52 | + public $az = null; /*!< Azimuth [deg] */ |
|
| 53 | + public $el = null; /*!< Elevation [deg] */ |
|
| 54 | + public $range = null; /*!< Range [km] */ |
|
| 55 | + public $range_rate = null; /*!< Range Rate [km/sec] */ |
|
| 56 | + public $ra = null; /*!< Right Ascension [deg] */ |
|
| 57 | + public $dec = null; /*!< Declination [deg] */ |
|
| 58 | + public $ssplat = null; /*!< SSP latitude [deg] */ |
|
| 59 | + public $ssplon = null; /*!< SSP longitude [deg] */ |
|
| 60 | + public $alt = null; /*!< altitude [km] */ |
|
| 61 | + public $velo = null; /*!< velocity [km/s] */ |
|
| 62 | + public $ma = null; /*!< mean anomaly */ |
|
| 63 | + public $footprint = null; /*!< footprint */ |
|
| 64 | + public $phase = null; /*!< orbit phase */ |
|
| 65 | + public $meanmo = null; /*!< mean motion kept in rev/day */ |
|
| 66 | + public $orbit = null; /*!< orbit number */ |
|
| 67 | + public $otype = null; /*!< orbit type. */ |
|
| 68 | 68 | |
| 69 | 69 | public function __construct(Predict_TLE $tle) |
| 70 | 70 | { |
@@ -93,30 +93,30 @@ discard block |
||
| 93 | 93 | $this->tle->omegao *= Predict::de2ra; |
| 94 | 94 | $this->tle->xmo *= Predict::de2ra; |
| 95 | 95 | $this->tle->xincl *= Predict::de2ra; |
| 96 | - $temp = Predict::twopi / Predict::xmnpda / Predict::xmnpda; |
|
| 96 | + $temp = Predict::twopi/Predict::xmnpda/Predict::xmnpda; |
|
| 97 | 97 | |
| 98 | 98 | /* store mean motion before conversion */ |
| 99 | 99 | $this->meanmo = $this->tle->xno; |
| 100 | - $this->tle->xno = $this->tle->xno * $temp * Predict::xmnpda; |
|
| 100 | + $this->tle->xno = $this->tle->xno*$temp*Predict::xmnpda; |
|
| 101 | 101 | $this->tle->xndt2o *= $temp; |
| 102 | - $this->tle->xndd6o = $this->tle->xndd6o * $temp / Predict::xmnpda; |
|
| 102 | + $this->tle->xndd6o = $this->tle->xndd6o*$temp/Predict::xmnpda; |
|
| 103 | 103 | $this->tle->bstar /= Predict::ae; |
| 104 | 104 | |
| 105 | 105 | /* Period > 225 minutes is deep space */ |
| 106 | - $dd1 = Predict::xke / $this->tle->xno; |
|
| 106 | + $dd1 = Predict::xke/$this->tle->xno; |
|
| 107 | 107 | $dd2 = Predict::tothrd; |
| 108 | 108 | $a1 = pow($dd1, $dd2); |
| 109 | 109 | $r1 = cos($this->tle->xincl); |
| 110 | - $dd1 = 1.0 - $this->tle->eo * $this->tle->eo; |
|
| 111 | - $temp = Predict::ck2 * 1.5 * ($r1 * $r1 * 3.0 - 1.0) / pow($dd1, 1.5); |
|
| 112 | - $del1 = $temp / ($a1 * $a1); |
|
| 113 | - $ao = $a1 * (1.0 - $del1 * (Predict::tothrd * 0.5 + $del1 * |
|
| 114 | - ($del1 * 1.654320987654321 + 1.0))); |
|
| 115 | - $delo = $temp / ($ao * $ao); |
|
| 116 | - $xnodp = $this->tle->xno / ($delo + 1.0); |
|
| 110 | + $dd1 = 1.0 - $this->tle->eo*$this->tle->eo; |
|
| 111 | + $temp = Predict::ck2*1.5*($r1*$r1*3.0 - 1.0)/pow($dd1, 1.5); |
|
| 112 | + $del1 = $temp/($a1*$a1); |
|
| 113 | + $ao = $a1*(1.0 - $del1*(Predict::tothrd*0.5 + $del1* |
|
| 114 | + ($del1*1.654320987654321 + 1.0))); |
|
| 115 | + $delo = $temp/($ao*$ao); |
|
| 116 | + $xnodp = $this->tle->xno/($delo + 1.0); |
|
| 117 | 117 | |
| 118 | 118 | /* Select a deep-space/near-earth ephemeris */ |
| 119 | - if (Predict::twopi / $xnodp / Predict::xmnpda >= .15625) { |
|
| 119 | + if (Predict::twopi/$xnodp/Predict::xmnpda >= .15625) { |
|
| 120 | 120 | $this->flags |= Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
| 121 | 121 | } else { |
| 122 | 122 | $this->flags &= ~Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG; |
@@ -142,9 +142,9 @@ discard block |
||
| 142 | 142 | |
| 143 | 143 | /* initialise observer location */ |
| 144 | 144 | if ($qth != null) { |
| 145 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 146 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 147 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 145 | + $obs_geodetic->lon = $qth->lon*Predict::de2ra; |
|
| 146 | + $obs_geodetic->lat = $qth->lat*Predict::de2ra; |
|
| 147 | + $obs_geodetic->alt = $qth->alt/1000.0; |
|
| 148 | 148 | $obs_geodetic->theta = 0; |
| 149 | 149 | } |
| 150 | 150 | else { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /* execute computations */ |
| 158 | 158 | $sdpsgp = Predict_SGPSDP::getInstance($sat); |
| 159 | - if ($sat->flags & Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 159 | + if ($sat->flags&Predict_SGPSDP::DEEP_SPACE_EPHEM_FLAG) { |
|
| 160 | 160 | $sdpsgp->SDP4($sat, 0.0); |
| 161 | 161 | } else { |
| 162 | 162 | $sdpsgp->SGP4($sat, 0.0); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | Predict_Math::Convert_Sat_State($sat->pos, $sat->vel); |
| 167 | 167 | |
| 168 | 168 | /* get the velocity of the satellite */ |
| 169 | - $sat->vel->w = sqrt($sat->vel->x * $sat->vel->x + $sat->vel->y * $sat->vel->y + $sat->vel->z * $sat->vel->z); |
|
| 169 | + $sat->vel->w = sqrt($sat->vel->x*$sat->vel->x + $sat->vel->y*$sat->vel->y + $sat->vel->z*$sat->vel->z); |
|
| 170 | 170 | $sat->velo = $sat->vel->w; |
| 171 | 171 | Predict_SGPObs::Calculate_Obs($jul_utc, $sat->pos, $sat->vel, $obs_geodetic, $obs_set); |
| 172 | 172 | Predict_SGPObs::Calculate_LatLonAlt($jul_utc, $sat->pos, $sat_geodetic); |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | $sat->ssplon = Predict_Math::Degrees($sat_geodetic->lon); |
| 188 | 188 | $sat->alt = $sat_geodetic->alt; |
| 189 | 189 | $sat->ma = Predict_Math::Degrees($sat->phase); |
| 190 | - $sat->ma *= 256.0 / 360.0; |
|
| 191 | - $sat->footprint = 2.0 * Predict::xkmper * acos (Predict::xkmper/$sat->pos->w); |
|
| 190 | + $sat->ma *= 256.0/360.0; |
|
| 191 | + $sat->footprint = 2.0*Predict::xkmper*acos(Predict::xkmper/$sat->pos->w); |
|
| 192 | 192 | $age = 0.0; |
| 193 | - $sat->orbit = floor(($sat->tle->xno * Predict::xmnpda / Predict::twopi + |
|
| 194 | - $age * $sat->tle->bstar * Predict::ae) * $age + |
|
| 195 | - $sat->tle->xmo / Predict::twopi) + $sat->tle->revnum - 1; |
|
| 193 | + $sat->orbit = floor(($sat->tle->xno*Predict::xmnpda/Predict::twopi + |
|
| 194 | + $age*$sat->tle->bstar*Predict::ae)*$age + |
|
| 195 | + $sat->tle->xmo/Predict::twopi) + $sat->tle->revnum - 1; |
|
| 196 | 196 | |
| 197 | 197 | /* orbit type */ |
| 198 | 198 | $sat->otype = $sat->get_orbit_type($sat); |
@@ -256,10 +256,10 @@ discard block |
||
| 256 | 256 | It is time dependent. Also sat->jul_utc is often zero |
| 257 | 257 | when this function is called |
| 258 | 258 | ***/ |
| 259 | - if ((10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda))) == 0) { |
|
| 259 | + if ((10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda))) == 0) { |
|
| 260 | 260 | return true; |
| 261 | - } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo) / |
|
| 262 | - (10.0 * abs($sat->tle->xndt2o / (Predict::twopi / Predict::xmnpda / Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 261 | + } elseif ($sat->jul_epoch + ((16.666666 - $sat->meanmo)/ |
|
| 262 | + (10.0*abs($sat->tle->xndt2o/(Predict::twopi/Predict::xmnpda/Predict::xmnpda)))) < $sat->jul_utc) { |
|
| 263 | 263 | return true; |
| 264 | 264 | } else { |
| 265 | 265 | return false; |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | $observerGeo = new Predict_Geodetic(); |
| 299 | 299 | $observerGeo->lat = Predict_Math::Radians($qth->lat); |
| 300 | 300 | $observerGeo->lon = Predict_Math::Radians($qth->lon); |
| 301 | - $observerGeo->alt = $qth->alt * 1000; |
|
| 301 | + $observerGeo->alt = $qth->alt*1000; |
|
| 302 | 302 | |
| 303 | 303 | // Now determine the sun and observer positions |
| 304 | 304 | $observerPos = new Predict_Vector(); |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | $observerSatPos = new Predict_Vector(); |
| 312 | 312 | Predict_Math::Vec_Sub($this->pos, $observerPos, $observerSatPos); |
| 313 | 313 | $phaseAngle = Predict_Math::Degrees(Predict_Math::Angle($solarVector, $observerSatPos)); |
| 314 | - $illum = $phaseAngle / 180; |
|
| 314 | + $illum = $phaseAngle/180; |
|
| 315 | 315 | |
| 316 | - $illuminationChange = $illum / $imag['illum']; |
|
| 317 | - $inverseSquareOfDistanceChange = pow(($imag['distance'] / $this->range), 2); |
|
| 316 | + $illuminationChange = $illum/$imag['illum']; |
|
| 317 | + $inverseSquareOfDistanceChange = pow(($imag['distance']/$this->range), 2); |
|
| 318 | 318 | $changeInMagnitude = log( |
| 319 | - $illuminationChange * $inverseSquareOfDistanceChange, |
|
| 319 | + $illuminationChange*$inverseSquareOfDistanceChange, |
|
| 320 | 320 | self::POGSONS_RATIO |
| 321 | 321 | ); |
| 322 | 322 | |
@@ -146,8 +146,7 @@ |
||
| 146 | 146 | $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
| 147 | 147 | $obs_geodetic->alt = $qth->alt / 1000.0; |
| 148 | 148 | $obs_geodetic->theta = 0; |
| 149 | - } |
|
| 150 | - else { |
|
| 149 | + } else { |
|
| 151 | 150 | $obs_geodetic->lon = 0.0; |
| 152 | 151 | $obs_geodetic->lat = 0.0; |
| 153 | 152 | $obs_geodetic->alt = 0.0; |
@@ -56,6 +56,10 @@ |
||
| 56 | 56 | /* It is intended to be used to determine the ground track of */ |
| 57 | 57 | /* a satellite. The calculations assume the earth to be an */ |
| 58 | 58 | /* oblate spheroid as defined in WGS '72. */ |
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param double $_time |
|
| 62 | + */ |
|
| 59 | 63 | public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) |
| 60 | 64 | { |
| 61 | 65 | /* Reference: The 1992 Astronomical Almanac, page K12. */ |
@@ -25,131 +25,131 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class Predict_SGPObs |
| 27 | 27 | { |
| 28 | - /* Procedure Calculate_User_PosVel passes the user's geodetic position */ |
|
| 29 | - /* and the time of interest and returns the ECI position and velocity */ |
|
| 30 | - /* of the observer. The velocity calculation assumes the geodetic */ |
|
| 31 | - /* position is stationary relative to the earth's surface. */ |
|
| 32 | - public static function Calculate_User_PosVel( |
|
| 33 | - $_time, Predict_Geodetic $geodetic, Predict_Vector $obs_pos, Predict_Vector $obs_vel |
|
| 34 | - ) |
|
| 35 | - { |
|
| 36 | - /* Reference: The 1992 Astronomical Almanac, page K11. */ |
|
| 37 | - |
|
| 38 | - $sinGeodeticLat = sin($geodetic->lat); /* Only run sin($geodetic->lat) once */ |
|
| 39 | - |
|
| 40 | - $geodetic->theta = Predict_Math::FMod2p(Predict_Time::ThetaG_JD($_time) + $geodetic->lon);/*LMST*/ |
|
| 41 | - $c = 1 / sqrt(1 + Predict::__f * (Predict::__f - 2) * $sinGeodeticLat * $sinGeodeticLat); |
|
| 42 | - $sq = (1 - Predict::__f) * (1 - Predict::__f) * $c; |
|
| 43 | - $achcp = (Predict::xkmper * $c + $geodetic->alt) * cos($geodetic->lat); |
|
| 44 | - $obs_pos->x = $achcp * cos($geodetic->theta); /*kilometers*/ |
|
| 45 | - $obs_pos->y = $achcp * sin($geodetic->theta); |
|
| 46 | - $obs_pos->z = (Predict::xkmper * $sq + $geodetic->alt) * $sinGeodeticLat; |
|
| 47 | - $obs_vel->x = -Predict::mfactor * $obs_pos->y; /*kilometers/second*/ |
|
| 48 | - $obs_vel->y = Predict::mfactor * $obs_pos->x; |
|
| 49 | - $obs_vel->z = 0; |
|
| 50 | - $obs_pos->w = sqrt($obs_pos->x * $obs_pos->x + $obs_pos->y * $obs_pos->y + $obs_pos->z * $obs_pos->z); |
|
| 51 | - $obs_vel->w = sqrt($obs_vel->x * $obs_vel->x + $obs_vel->y * $obs_vel->y + $obs_vel->z * $obs_vel->z); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - /* Procedure Calculate_LatLonAlt will calculate the geodetic */ |
|
| 55 | - /* position of an object given its ECI position pos and time. */ |
|
| 56 | - /* It is intended to be used to determine the ground track of */ |
|
| 57 | - /* a satellite. The calculations assume the earth to be an */ |
|
| 58 | - /* oblate spheroid as defined in WGS '72. */ |
|
| 59 | - public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) |
|
| 60 | - { |
|
| 61 | - /* Reference: The 1992 Astronomical Almanac, page K12. */ |
|
| 62 | - |
|
| 63 | - /* double r,e2,phi,c; */ |
|
| 64 | - |
|
| 65 | - $geodetic->theta = Predict_Math::AcTan($pos->y, $pos->x); /*radians*/ |
|
| 66 | - $geodetic->lon = Predict_Math::FMod2p($geodetic->theta - Predict_Time::ThetaG_JD($_time)); /*radians*/ |
|
| 67 | - $r = sqrt(($pos->x * $pos->x) + ($pos->y * $pos->y)); |
|
| 68 | - $e2 = Predict::__f * (2 - Predict::__f); |
|
| 69 | - $geodetic->lat = Predict_Math::AcTan($pos->z, $r); /*radians*/ |
|
| 70 | - |
|
| 71 | - do { |
|
| 72 | - $phi = $geodetic->lat; |
|
| 73 | - $sinPhi = sin($phi); |
|
| 74 | - $c = 1 / sqrt(1 - $e2 * ($sinPhi * $sinPhi)); |
|
| 75 | - $geodetic->lat = Predict_Math::AcTan($pos->z + Predict::xkmper * $c * $e2 * $sinPhi, $r); |
|
| 76 | - } while (abs($geodetic->lat - $phi) >= 1E-10); |
|
| 77 | - |
|
| 78 | - $geodetic->alt = $r / cos($geodetic->lat) - Predict::xkmper * $c;/*kilometers*/ |
|
| 79 | - |
|
| 80 | - if ($geodetic->lat > Predict::pio2) { |
|
| 81 | - $geodetic->lat -= Predict::twopi; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - /* The procedures Calculate_Obs and Calculate_RADec calculate */ |
|
| 86 | - /* the *topocentric* coordinates of the object with ECI position, */ |
|
| 87 | - /* {pos}, and velocity, {vel}, from location {geodetic} at {time}. */ |
|
| 88 | - /* The {obs_set} returned for Calculate_Obs consists of azimuth, */ |
|
| 89 | - /* elevation, range, and range rate (in that order) with units of */ |
|
| 90 | - /* radians, radians, kilometers, and kilometers/second, respectively. */ |
|
| 91 | - /* The WGS '72 geoid is used and the effect of atmospheric refraction */ |
|
| 92 | - /* (under standard temperature and pressure) is incorporated into the */ |
|
| 93 | - /* elevation calculation; the effect of atmospheric refraction on */ |
|
| 94 | - /* range and range rate has not yet been quantified. */ |
|
| 95 | - |
|
| 96 | - /* The {obs_set} for Calculate_RADec consists of right ascension and */ |
|
| 97 | - /* declination (in that order) in radians. Again, calculations are */ |
|
| 98 | - /* based on *topocentric* position using the WGS '72 geoid and */ |
|
| 99 | - /* incorporating atmospheric refraction. */ |
|
| 100 | - public static function Calculate_Obs($_time, Predict_Vector $pos, Predict_Vector $vel, Predict_Geodetic $geodetic, Predict_ObsSet $obs_set) |
|
| 101 | - { |
|
| 102 | - $obs_pos = new Predict_Vector(); |
|
| 103 | - $obs_vel = new Predict_Vector(); |
|
| 104 | - $range = new Predict_Vector(); |
|
| 105 | - $rgvel = new Predict_Vector(); |
|
| 106 | - |
|
| 107 | - self::Calculate_User_PosVel($_time, $geodetic, $obs_pos, $obs_vel); |
|
| 108 | - |
|
| 109 | - $range->x = $pos->x - $obs_pos->x; |
|
| 110 | - $range->y = $pos->y - $obs_pos->y; |
|
| 111 | - $range->z = $pos->z - $obs_pos->z; |
|
| 112 | - |
|
| 113 | - $rgvel->x = $vel->x - $obs_vel->x; |
|
| 114 | - $rgvel->y = $vel->y - $obs_vel->y; |
|
| 115 | - $rgvel->z = $vel->z - $obs_vel->z; |
|
| 116 | - |
|
| 117 | - $range->w = sqrt($range->x * $range->x + $range->y * $range->y + $range->z * $range->z); |
|
| 118 | - |
|
| 119 | - $sin_lat = sin($geodetic->lat); |
|
| 120 | - $cos_lat = cos($geodetic->lat); |
|
| 121 | - $sin_theta = sin($geodetic->theta); |
|
| 122 | - $cos_theta = cos($geodetic->theta); |
|
| 123 | - $top_s = $sin_lat * $cos_theta * $range->x |
|
| 124 | - + $sin_lat * $sin_theta * $range->y |
|
| 125 | - - $cos_lat * $range->z; |
|
| 126 | - $top_e = -$sin_theta * $range->x |
|
| 127 | - + $cos_theta * $range->y; |
|
| 128 | - $top_z = $cos_lat * $cos_theta * $range->x |
|
| 129 | - + $cos_lat * $sin_theta * $range->y |
|
| 130 | - + $sin_lat * $range->z; |
|
| 131 | - $azim = atan(-$top_e / $top_s); /*Azimuth*/ |
|
| 132 | - if ($top_s > 0) { |
|
| 133 | - $azim = $azim + Predict::pi; |
|
| 134 | - } |
|
| 135 | - if ($azim < 0 ) { |
|
| 136 | - $azim = $azim + Predict::twopi; |
|
| 137 | - } |
|
| 138 | - $el = Predict_Math::ArcSin($top_z / $range->w); |
|
| 139 | - $obs_set->az = $azim; /* Azimuth (radians) */ |
|
| 140 | - $obs_set->el = $el; /* Elevation (radians)*/ |
|
| 141 | - $obs_set->range = $range->w; /* Range (kilometers) */ |
|
| 142 | - |
|
| 143 | - /* Range Rate (kilometers/second)*/ |
|
| 144 | - $obs_set->range_rate = Predict_Math::Dot($range, $rgvel) / $range->w; |
|
| 145 | - |
|
| 146 | - /* Corrections for atmospheric refraction */ |
|
| 147 | - /* Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 */ |
|
| 148 | - /* Correction is meaningless when apparent elevation is below horizon */ |
|
| 149 | - // obs_set->el = obs_set->el + Radians((1.02/tan(Radians(Degrees(el)+ |
|
| 150 | - // 10.3/(Degrees(el)+5.11))))/60); |
|
| 151 | - if ($obs_set->el < 0) { |
|
| 152 | - $obs_set->el = $el; /*Reset to true elevation*/ |
|
| 153 | - } |
|
| 154 | - } |
|
| 28 | + /* Procedure Calculate_User_PosVel passes the user's geodetic position */ |
|
| 29 | + /* and the time of interest and returns the ECI position and velocity */ |
|
| 30 | + /* of the observer. The velocity calculation assumes the geodetic */ |
|
| 31 | + /* position is stationary relative to the earth's surface. */ |
|
| 32 | + public static function Calculate_User_PosVel( |
|
| 33 | + $_time, Predict_Geodetic $geodetic, Predict_Vector $obs_pos, Predict_Vector $obs_vel |
|
| 34 | + ) |
|
| 35 | + { |
|
| 36 | + /* Reference: The 1992 Astronomical Almanac, page K11. */ |
|
| 37 | + |
|
| 38 | + $sinGeodeticLat = sin($geodetic->lat); /* Only run sin($geodetic->lat) once */ |
|
| 39 | + |
|
| 40 | + $geodetic->theta = Predict_Math::FMod2p(Predict_Time::ThetaG_JD($_time) + $geodetic->lon);/*LMST*/ |
|
| 41 | + $c = 1 / sqrt(1 + Predict::__f * (Predict::__f - 2) * $sinGeodeticLat * $sinGeodeticLat); |
|
| 42 | + $sq = (1 - Predict::__f) * (1 - Predict::__f) * $c; |
|
| 43 | + $achcp = (Predict::xkmper * $c + $geodetic->alt) * cos($geodetic->lat); |
|
| 44 | + $obs_pos->x = $achcp * cos($geodetic->theta); /*kilometers*/ |
|
| 45 | + $obs_pos->y = $achcp * sin($geodetic->theta); |
|
| 46 | + $obs_pos->z = (Predict::xkmper * $sq + $geodetic->alt) * $sinGeodeticLat; |
|
| 47 | + $obs_vel->x = -Predict::mfactor * $obs_pos->y; /*kilometers/second*/ |
|
| 48 | + $obs_vel->y = Predict::mfactor * $obs_pos->x; |
|
| 49 | + $obs_vel->z = 0; |
|
| 50 | + $obs_pos->w = sqrt($obs_pos->x * $obs_pos->x + $obs_pos->y * $obs_pos->y + $obs_pos->z * $obs_pos->z); |
|
| 51 | + $obs_vel->w = sqrt($obs_vel->x * $obs_vel->x + $obs_vel->y * $obs_vel->y + $obs_vel->z * $obs_vel->z); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + /* Procedure Calculate_LatLonAlt will calculate the geodetic */ |
|
| 55 | + /* position of an object given its ECI position pos and time. */ |
|
| 56 | + /* It is intended to be used to determine the ground track of */ |
|
| 57 | + /* a satellite. The calculations assume the earth to be an */ |
|
| 58 | + /* oblate spheroid as defined in WGS '72. */ |
|
| 59 | + public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) |
|
| 60 | + { |
|
| 61 | + /* Reference: The 1992 Astronomical Almanac, page K12. */ |
|
| 62 | + |
|
| 63 | + /* double r,e2,phi,c; */ |
|
| 64 | + |
|
| 65 | + $geodetic->theta = Predict_Math::AcTan($pos->y, $pos->x); /*radians*/ |
|
| 66 | + $geodetic->lon = Predict_Math::FMod2p($geodetic->theta - Predict_Time::ThetaG_JD($_time)); /*radians*/ |
|
| 67 | + $r = sqrt(($pos->x * $pos->x) + ($pos->y * $pos->y)); |
|
| 68 | + $e2 = Predict::__f * (2 - Predict::__f); |
|
| 69 | + $geodetic->lat = Predict_Math::AcTan($pos->z, $r); /*radians*/ |
|
| 70 | + |
|
| 71 | + do { |
|
| 72 | + $phi = $geodetic->lat; |
|
| 73 | + $sinPhi = sin($phi); |
|
| 74 | + $c = 1 / sqrt(1 - $e2 * ($sinPhi * $sinPhi)); |
|
| 75 | + $geodetic->lat = Predict_Math::AcTan($pos->z + Predict::xkmper * $c * $e2 * $sinPhi, $r); |
|
| 76 | + } while (abs($geodetic->lat - $phi) >= 1E-10); |
|
| 77 | + |
|
| 78 | + $geodetic->alt = $r / cos($geodetic->lat) - Predict::xkmper * $c;/*kilometers*/ |
|
| 79 | + |
|
| 80 | + if ($geodetic->lat > Predict::pio2) { |
|
| 81 | + $geodetic->lat -= Predict::twopi; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + /* The procedures Calculate_Obs and Calculate_RADec calculate */ |
|
| 86 | + /* the *topocentric* coordinates of the object with ECI position, */ |
|
| 87 | + /* {pos}, and velocity, {vel}, from location {geodetic} at {time}. */ |
|
| 88 | + /* The {obs_set} returned for Calculate_Obs consists of azimuth, */ |
|
| 89 | + /* elevation, range, and range rate (in that order) with units of */ |
|
| 90 | + /* radians, radians, kilometers, and kilometers/second, respectively. */ |
|
| 91 | + /* The WGS '72 geoid is used and the effect of atmospheric refraction */ |
|
| 92 | + /* (under standard temperature and pressure) is incorporated into the */ |
|
| 93 | + /* elevation calculation; the effect of atmospheric refraction on */ |
|
| 94 | + /* range and range rate has not yet been quantified. */ |
|
| 95 | + |
|
| 96 | + /* The {obs_set} for Calculate_RADec consists of right ascension and */ |
|
| 97 | + /* declination (in that order) in radians. Again, calculations are */ |
|
| 98 | + /* based on *topocentric* position using the WGS '72 geoid and */ |
|
| 99 | + /* incorporating atmospheric refraction. */ |
|
| 100 | + public static function Calculate_Obs($_time, Predict_Vector $pos, Predict_Vector $vel, Predict_Geodetic $geodetic, Predict_ObsSet $obs_set) |
|
| 101 | + { |
|
| 102 | + $obs_pos = new Predict_Vector(); |
|
| 103 | + $obs_vel = new Predict_Vector(); |
|
| 104 | + $range = new Predict_Vector(); |
|
| 105 | + $rgvel = new Predict_Vector(); |
|
| 106 | + |
|
| 107 | + self::Calculate_User_PosVel($_time, $geodetic, $obs_pos, $obs_vel); |
|
| 108 | + |
|
| 109 | + $range->x = $pos->x - $obs_pos->x; |
|
| 110 | + $range->y = $pos->y - $obs_pos->y; |
|
| 111 | + $range->z = $pos->z - $obs_pos->z; |
|
| 112 | + |
|
| 113 | + $rgvel->x = $vel->x - $obs_vel->x; |
|
| 114 | + $rgvel->y = $vel->y - $obs_vel->y; |
|
| 115 | + $rgvel->z = $vel->z - $obs_vel->z; |
|
| 116 | + |
|
| 117 | + $range->w = sqrt($range->x * $range->x + $range->y * $range->y + $range->z * $range->z); |
|
| 118 | + |
|
| 119 | + $sin_lat = sin($geodetic->lat); |
|
| 120 | + $cos_lat = cos($geodetic->lat); |
|
| 121 | + $sin_theta = sin($geodetic->theta); |
|
| 122 | + $cos_theta = cos($geodetic->theta); |
|
| 123 | + $top_s = $sin_lat * $cos_theta * $range->x |
|
| 124 | + + $sin_lat * $sin_theta * $range->y |
|
| 125 | + - $cos_lat * $range->z; |
|
| 126 | + $top_e = -$sin_theta * $range->x |
|
| 127 | + + $cos_theta * $range->y; |
|
| 128 | + $top_z = $cos_lat * $cos_theta * $range->x |
|
| 129 | + + $cos_lat * $sin_theta * $range->y |
|
| 130 | + + $sin_lat * $range->z; |
|
| 131 | + $azim = atan(-$top_e / $top_s); /*Azimuth*/ |
|
| 132 | + if ($top_s > 0) { |
|
| 133 | + $azim = $azim + Predict::pi; |
|
| 134 | + } |
|
| 135 | + if ($azim < 0 ) { |
|
| 136 | + $azim = $azim + Predict::twopi; |
|
| 137 | + } |
|
| 138 | + $el = Predict_Math::ArcSin($top_z / $range->w); |
|
| 139 | + $obs_set->az = $azim; /* Azimuth (radians) */ |
|
| 140 | + $obs_set->el = $el; /* Elevation (radians)*/ |
|
| 141 | + $obs_set->range = $range->w; /* Range (kilometers) */ |
|
| 142 | + |
|
| 143 | + /* Range Rate (kilometers/second)*/ |
|
| 144 | + $obs_set->range_rate = Predict_Math::Dot($range, $rgvel) / $range->w; |
|
| 145 | + |
|
| 146 | + /* Corrections for atmospheric refraction */ |
|
| 147 | + /* Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 */ |
|
| 148 | + /* Correction is meaningless when apparent elevation is below horizon */ |
|
| 149 | + // obs_set->el = obs_set->el + Radians((1.02/tan(Radians(Degrees(el)+ |
|
| 150 | + // 10.3/(Degrees(el)+5.11))))/60); |
|
| 151 | + if ($obs_set->el < 0) { |
|
| 152 | + $obs_set->el = $el; /*Reset to true elevation*/ |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | } |
@@ -37,18 +37,18 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $sinGeodeticLat = sin($geodetic->lat); /* Only run sin($geodetic->lat) once */ |
| 39 | 39 | |
| 40 | - $geodetic->theta = Predict_Math::FMod2p(Predict_Time::ThetaG_JD($_time) + $geodetic->lon);/*LMST*/ |
|
| 41 | - $c = 1 / sqrt(1 + Predict::__f * (Predict::__f - 2) * $sinGeodeticLat * $sinGeodeticLat); |
|
| 42 | - $sq = (1 - Predict::__f) * (1 - Predict::__f) * $c; |
|
| 43 | - $achcp = (Predict::xkmper * $c + $geodetic->alt) * cos($geodetic->lat); |
|
| 44 | - $obs_pos->x = $achcp * cos($geodetic->theta); /*kilometers*/ |
|
| 45 | - $obs_pos->y = $achcp * sin($geodetic->theta); |
|
| 46 | - $obs_pos->z = (Predict::xkmper * $sq + $geodetic->alt) * $sinGeodeticLat; |
|
| 47 | - $obs_vel->x = -Predict::mfactor * $obs_pos->y; /*kilometers/second*/ |
|
| 48 | - $obs_vel->y = Predict::mfactor * $obs_pos->x; |
|
| 49 | - $obs_vel->z = 0; |
|
| 50 | - $obs_pos->w = sqrt($obs_pos->x * $obs_pos->x + $obs_pos->y * $obs_pos->y + $obs_pos->z * $obs_pos->z); |
|
| 51 | - $obs_vel->w = sqrt($obs_vel->x * $obs_vel->x + $obs_vel->y * $obs_vel->y + $obs_vel->z * $obs_vel->z); |
|
| 40 | + $geodetic->theta = Predict_Math::FMod2p(Predict_Time::ThetaG_JD($_time) + $geodetic->lon); /*LMST*/ |
|
| 41 | + $c = 1/sqrt(1 + Predict::__f*(Predict::__f - 2)*$sinGeodeticLat*$sinGeodeticLat); |
|
| 42 | + $sq = (1 - Predict::__f)*(1 - Predict::__f)*$c; |
|
| 43 | + $achcp = (Predict::xkmper*$c + $geodetic->alt)*cos($geodetic->lat); |
|
| 44 | + $obs_pos->x = $achcp*cos($geodetic->theta); /*kilometers*/ |
|
| 45 | + $obs_pos->y = $achcp*sin($geodetic->theta); |
|
| 46 | + $obs_pos->z = (Predict::xkmper*$sq + $geodetic->alt)*$sinGeodeticLat; |
|
| 47 | + $obs_vel->x = -Predict::mfactor*$obs_pos->y; /*kilometers/second*/ |
|
| 48 | + $obs_vel->y = Predict::mfactor*$obs_pos->x; |
|
| 49 | + $obs_vel->z = 0; |
|
| 50 | + $obs_pos->w = sqrt($obs_pos->x*$obs_pos->x + $obs_pos->y*$obs_pos->y + $obs_pos->z*$obs_pos->z); |
|
| 51 | + $obs_vel->w = sqrt($obs_vel->x*$obs_vel->x + $obs_vel->y*$obs_vel->y + $obs_vel->z*$obs_vel->z); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /* Procedure Calculate_LatLonAlt will calculate the geodetic */ |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /* It is intended to be used to determine the ground track of */ |
| 57 | 57 | /* a satellite. The calculations assume the earth to be an */ |
| 58 | 58 | /* oblate spheroid as defined in WGS '72. */ |
| 59 | - public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) |
|
| 59 | + public static function Calculate_LatLonAlt($_time, Predict_Vector $pos, Predict_Geodetic $geodetic) |
|
| 60 | 60 | { |
| 61 | 61 | /* Reference: The 1992 Astronomical Almanac, page K12. */ |
| 62 | 62 | |
@@ -64,18 +64,18 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $geodetic->theta = Predict_Math::AcTan($pos->y, $pos->x); /*radians*/ |
| 66 | 66 | $geodetic->lon = Predict_Math::FMod2p($geodetic->theta - Predict_Time::ThetaG_JD($_time)); /*radians*/ |
| 67 | - $r = sqrt(($pos->x * $pos->x) + ($pos->y * $pos->y)); |
|
| 68 | - $e2 = Predict::__f * (2 - Predict::__f); |
|
| 67 | + $r = sqrt(($pos->x*$pos->x) + ($pos->y*$pos->y)); |
|
| 68 | + $e2 = Predict::__f*(2 - Predict::__f); |
|
| 69 | 69 | $geodetic->lat = Predict_Math::AcTan($pos->z, $r); /*radians*/ |
| 70 | 70 | |
| 71 | 71 | do { |
| 72 | 72 | $phi = $geodetic->lat; |
| 73 | 73 | $sinPhi = sin($phi); |
| 74 | - $c = 1 / sqrt(1 - $e2 * ($sinPhi * $sinPhi)); |
|
| 75 | - $geodetic->lat = Predict_Math::AcTan($pos->z + Predict::xkmper * $c * $e2 * $sinPhi, $r); |
|
| 74 | + $c = 1/sqrt(1 - $e2*($sinPhi*$sinPhi)); |
|
| 75 | + $geodetic->lat = Predict_Math::AcTan($pos->z + Predict::xkmper*$c*$e2*$sinPhi, $r); |
|
| 76 | 76 | } while (abs($geodetic->lat - $phi) >= 1E-10); |
| 77 | 77 | |
| 78 | - $geodetic->alt = $r / cos($geodetic->lat) - Predict::xkmper * $c;/*kilometers*/ |
|
| 78 | + $geodetic->alt = $r/cos($geodetic->lat) - Predict::xkmper*$c; /*kilometers*/ |
|
| 79 | 79 | |
| 80 | 80 | if ($geodetic->lat > Predict::pio2) { |
| 81 | 81 | $geodetic->lat -= Predict::twopi; |
@@ -114,34 +114,34 @@ discard block |
||
| 114 | 114 | $rgvel->y = $vel->y - $obs_vel->y; |
| 115 | 115 | $rgvel->z = $vel->z - $obs_vel->z; |
| 116 | 116 | |
| 117 | - $range->w = sqrt($range->x * $range->x + $range->y * $range->y + $range->z * $range->z); |
|
| 117 | + $range->w = sqrt($range->x*$range->x + $range->y*$range->y + $range->z*$range->z); |
|
| 118 | 118 | |
| 119 | 119 | $sin_lat = sin($geodetic->lat); |
| 120 | 120 | $cos_lat = cos($geodetic->lat); |
| 121 | 121 | $sin_theta = sin($geodetic->theta); |
| 122 | 122 | $cos_theta = cos($geodetic->theta); |
| 123 | - $top_s = $sin_lat * $cos_theta * $range->x |
|
| 124 | - + $sin_lat * $sin_theta * $range->y |
|
| 125 | - - $cos_lat * $range->z; |
|
| 126 | - $top_e = -$sin_theta * $range->x |
|
| 127 | - + $cos_theta * $range->y; |
|
| 128 | - $top_z = $cos_lat * $cos_theta * $range->x |
|
| 129 | - + $cos_lat * $sin_theta * $range->y |
|
| 130 | - + $sin_lat * $range->z; |
|
| 131 | - $azim = atan(-$top_e / $top_s); /*Azimuth*/ |
|
| 123 | + $top_s = $sin_lat*$cos_theta*$range->x |
|
| 124 | + + $sin_lat*$sin_theta*$range->y |
|
| 125 | + - $cos_lat*$range->z; |
|
| 126 | + $top_e = -$sin_theta*$range->x |
|
| 127 | + + $cos_theta*$range->y; |
|
| 128 | + $top_z = $cos_lat*$cos_theta*$range->x |
|
| 129 | + + $cos_lat*$sin_theta*$range->y |
|
| 130 | + + $sin_lat*$range->z; |
|
| 131 | + $azim = atan(-$top_e/$top_s); /*Azimuth*/ |
|
| 132 | 132 | if ($top_s > 0) { |
| 133 | 133 | $azim = $azim + Predict::pi; |
| 134 | 134 | } |
| 135 | - if ($azim < 0 ) { |
|
| 135 | + if ($azim < 0) { |
|
| 136 | 136 | $azim = $azim + Predict::twopi; |
| 137 | 137 | } |
| 138 | - $el = Predict_Math::ArcSin($top_z / $range->w); |
|
| 139 | - $obs_set->az = $azim; /* Azimuth (radians) */ |
|
| 140 | - $obs_set->el = $el; /* Elevation (radians)*/ |
|
| 138 | + $el = Predict_Math::ArcSin($top_z/$range->w); |
|
| 139 | + $obs_set->az = $azim; /* Azimuth (radians) */ |
|
| 140 | + $obs_set->el = $el; /* Elevation (radians)*/ |
|
| 141 | 141 | $obs_set->range = $range->w; /* Range (kilometers) */ |
| 142 | 142 | |
| 143 | 143 | /* Range Rate (kilometers/second)*/ |
| 144 | - $obs_set->range_rate = Predict_Math::Dot($range, $rgvel) / $range->w; |
|
| 144 | + $obs_set->range_rate = Predict_Math::Dot($range, $rgvel)/$range->w; |
|
| 145 | 145 | |
| 146 | 146 | /* Corrections for atmospheric refraction */ |
| 147 | 147 | /* Reference: Astronomical Algorithms by Jean Meeus, pp. 101-104 */ |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | // obs_set->el = obs_set->el + Radians((1.02/tan(Radians(Degrees(el)+ |
| 150 | 150 | // 10.3/(Degrees(el)+5.11))))/60); |
| 151 | 151 | if ($obs_set->el < 0) { |
| 152 | - $obs_set->el = $el; /*Reset to true elevation*/ |
|
| 152 | + $obs_set->el = $el; /*Reset to true elevation*/ |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | } |
@@ -67,6 +67,10 @@ discard block |
||
| 67 | 67 | /* structure with Keplerian orbital elements and pos and vel */ |
| 68 | 68 | /* are vector_t structures returning ECI satellite position and */ |
| 69 | 69 | /* velocity. Use Convert_Sat_State() to convert to km and km/s.*/ |
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param double $tsince |
|
| 73 | + */ |
|
| 70 | 74 | public function SGP4(Predict_Sat $sat, $tsince) |
| 71 | 75 | { |
| 72 | 76 | /* Initialization */ |
@@ -312,6 +316,10 @@ discard block |
||
| 312 | 316 | /* structure with Keplerian orbital elements and pos and vel */ |
| 313 | 317 | /* are vector_t structures returning ECI satellite position and */ |
| 314 | 318 | /* velocity. Use Convert_Sat_State() to convert to km and km/s. */ |
| 319 | + |
|
| 320 | + /** |
|
| 321 | + * @param double $tsince |
|
| 322 | + */ |
|
| 315 | 323 | public function SDP4(Predict_Sat $sat, $tsince) |
| 316 | 324 | { |
| 317 | 325 | /* Initialization */ |
@@ -538,6 +546,10 @@ discard block |
||
| 538 | 546 | /* DEEP */ |
| 539 | 547 | /* This function is used by SDP4 to add lunar and solar */ |
| 540 | 548 | /* perturbation effects to deep-space orbit objects. */ |
| 549 | + |
|
| 550 | + /** |
|
| 551 | + * @param integer $ientry |
|
| 552 | + */ |
|
| 541 | 553 | public function Deep($ientry, Predict_Sat $sat) |
| 542 | 554 | { |
| 543 | 555 | switch ($ientry) { |
@@ -23,1037 +23,1037 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Predict_SGPSDP |
| 25 | 25 | { |
| 26 | - const ALL_FLAGS = -1; |
|
| 27 | - const SGP_INITIALIZED_FLAG = 0x000001; |
|
| 28 | - const SGP4_INITIALIZED_FLAG = 0x000002; |
|
| 29 | - const SDP4_INITIALIZED_FLAG = 0x000004; |
|
| 30 | - const SGP8_INITIALIZED_FLAG = 0x000008; |
|
| 31 | - const SDP8_INITIALIZED_FLAG = 0x000010; |
|
| 32 | - const SIMPLE_FLAG = 0x000020; |
|
| 33 | - const DEEP_SPACE_EPHEM_FLAG = 0x000040; |
|
| 34 | - const LUNAR_TERMS_DONE_FLAG = 0x000080; |
|
| 35 | - const NEW_EPHEMERIS_FLAG = 0x000100; |
|
| 36 | - const DO_LOOP_FLAG = 0x000200; |
|
| 37 | - const RESONANCE_FLAG = 0x000400; |
|
| 38 | - const SYNCHRONOUS_FLAG = 0x000800; |
|
| 39 | - const EPOCH_RESTART_FLAG = 0x001000; |
|
| 40 | - const VISIBLE_FLAG = 0x002000; |
|
| 41 | - const SAT_ECLIPSED_FLAG = 0x004000; |
|
| 42 | - |
|
| 43 | - /* orbit_type_t struct */ |
|
| 44 | - const ORBIT_TYPE_UNKNOWN = 0; |
|
| 45 | - const ORBIT_TYPE_LEO = 1; /*!< Low Earth orbit, up to 1200 km. */ |
|
| 46 | - const ORBIT_TYPE_ICO = 2; /*!< Intermediate Circular Orbit, up to 1400 km. */ |
|
| 47 | - const ORBIT_TYPE_GEO = 3; /*!< Geostationary. */ |
|
| 48 | - const ORBIT_TYPE_GSO = 4; /*!< Geosynchronuous. */ |
|
| 49 | - const ORBIT_TYPE_MOLNIYA = 5; |
|
| 50 | - const ORBIT_TYPE_TUNDRA = 6; |
|
| 51 | - const ORBIT_TYPE_POLAR = 7; |
|
| 52 | - const ORBIT_TYPE_SUNSYNC = 8; |
|
| 53 | - const ORBIT_TYPE_DECAYED = 9; |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /* Entry points of Deep() |
|
| 26 | + const ALL_FLAGS = -1; |
|
| 27 | + const SGP_INITIALIZED_FLAG = 0x000001; |
|
| 28 | + const SGP4_INITIALIZED_FLAG = 0x000002; |
|
| 29 | + const SDP4_INITIALIZED_FLAG = 0x000004; |
|
| 30 | + const SGP8_INITIALIZED_FLAG = 0x000008; |
|
| 31 | + const SDP8_INITIALIZED_FLAG = 0x000010; |
|
| 32 | + const SIMPLE_FLAG = 0x000020; |
|
| 33 | + const DEEP_SPACE_EPHEM_FLAG = 0x000040; |
|
| 34 | + const LUNAR_TERMS_DONE_FLAG = 0x000080; |
|
| 35 | + const NEW_EPHEMERIS_FLAG = 0x000100; |
|
| 36 | + const DO_LOOP_FLAG = 0x000200; |
|
| 37 | + const RESONANCE_FLAG = 0x000400; |
|
| 38 | + const SYNCHRONOUS_FLAG = 0x000800; |
|
| 39 | + const EPOCH_RESTART_FLAG = 0x001000; |
|
| 40 | + const VISIBLE_FLAG = 0x002000; |
|
| 41 | + const SAT_ECLIPSED_FLAG = 0x004000; |
|
| 42 | + |
|
| 43 | + /* orbit_type_t struct */ |
|
| 44 | + const ORBIT_TYPE_UNKNOWN = 0; |
|
| 45 | + const ORBIT_TYPE_LEO = 1; /*!< Low Earth orbit, up to 1200 km. */ |
|
| 46 | + const ORBIT_TYPE_ICO = 2; /*!< Intermediate Circular Orbit, up to 1400 km. */ |
|
| 47 | + const ORBIT_TYPE_GEO = 3; /*!< Geostationary. */ |
|
| 48 | + const ORBIT_TYPE_GSO = 4; /*!< Geosynchronuous. */ |
|
| 49 | + const ORBIT_TYPE_MOLNIYA = 5; |
|
| 50 | + const ORBIT_TYPE_TUNDRA = 6; |
|
| 51 | + const ORBIT_TYPE_POLAR = 7; |
|
| 52 | + const ORBIT_TYPE_SUNSYNC = 8; |
|
| 53 | + const ORBIT_TYPE_DECAYED = 9; |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /* Entry points of Deep() |
|
| 58 | 58 | // FIXME: Change to enu */ |
| 59 | - const dpinit = 1; /* Deep-space initialization code */ |
|
| 60 | - const dpsec = 2; /* Deep-space secular code */ |
|
| 61 | - const dpper = 3; /* Deep-space periodic code */ |
|
| 62 | - |
|
| 63 | - /* SGP4 */ |
|
| 64 | - /* This function is used to calculate the position and velocity */ |
|
| 65 | - /* of near-earth (period < 225 minutes) satellites. tsince is */ |
|
| 66 | - /* time since epoch in minutes, tle is a pointer to a tle_t */ |
|
| 67 | - /* structure with Keplerian orbital elements and pos and vel */ |
|
| 68 | - /* are vector_t structures returning ECI satellite position and */ |
|
| 69 | - /* velocity. Use Convert_Sat_State() to convert to km and km/s.*/ |
|
| 70 | - public function SGP4(Predict_Sat $sat, $tsince) |
|
| 71 | - { |
|
| 72 | - /* Initialization */ |
|
| 73 | - if (~$sat->flags & self::SGP4_INITIALIZED_FLAG) { |
|
| 74 | - $sat->flags |= self::SGP4_INITIALIZED_FLAG; |
|
| 75 | - |
|
| 76 | - /* Recover original mean motion (xnodp) and */ |
|
| 77 | - /* semimajor axis (aodp) from input elements. */ |
|
| 78 | - $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 79 | - $sat->sgps->cosio = cos($sat->tle->xincl); |
|
| 80 | - $theta2 = $sat->sgps->cosio * $sat->sgps->cosio; |
|
| 81 | - $sat->sgps->x3thm1 = 3 * $theta2 - 1.0; |
|
| 82 | - $eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 83 | - $betao2 = 1 - $eosq; |
|
| 84 | - $betao = sqrt($betao2); |
|
| 85 | - $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($a1 * $a1 * $betao * $betao2); |
|
| 86 | - $ao = $a1 * (1 - $del1 * (0.5 * Predict::tothrd + $del1 * (1 + 134.0 / 81.0 * $del1))); |
|
| 87 | - $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($ao * $ao * $betao * $betao2); |
|
| 88 | - $sat->sgps->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 89 | - $sat->sgps->aodp = $ao / (1.0 - $delo); |
|
| 90 | - |
|
| 91 | - /* For perigee less than 220 kilometers, the "simple" flag is set */ |
|
| 92 | - /* and the equations are truncated to linear variation in sqrt a */ |
|
| 93 | - /* and quadratic variation in mean anomaly. Also, the c3 term, */ |
|
| 94 | - /* the delta omega term, and the delta m term are dropped. */ |
|
| 95 | - if (($sat->sgps->aodp * (1.0 - $sat->tle->eo) / Predict::ae) < (220.0 / Predict::xkmper + Predict::ae)) { |
|
| 96 | - $sat->flags |= self::SIMPLE_FLAG; |
|
| 97 | - } else { |
|
| 98 | - $sat->flags &= ~self::SIMPLE_FLAG; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - /* For perigee below 156 km, the */ |
|
| 102 | - /* values of s and qoms2t are altered. */ |
|
| 103 | - $s4 = Predict::__s__; |
|
| 104 | - $qoms24 = Predict::qoms2t; |
|
| 105 | - $perige = ($sat->sgps->aodp * (1 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 106 | - if ($perige < 156.0) { |
|
| 107 | - if ($perige <= 98.0) { |
|
| 108 | - $s4 = 20.0; |
|
| 109 | - } else { |
|
| 110 | - $s4 = $perige - 78.0; |
|
| 111 | - } |
|
| 112 | - $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 113 | - $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 114 | - }; /* FIXME FIXME: End of if(perige <= 98) NO WAY!!!! */ |
|
| 115 | - |
|
| 116 | - $pinvsq = 1.0 / ($sat->sgps->aodp * $sat->sgps->aodp * $betao2 * $betao2); |
|
| 117 | - $tsi = 1.0 / ($sat->sgps->aodp - $s4); |
|
| 118 | - $sat->sgps->eta = $sat->sgps->aodp * $sat->tle->eo * $tsi; |
|
| 119 | - $etasq = $sat->sgps->eta * $sat->sgps->eta; |
|
| 120 | - $eeta = $sat->tle->eo * $sat->sgps->eta; |
|
| 121 | - $psisq = abs(1.0 - $etasq); |
|
| 122 | - $coef = $qoms24 * pow($tsi, 4); |
|
| 123 | - $coef1 = $coef / pow($psisq, 3.5); |
|
| 124 | - $c2 = $coef1 * $sat->sgps->xnodp * ($sat->sgps->aodp * |
|
| 125 | - (1.0 + 1.5 * $etasq + $eeta * (4.0 + $etasq)) + |
|
| 126 | - 0.75 * Predict::ck2 * $tsi / $psisq * $sat->sgps->x3thm1 * |
|
| 127 | - (8.0 + 3.0 * $etasq * (8 + $etasq))); |
|
| 128 | - $sat->sgps->c1 = $c2 * $sat->tle->bstar; |
|
| 129 | - $sat->sgps->sinio = sin($sat->tle->xincl); |
|
| 130 | - $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 131 | - $c3 = $coef * $tsi * $a3ovk2 * $sat->sgps->xnodp * Predict::ae * $sat->sgps->sinio / $sat->tle->eo; |
|
| 132 | - $sat->sgps->x1mth2 = 1.0 - $theta2; |
|
| 133 | - $sat->sgps->c4 = 2.0 * $sat->sgps->xnodp * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 134 | - ($sat->sgps->eta * (2.0 + 0.5 * $etasq) + |
|
| 135 | - $sat->tle->eo * (0.5 + 2.0 * $etasq) - |
|
| 136 | - 2.0 * Predict::ck2 * $tsi / ($sat->sgps->aodp * $psisq) * |
|
| 137 | - (-3.0 * $sat->sgps->x3thm1 * (1.0 - 2.0 * $eeta + $etasq * (1.5 - 0.5 * $eeta)) + |
|
| 138 | - 0.75 * $sat->sgps->x1mth2 * (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 139 | - cos(2.0 * $sat->tle->omegao))); |
|
| 140 | - $sat->sgps->c5 = 2.0 * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 141 | - (1.0 + 2.75 * ($etasq + $eeta) + $eeta * $etasq); |
|
| 142 | - $theta4 = $theta2 * $theta2; |
|
| 143 | - $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->sgps->xnodp; |
|
| 144 | - $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 145 | - $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->sgps->xnodp; |
|
| 146 | - $sat->sgps->xmdot = $sat->sgps->xnodp + 0.5 * $temp1 * $betao * $sat->sgps->x3thm1 + |
|
| 147 | - 0.0625 * $temp2 * $betao * (13.0 - 78.0 * $theta2 + 137.0 * $theta4); |
|
| 148 | - $x1m5th = 1.0 - 5.0 * $theta2; |
|
| 149 | - $sat->sgps->omgdot = -0.5 * $temp1 * $x1m5th + |
|
| 150 | - 0.0625 * $temp2 * (7.0 - 114.0 * $theta2 + 395.0 * $theta4) + |
|
| 151 | - $temp3 * (3.0 - 36.0 * $theta2 + 49.0 * $theta4); |
|
| 152 | - $xhdot1 = -$temp1 * $sat->sgps->cosio; |
|
| 153 | - $sat->sgps->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $theta2) + |
|
| 154 | - 2.0 * $temp3 * (3.0 - 7.0 * $theta2)) * $sat->sgps->cosio; |
|
| 155 | - $sat->sgps->omgcof = $sat->tle->bstar * $c3 * cos($sat->tle->omegao); |
|
| 156 | - $sat->sgps->xmcof = -Predict::tothrd * $coef * $sat->tle->bstar * Predict::ae / $eeta; |
|
| 157 | - $sat->sgps->xnodcf = 3.5 * $betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 158 | - $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 159 | - $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->sgps->sinio * |
|
| 160 | - (3.0 + 5.0 * $sat->sgps->cosio) / (1.0 + $sat->sgps->cosio); |
|
| 161 | - $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->sgps->sinio; |
|
| 162 | - $sat->sgps->delmo = pow(1.0 + $sat->sgps->eta * cos($sat->tle->xmo), 3); |
|
| 163 | - $sat->sgps->sinmo = sin($sat->tle->xmo); |
|
| 164 | - $sat->sgps->x7thm1 = 7.0 * $theta2 - 1.0; |
|
| 165 | - if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 166 | - $c1sq = $sat->sgps->c1 * $sat->sgps->c1; |
|
| 167 | - $sat->sgps->d2 = 4.0 * $sat->sgps->aodp * $tsi * $c1sq; |
|
| 168 | - $temp = $sat->sgps->d2 * $tsi * $sat->sgps->c1 / 3.0; |
|
| 169 | - $sat->sgps->d3 = (17.0 * $sat->sgps->aodp + $s4) * $temp; |
|
| 170 | - $sat->sgps->d4 = 0.5 * $temp * $sat->sgps->aodp * $tsi * |
|
| 171 | - (221.0 * $sat->sgps->aodp + 31.0 * $s4) * $sat->sgps->c1; |
|
| 172 | - $sat->sgps->t3cof = $sat->sgps->d2 + 2.0 * $c1sq; |
|
| 173 | - $sat->sgps->t4cof = 0.25 * (3.0 * $sat->sgps->d3 + $sat->sgps->c1 * |
|
| 174 | - (12.0 * $sat->sgps->d2 + 10.0 * $c1sq)); |
|
| 175 | - $sat->sgps->t5cof = 0.2 * (3.0 * $sat->sgps->d4 + |
|
| 176 | - 12.0 * $sat->sgps->c1 * $sat->sgps->d3 + |
|
| 177 | - 6.0 * $sat->sgps->d2 * $sat->sgps->d2 + |
|
| 178 | - 15.0 * $c1sq * (2.0 * $sat->sgps->d2 + $c1sq)); |
|
| 179 | - }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
|
| 180 | - }; /* End of SGP4() initialization */ |
|
| 181 | - |
|
| 182 | - /* Update for secular gravity and atmospheric drag. */ |
|
| 183 | - $xmdf = $sat->tle->xmo + $sat->sgps->xmdot * $tsince; |
|
| 184 | - $omgadf = $sat->tle->omegao + $sat->sgps->omgdot * $tsince; |
|
| 185 | - $xnoddf = $sat->tle->xnodeo + $sat->sgps->xnodot * $tsince; |
|
| 186 | - $omega = $omgadf; |
|
| 187 | - $xmp = $xmdf; |
|
| 188 | - $tsq = $tsince * $tsince; |
|
| 189 | - $xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 190 | - $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 191 | - $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 192 | - $templ = $sat->sgps->t2cof * $tsq; |
|
| 193 | - if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 194 | - $delomg = $sat->sgps->omgcof * $tsince; |
|
| 195 | - $delm = $sat->sgps->xmcof * (pow(1 + $sat->sgps->eta * cos($xmdf), 3) - $sat->sgps->delmo); |
|
| 196 | - $temp = $delomg + $delm; |
|
| 197 | - $xmp = $xmdf + $temp; |
|
| 198 | - $omega = $omgadf - $temp; |
|
| 199 | - $tcube = $tsq * $tsince; |
|
| 200 | - $tfour = $tsince * $tcube; |
|
| 201 | - $tempa = $tempa - $sat->sgps->d2 * $tsq - $sat->sgps->d3 * $tcube - $sat->sgps->d4 * $tfour; |
|
| 202 | - $tempe = $tempe + $sat->tle->bstar * $sat->sgps->c5 * (sin($xmp) - $sat->sgps->sinmo); |
|
| 203 | - $templ = $templ + $sat->sgps->t3cof * $tcube + $tfour * |
|
| 204 | - ($sat->sgps->t4cof + $tsince * $sat->sgps->t5cof); |
|
| 205 | - }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
|
| 206 | - |
|
| 207 | - $a = $sat->sgps->aodp * pow($tempa, 2); |
|
| 208 | - $e = $sat->tle->eo - $tempe; |
|
| 209 | - $xl = $xmp + $omega + $xnode + $sat->sgps->xnodp * $templ; |
|
| 210 | - $beta = sqrt(1.0 - ($e * $e)); |
|
| 211 | - $xn = Predict::xke / pow($a, 1.5); |
|
| 212 | - |
|
| 213 | - /* Long period periodics */ |
|
| 214 | - $axn = $e * cos($omega); |
|
| 215 | - $temp = 1.0 / ($a * $beta * $beta); |
|
| 216 | - $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 217 | - $aynl = $temp * $sat->sgps->aycof; |
|
| 218 | - $xlt = $xl + $xll; |
|
| 219 | - $ayn = $e * sin($omega) + $aynl; |
|
| 220 | - |
|
| 221 | - /* Solve Kepler's' Equation */ |
|
| 222 | - $capu = Predict_Math::FMod2p($xlt - $xnode); |
|
| 223 | - $temp2 = $capu; |
|
| 224 | - |
|
| 225 | - $i = 0; |
|
| 226 | - do { |
|
| 227 | - $sinepw = sin($temp2); |
|
| 228 | - $cosepw = cos($temp2); |
|
| 229 | - $temp3 = $axn * $sinepw; |
|
| 230 | - $temp4 = $ayn * $cosepw; |
|
| 231 | - $temp5 = $axn * $cosepw; |
|
| 232 | - $temp6 = $ayn * $sinepw; |
|
| 233 | - $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 234 | - if (abs($epw - $temp2) <= Predict::e6a) { |
|
| 235 | - break; |
|
| 236 | - } |
|
| 237 | - $temp2 = $epw; |
|
| 238 | - } while ($i++ < 10); |
|
| 239 | - |
|
| 240 | - /* Short period preliminary quantities */ |
|
| 241 | - $ecose = $temp5 + $temp6; |
|
| 242 | - $esine = $temp3 - $temp4; |
|
| 243 | - $elsq = $axn * $axn + $ayn * $ayn; |
|
| 244 | - $temp = 1.0 - $elsq; |
|
| 245 | - $pl = $a * $temp; |
|
| 246 | - $r = $a * (1.0 - $ecose); |
|
| 247 | - $temp1 = 1.0 / $r; |
|
| 248 | - $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 249 | - $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 250 | - $temp2 = $a * $temp1; |
|
| 251 | - $betal = sqrt($temp); |
|
| 252 | - $temp3 = 1.0 / (1.0 + $betal); |
|
| 253 | - $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 254 | - $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 255 | - $u = Predict_Math::AcTan($sinu, $cosu); |
|
| 256 | - $sin2u = 2.0 * $sinu * $cosu; |
|
| 257 | - $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 258 | - $temp = 1.0 / $pl; |
|
| 259 | - $temp1 = Predict::ck2 * $temp; |
|
| 260 | - $temp2 = $temp1 * $temp; |
|
| 261 | - |
|
| 262 | - /* Update for short periodics */ |
|
| 263 | - $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 264 | - 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 265 | - $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 266 | - $xnodek = $xnode + 1.5 * $temp2 * $sat->sgps->cosio * $sin2u; |
|
| 267 | - $xinck = $sat->tle->xincl + 1.5 * $temp2 * $sat->sgps->cosio * $sat->sgps->sinio * $cos2u; |
|
| 268 | - $rdotk = $rdot - $xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 269 | - $rfdotk = $rfdot + $xn * $temp1 * ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /* Orientation vectors */ |
|
| 273 | - $sinuk = sin($uk); |
|
| 274 | - $cosuk = cos($uk); |
|
| 275 | - $sinik = sin($xinck); |
|
| 276 | - $cosik = cos($xinck); |
|
| 277 | - $sinnok = sin($xnodek); |
|
| 278 | - $cosnok = cos($xnodek); |
|
| 279 | - $xmx = -$sinnok * $cosik; |
|
| 280 | - $xmy = $cosnok * $cosik; |
|
| 281 | - $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 282 | - $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 283 | - $uz = $sinik * $sinuk; |
|
| 284 | - $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 285 | - $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 286 | - $vz = $sinik * $cosuk; |
|
| 287 | - |
|
| 288 | - /* Position and velocity */ |
|
| 289 | - $sat->pos->x = $rk * $ux; |
|
| 290 | - $sat->pos->y = $rk * $uy; |
|
| 291 | - $sat->pos->z = $rk * $uz; |
|
| 292 | - $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 293 | - $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 294 | - $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 295 | - |
|
| 296 | - $sat->phase = $xlt - $xnode - $omgadf + Predict::twopi; |
|
| 297 | - if ($sat->phase < 0) { |
|
| 298 | - $sat->phase += Predict::twopi; |
|
| 299 | - } |
|
| 300 | - $sat->phase = Predict_Math::FMod2p($sat->phase); |
|
| 301 | - |
|
| 302 | - $sat->tle->omegao1 = $omega; |
|
| 303 | - $sat->tle->xincl1 = $xinck; |
|
| 304 | - $sat->tle->xnodeo1 = $xnodek; |
|
| 305 | - |
|
| 306 | - } /*SGP4*/ |
|
| 307 | - |
|
| 308 | - /* SDP4 */ |
|
| 309 | - /* This function is used to calculate the position and velocity */ |
|
| 310 | - /* of deep-space (period > 225 minutes) satellites. tsince is */ |
|
| 311 | - /* time since epoch in minutes, tle is a pointer to a tle_t */ |
|
| 312 | - /* structure with Keplerian orbital elements and pos and vel */ |
|
| 313 | - /* are vector_t structures returning ECI satellite position and */ |
|
| 314 | - /* velocity. Use Convert_Sat_State() to convert to km and km/s. */ |
|
| 315 | - public function SDP4(Predict_Sat $sat, $tsince) |
|
| 316 | - { |
|
| 317 | - /* Initialization */ |
|
| 318 | - if (~$sat->flags & self::SDP4_INITIALIZED_FLAG) { |
|
| 319 | - |
|
| 320 | - $sat->flags |= self::SDP4_INITIALIZED_FLAG; |
|
| 321 | - |
|
| 322 | - /* Recover original mean motion (xnodp) and */ |
|
| 323 | - /* semimajor axis (aodp) from input elements. */ |
|
| 324 | - $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 325 | - $sat->deep_arg->cosio = cos($sat->tle->xincl); |
|
| 326 | - $sat->deep_arg->theta2 = $sat->deep_arg->cosio * $sat->deep_arg->cosio; |
|
| 327 | - $sat->sgps->x3thm1 = 3.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 328 | - $sat->deep_arg->eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 329 | - $sat->deep_arg->betao2 = 1.0 - $sat->deep_arg->eosq; |
|
| 330 | - $sat->deep_arg->betao = sqrt($sat->deep_arg->betao2); |
|
| 331 | - $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 332 | - ($a1 * $a1 * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 333 | - $ao = $a1 * (1.0 - $del1 * (0.5 * Predict::tothrd + $del1 * (1.0 + 134.0 / 81.0 * $del1))); |
|
| 334 | - $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 335 | - ($ao * $ao * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 336 | - $sat->deep_arg->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 337 | - $sat->deep_arg->aodp = $ao / (1.0 - $delo); |
|
| 338 | - |
|
| 339 | - /* For perigee below 156 km, the values */ |
|
| 340 | - /* of s and qoms2t are altered. */ |
|
| 341 | - $s4 = Predict::__s__; |
|
| 342 | - $qoms24 = Predict::qoms2t; |
|
| 343 | - $perige = ($sat->deep_arg->aodp * (1.0 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 344 | - if ($perige < 156.0) { |
|
| 345 | - if ($perige <= 98.0) { |
|
| 346 | - $s4 = 20.0; |
|
| 347 | - } else { |
|
| 348 | - $s4 = $perige - 78.0; |
|
| 349 | - } |
|
| 350 | - $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 351 | - $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 352 | - } |
|
| 353 | - $pinvsq = 1.0 / ($sat->deep_arg->aodp * $sat->deep_arg->aodp * |
|
| 354 | - $sat->deep_arg->betao2 * $sat->deep_arg->betao2); |
|
| 355 | - $sat->deep_arg->sing = sin($sat->tle->omegao); |
|
| 356 | - $sat->deep_arg->cosg = cos($sat->tle->omegao); |
|
| 357 | - $tsi = 1.0 / ($sat->deep_arg->aodp - $s4); |
|
| 358 | - $eta = $sat->deep_arg->aodp * $sat->tle->eo * $tsi; |
|
| 359 | - $etasq = $eta * $eta; |
|
| 360 | - $eeta = $sat->tle->eo * $eta; |
|
| 361 | - $psisq = abs(1.0 - $etasq); |
|
| 362 | - $coef = $qoms24 * pow($tsi, 4); |
|
| 363 | - $coef1 = $coef / pow($psisq, 3.5); |
|
| 364 | - $c2 = $coef1 * $sat->deep_arg->xnodp * ($sat->deep_arg->aodp * |
|
| 365 | - (1.0 + 1.5 * $etasq + $eeta * |
|
| 366 | - (4.0 + $etasq)) + 0.75 * Predict::ck2 * $tsi / $psisq * |
|
| 367 | - $sat->sgps->x3thm1 * (8.0 + 3.0 * $etasq * |
|
| 368 | - (8.0 + $etasq))); |
|
| 369 | - $sat->sgps->c1 = $sat->tle->bstar * $c2; |
|
| 370 | - $sat->deep_arg->sinio = sin($sat->tle->xincl); |
|
| 371 | - $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 372 | - $sat->sgps->x1mth2 = 1.0 - $sat->deep_arg->theta2; |
|
| 373 | - $sat->sgps->c4 = 2.0 * $sat->deep_arg->xnodp * $coef1 * |
|
| 374 | - $sat->deep_arg->aodp * $sat->deep_arg->betao2 * |
|
| 375 | - ($eta * (2.0 + 0.5 * $etasq) + $sat->tle->eo * |
|
| 376 | - (0.5 + 2.0 * $etasq) - 2.0 * Predict::ck2 * $tsi / |
|
| 377 | - ($sat->deep_arg->aodp * $psisq) * (-3.0 * $sat->sgps->x3thm1 * |
|
| 378 | - (1.0 - 2.0 * $eeta + $etasq * |
|
| 379 | - (1.5 - 0.5 * $eeta)) + |
|
| 380 | - 0.75 * $sat->sgps->x1mth2 * |
|
| 381 | - (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 382 | - cos(2.0 * $sat->tle->omegao))); |
|
| 383 | - $theta4 = $sat->deep_arg->theta2 * $sat->deep_arg->theta2; |
|
| 384 | - $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->deep_arg->xnodp; |
|
| 385 | - $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 386 | - $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->deep_arg->xnodp; |
|
| 387 | - $sat->deep_arg->xmdot = $sat->deep_arg->xnodp + 0.5 * $temp1 * $sat->deep_arg->betao * |
|
| 388 | - $sat->sgps->x3thm1 + 0.0625 * $temp2 * $sat->deep_arg->betao * |
|
| 389 | - (13.0 - 78.0 * $sat->deep_arg->theta2 + 137.0 * $theta4); |
|
| 390 | - $x1m5th = 1.0 - 5.0 * $sat->deep_arg->theta2; |
|
| 391 | - $sat->deep_arg->omgdot = -0.5 * $temp1 * $x1m5th + 0.0625 * $temp2 * |
|
| 392 | - (7.0 - 114.0 * $sat->deep_arg->theta2 + 395.0 * $theta4) + |
|
| 393 | - $temp3 * (3.0 - 36.0 * $sat->deep_arg->theta2 + 49.0 * $theta4); |
|
| 394 | - $xhdot1 = -$temp1 * $sat->deep_arg->cosio; |
|
| 395 | - $sat->deep_arg->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $sat->deep_arg->theta2) + |
|
| 396 | - 2.0 * $temp3 * (3.0 - 7.0 * $sat->deep_arg->theta2)) * |
|
| 397 | - $sat->deep_arg->cosio; |
|
| 398 | - $sat->sgps->xnodcf = 3.5 * $sat->deep_arg->betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 399 | - $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 400 | - $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->deep_arg->sinio * |
|
| 401 | - (3.0 + 5.0 * $sat->deep_arg->cosio) / (1.0 + $sat->deep_arg->cosio); |
|
| 402 | - $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->deep_arg->sinio; |
|
| 403 | - $sat->sgps->x7thm1 = 7.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 404 | - |
|
| 405 | - /* initialize Deep() */ |
|
| 406 | - $this->Deep(self::dpinit, $sat); |
|
| 407 | - }; /*End of SDP4() initialization */ |
|
| 408 | - |
|
| 409 | - /* Update for secular gravity and atmospheric drag */ |
|
| 410 | - $xmdf = $sat->tle->xmo + $sat->deep_arg->xmdot * $tsince; |
|
| 411 | - $sat->deep_arg->omgadf = $sat->tle->omegao + $sat->deep_arg->omgdot * $tsince; |
|
| 412 | - $xnoddf = $sat->tle->xnodeo + $sat->deep_arg->xnodot * $tsince; |
|
| 413 | - $tsq = $tsince * $tsince; |
|
| 414 | - $sat->deep_arg->xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 415 | - $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 416 | - $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 417 | - $templ = $sat->sgps->t2cof * $tsq; |
|
| 418 | - $sat->deep_arg->xn = $sat->deep_arg->xnodp; |
|
| 419 | - |
|
| 420 | - /* Update for deep-space secular effects */ |
|
| 421 | - $sat->deep_arg->xll = $xmdf; |
|
| 422 | - $sat->deep_arg->t = $tsince; |
|
| 423 | - |
|
| 424 | - $this->Deep(self::dpsec, $sat); |
|
| 425 | - |
|
| 426 | - $xmdf = $sat->deep_arg->xll; |
|
| 427 | - $a = pow(Predict::xke / $sat->deep_arg->xn, Predict::tothrd) * $tempa * $tempa; |
|
| 428 | - $sat->deep_arg->em = $sat->deep_arg->em - $tempe; |
|
| 429 | - $xmam = $xmdf + $sat->deep_arg->xnodp * $templ; |
|
| 430 | - |
|
| 431 | - /* Update for deep-space periodic effects */ |
|
| 432 | - $sat->deep_arg->xll = $xmam; |
|
| 433 | - |
|
| 434 | - $this->Deep(self::dpper, $sat); |
|
| 435 | - |
|
| 436 | - $xmam = $sat->deep_arg->xll; |
|
| 437 | - $xl = $xmam + $sat->deep_arg->omgadf + $sat->deep_arg->xnode; |
|
| 438 | - $beta = sqrt(1.0 - $sat->deep_arg->em * $sat->deep_arg->em); |
|
| 439 | - $sat->deep_arg->xn = Predict::xke / pow($a, 1.5); |
|
| 440 | - |
|
| 441 | - /* Long period periodics */ |
|
| 442 | - $axn = $sat->deep_arg->em * cos($sat->deep_arg->omgadf); |
|
| 443 | - $temp = 1.0 / ($a * $beta * $beta); |
|
| 444 | - $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 445 | - $aynl = $temp * $sat->sgps->aycof; |
|
| 446 | - $xlt = $xl + $xll; |
|
| 447 | - $ayn = $sat->deep_arg->em * sin($sat->deep_arg->omgadf) + $aynl; |
|
| 448 | - |
|
| 449 | - /* Solve Kepler's Equation */ |
|
| 450 | - $capu = Predict_Math::FMod2p ($xlt - $sat->deep_arg->xnode); |
|
| 451 | - $temp2 = $capu; |
|
| 452 | - |
|
| 453 | - $i = 0; |
|
| 454 | - do { |
|
| 455 | - $sinepw = sin($temp2); |
|
| 456 | - $cosepw = cos($temp2); |
|
| 457 | - $temp3 = $axn * $sinepw; |
|
| 458 | - $temp4 = $ayn * $cosepw; |
|
| 459 | - $temp5 = $axn * $cosepw; |
|
| 460 | - $temp6 = $ayn * $sinepw; |
|
| 461 | - $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 462 | - if (abs($epw - $temp2) <= Predict::e6a) { |
|
| 463 | - break; |
|
| 464 | - } |
|
| 465 | - $temp2 = $epw; |
|
| 466 | - } while ($i++ < 10); |
|
| 467 | - |
|
| 468 | - /* Short period preliminary quantities */ |
|
| 469 | - $ecose = $temp5 + $temp6; |
|
| 470 | - $esine = $temp3 - $temp4; |
|
| 471 | - $elsq = $axn * $axn + $ayn * $ayn; |
|
| 472 | - $temp = 1.0 - $elsq; |
|
| 473 | - $pl = $a * $temp; |
|
| 474 | - $r = $a * (1.0 - $ecose); |
|
| 475 | - $temp1 = 1.0 / $r; |
|
| 476 | - $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 477 | - $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 478 | - $temp2 = $a * $temp1; |
|
| 479 | - $betal = sqrt($temp); |
|
| 480 | - $temp3 = 1.0 / (1.0 + $betal); |
|
| 481 | - $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 482 | - $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 483 | - $u = Predict_Math::AcTan($sinu, $cosu); |
|
| 484 | - $sin2u = 2.0 * $sinu * $cosu; |
|
| 485 | - $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 486 | - $temp = 1.0 / $pl; |
|
| 487 | - $temp1 = Predict::ck2 * $temp; |
|
| 488 | - $temp2 = $temp1 * $temp; |
|
| 489 | - |
|
| 490 | - /* Update for short periodics */ |
|
| 491 | - $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 492 | - 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 493 | - $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 494 | - $xnodek = $sat->deep_arg->xnode + 1.5 * $temp2 * $sat->deep_arg->cosio * $sin2u; |
|
| 495 | - $xinck = $sat->deep_arg->xinc + 1.5 * $temp2 * |
|
| 496 | - $sat->deep_arg->cosio * $sat->deep_arg->sinio * $cos2u; |
|
| 497 | - $rdotk = $rdot - $sat->deep_arg->xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 498 | - $rfdotk = $rfdot + $sat->deep_arg->xn * $temp1 * |
|
| 499 | - ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 500 | - |
|
| 501 | - /* Orientation vectors */ |
|
| 502 | - $sinuk = sin($uk); |
|
| 503 | - $cosuk = cos($uk); |
|
| 504 | - $sinik = sin($xinck); |
|
| 505 | - $cosik = cos($xinck); |
|
| 506 | - $sinnok = sin($xnodek); |
|
| 507 | - $cosnok = cos($xnodek); |
|
| 508 | - $xmx = -$sinnok * $cosik; |
|
| 509 | - $xmy = $cosnok * $cosik; |
|
| 510 | - $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 511 | - $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 512 | - $uz = $sinik * $sinuk; |
|
| 513 | - $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 514 | - $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 515 | - $vz = $sinik * $cosuk; |
|
| 516 | - |
|
| 517 | - /* Position and velocity */ |
|
| 518 | - $sat->pos->x = $rk * $ux; |
|
| 519 | - $sat->pos->y = $rk * $uy; |
|
| 520 | - $sat->pos->z = $rk * $uz; |
|
| 521 | - $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 522 | - $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 523 | - $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 524 | - |
|
| 525 | - /* Phase in rads */ |
|
| 526 | - $sat->phase = $xlt - $sat->deep_arg->xnode - $sat->deep_arg->omgadf + Predict::twopi; |
|
| 527 | - if ($sat->phase < 0.0) { |
|
| 528 | - $sat->phase += Predict::twopi; |
|
| 529 | - } |
|
| 530 | - $sat->phase = Predict_Math::FMod2p ($sat->phase); |
|
| 531 | - |
|
| 532 | - $sat->tle->omegao1 = $sat->deep_arg->omgadf; |
|
| 533 | - $sat->tle->xincl1 = $sat->deep_arg->xinc; |
|
| 534 | - $sat->tle->xnodeo1 = $sat->deep_arg->xnode; |
|
| 535 | - } /* SDP4 */ |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - /* DEEP */ |
|
| 539 | - /* This function is used by SDP4 to add lunar and solar */ |
|
| 540 | - /* perturbation effects to deep-space orbit objects. */ |
|
| 541 | - public function Deep($ientry, Predict_Sat $sat) |
|
| 542 | - { |
|
| 543 | - switch ($ientry) { |
|
| 544 | - case self::dpinit : /* Entrance for deep space initialization */ |
|
| 545 | - $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); |
|
| 546 | - $eq = $sat->tle->eo; |
|
| 547 | - $sat->dps->xnq = $sat->deep_arg->xnodp; |
|
| 548 | - $aqnv = 1.0 / $sat->deep_arg->aodp; |
|
| 549 | - $sat->dps->xqncl = $sat->tle->xincl; |
|
| 550 | - $xmao = $sat->tle->xmo; |
|
| 551 | - $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; |
|
| 552 | - $sinq = sin($sat->tle->xnodeo); |
|
| 553 | - $cosq = cos($sat->tle->xnodeo); |
|
| 554 | - $sat->dps->omegaq = $sat->tle->omegao; |
|
| 555 | - $sat->dps->preep = 0; |
|
| 556 | - |
|
| 557 | - /* Initialize lunar solar terms */ |
|
| 558 | - $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 559 | - if ($day != $sat->dps->preep) { |
|
| 560 | - $sat->dps->preep = $day; |
|
| 561 | - $xnodce = 4.5236020 - 9.2422029E-4 * $day; |
|
| 562 | - $stem = sin($xnodce); |
|
| 563 | - $ctem = cos($xnodce); |
|
| 564 | - $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; |
|
| 565 | - $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); |
|
| 566 | - $sat->dps->zsinhl = 0.089683511 * $stem / $sat->dps->zsinil; |
|
| 567 | - $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); |
|
| 568 | - $c = 4.7199672 + 0.22997150 * $day; |
|
| 569 | - $gam = 5.8351514 + 0.0019443680 * $day; |
|
| 570 | - $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); |
|
| 571 | - $zx = 0.39785416 * $stem / $sat->dps->zsinil; |
|
| 572 | - $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; |
|
| 573 | - $zx = Predict_Math::AcTan($zx, $zy); |
|
| 574 | - $zx = $gam + $zx - $xnodce; |
|
| 575 | - $sat->dps->zcosgl = cos($zx); |
|
| 576 | - $sat->dps->zsingl = sin($zx); |
|
| 577 | - $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; |
|
| 578 | - $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); |
|
| 579 | - } /* End if(day != preep) */ |
|
| 580 | - |
|
| 581 | - /* Do solar terms */ |
|
| 582 | - $sat->dps->savtsn = 1E20; |
|
| 583 | - $zcosg = Predict::zcosgs; |
|
| 584 | - $zsing = Predict::zsings; |
|
| 585 | - $zcosi = Predict::zcosis; |
|
| 586 | - $zsini = Predict::zsinis; |
|
| 587 | - $zcosh = $cosq; |
|
| 588 | - $zsinh = $sinq; |
|
| 589 | - $cc = Predict::c1ss; |
|
| 590 | - $zn = Predict::zns; |
|
| 591 | - $ze = Predict::zes; |
|
| 592 | - $zmo = $sat->dps->zmos; |
|
| 593 | - $xnoi = 1.0 / $sat->dps->xnq; |
|
| 594 | - |
|
| 595 | - /* Loop breaks when Solar terms are done a second */ |
|
| 596 | - /* time, after Lunar terms are initialized */ |
|
| 597 | - for(;;) { |
|
| 598 | - /* Solar terms done again after Lunar terms are done */ |
|
| 599 | - $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; |
|
| 600 | - $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; |
|
| 601 | - $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; |
|
| 602 | - $a8 = $zsing * $zsini; |
|
| 603 | - $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; |
|
| 604 | - $a10 = $zcosg * $zsini; |
|
| 605 | - $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; |
|
| 606 | - $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; |
|
| 607 | - $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; |
|
| 608 | - $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; |
|
| 609 | - $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; |
|
| 610 | - $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; |
|
| 611 | - $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; |
|
| 612 | - $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; |
|
| 613 | - $x5 = $a5 * $sat->deep_arg->sing; |
|
| 614 | - $x6 = $a6 * $sat->deep_arg->sing; |
|
| 615 | - $x7 = $a5 * $sat->deep_arg->cosg; |
|
| 616 | - $x8 = $a6 * $sat->deep_arg->cosg; |
|
| 617 | - $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; |
|
| 618 | - $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; |
|
| 619 | - $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; |
|
| 620 | - $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; |
|
| 621 | - $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; |
|
| 622 | - $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; |
|
| 623 | - $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); |
|
| 624 | - $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * |
|
| 625 | - (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); |
|
| 626 | - $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); |
|
| 627 | - $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); |
|
| 628 | - $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * |
|
| 629 | - (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); |
|
| 630 | - $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); |
|
| 631 | - $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; |
|
| 632 | - $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; |
|
| 633 | - $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; |
|
| 634 | - $s3 = $cc * $xnoi; |
|
| 635 | - $s2 = -0.5 * $s3 / $sat->deep_arg->betao; |
|
| 636 | - $s4 = $s3 * $sat->deep_arg->betao; |
|
| 637 | - $s1 = -15 * $eq * $s4; |
|
| 638 | - $s5 = $x1 * $x3 + $x2 * $x4; |
|
| 639 | - $s6 = $x2 * $x3 + $x1 * $x4; |
|
| 640 | - $s7 = $x2 * $x4 - $x1 * $x3; |
|
| 641 | - $se = $s1 * $zn * $s5; |
|
| 642 | - $si = $s2 * $zn * ($z11 + $z13); |
|
| 643 | - $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); |
|
| 644 | - $sgh = $s4 * $zn * ($z31 + $z33 - 6); |
|
| 645 | - $sh = -$zn * $s2 * ($z21 + $z23); |
|
| 646 | - if ($sat->dps->xqncl < 5.2359877E-2) { |
|
| 647 | - $sh = 0; |
|
| 648 | - } |
|
| 649 | - $sat->dps->ee2 = 2 * $s1 * $s6; |
|
| 650 | - $sat->dps->e3 = 2 * $s1 * $s7; |
|
| 651 | - $sat->dps->xi2 = 2 * $s2 * $z12; |
|
| 652 | - $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); |
|
| 653 | - $sat->dps->xl2 = -2 * $s3 * $z2; |
|
| 654 | - $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); |
|
| 655 | - $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; |
|
| 656 | - $sat->dps->xgh2 = 2 * $s4 * $z32; |
|
| 657 | - $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); |
|
| 658 | - $sat->dps->xgh4 = -18 * $s4 * $ze; |
|
| 659 | - $sat->dps->xh2 = -2 * $s2 * $z22; |
|
| 660 | - $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); |
|
| 661 | - |
|
| 662 | - if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { |
|
| 663 | - break; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - /* Do lunar terms */ |
|
| 667 | - $sat->dps->sse = $se; |
|
| 668 | - $sat->dps->ssi = $si; |
|
| 669 | - $sat->dps->ssl = $sl; |
|
| 670 | - $sat->dps->ssh = $sh / $sat->deep_arg->sinio; |
|
| 671 | - $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; |
|
| 672 | - $sat->dps->se2 = $sat->dps->ee2; |
|
| 673 | - $sat->dps->si2 = $sat->dps->xi2; |
|
| 674 | - $sat->dps->sl2 = $sat->dps->xl2; |
|
| 675 | - $sat->dps->sgh2 = $sat->dps->xgh2; |
|
| 676 | - $sat->dps->sh2 = $sat->dps->xh2; |
|
| 677 | - $sat->dps->se3 = $sat->dps->e3; |
|
| 678 | - $sat->dps->si3 = $sat->dps->xi3; |
|
| 679 | - $sat->dps->sl3 = $sat->dps->xl3; |
|
| 680 | - $sat->dps->sgh3 = $sat->dps->xgh3; |
|
| 681 | - $sat->dps->sh3 = $sat->dps->xh3; |
|
| 682 | - $sat->dps->sl4 = $sat->dps->xl4; |
|
| 683 | - $sat->dps->sgh4 = $sat->dps->xgh4; |
|
| 684 | - $zcosg = $sat->dps->zcosgl; |
|
| 685 | - $zsing = $sat->dps->zsingl; |
|
| 686 | - $zcosi = $sat->dps->zcosil; |
|
| 687 | - $zsini = $sat->dps->zsinil; |
|
| 688 | - $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; |
|
| 689 | - $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; |
|
| 690 | - $zn = Predict::znl; |
|
| 691 | - $cc = Predict::c1l; |
|
| 692 | - $ze = Predict::zel; |
|
| 693 | - $zmo = $sat->dps->zmol; |
|
| 694 | - $sat->flags |= self::LUNAR_TERMS_DONE_FLAG; |
|
| 695 | - } /* End of for(;;) */ |
|
| 696 | - |
|
| 697 | - $sat->dps->sse = $sat->dps->sse + $se; |
|
| 698 | - $sat->dps->ssi = $sat->dps->ssi + $si; |
|
| 699 | - $sat->dps->ssl = $sat->dps->ssl + $sl; |
|
| 700 | - $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; |
|
| 701 | - $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; |
|
| 702 | - |
|
| 703 | - /* Geopotential resonance initialization for 12 hour orbits */ |
|
| 704 | - $sat->flags &= ~self::RESONANCE_FLAG; |
|
| 705 | - $sat->flags &= ~self::SYNCHRONOUS_FLAG; |
|
| 706 | - |
|
| 707 | - if (!(($sat->dps->xnq < 0.0052359877) && ($sat->dps->xnq > 0.0034906585))) { |
|
| 708 | - if( ($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924) ) { |
|
| 709 | - return; |
|
| 710 | - } |
|
| 711 | - if ($eq < 0.5) { |
|
| 712 | - return; |
|
| 713 | - } |
|
| 714 | - $sat->flags |= self::RESONANCE_FLAG; |
|
| 715 | - $eoc = $eq * $sat->deep_arg->eosq; |
|
| 716 | - $g201 = -0.306 - ($eq - 0.64) * 0.440; |
|
| 717 | - if ($eq <= 0.65) { |
|
| 718 | - $g211 = 3.616 - 13.247 * $eq + 16.290 * $sat->deep_arg->eosq; |
|
| 719 | - $g310 = -19.302 + 117.390 * $eq - 228.419 * |
|
| 720 | - $sat->deep_arg->eosq + 156.591 * $eoc; |
|
| 721 | - $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * |
|
| 722 | - $sat->deep_arg->eosq + 146.5816 * $eoc; |
|
| 723 | - $g410 = -41.122 + 242.694 * $eq - 471.094 * |
|
| 724 | - $sat->deep_arg->eosq + 313.953 * $eoc; |
|
| 725 | - $g422 = -146.407 + 841.880 * $eq - 1629.014 * |
|
| 726 | - $sat->deep_arg->eosq + 1083.435 * $eoc; |
|
| 727 | - $g520 = -532.114 + 3017.977 * $eq - 5740 * |
|
| 728 | - $sat->deep_arg->eosq + 3708.276 * $eoc; |
|
| 729 | - } else { |
|
| 730 | - $g211 = -72.099 + 331.819 * $eq - 508.738 * |
|
| 731 | - $sat->deep_arg->eosq + 266.724 * $eoc; |
|
| 732 | - $g310 = -346.844 + 1582.851 * $eq - 2415.925 * |
|
| 733 | - $sat->deep_arg->eosq + 1246.113 * $eoc; |
|
| 734 | - $g322 = -342.585 + 1554.908 * $eq - 2366.899 * |
|
| 735 | - $sat->deep_arg->eosq + 1215.972 * $eoc; |
|
| 736 | - $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * |
|
| 737 | - $sat->deep_arg->eosq + 3651.957 * $eoc; |
|
| 738 | - $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * |
|
| 739 | - $sat->deep_arg->eosq+ 12422.52 * $eoc; |
|
| 740 | - if ($eq <= 0.715) { |
|
| 741 | - $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; |
|
| 742 | - } else { |
|
| 743 | - $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * |
|
| 744 | - $sat->deep_arg->eosq + 31324.56 * $eoc; |
|
| 745 | - } |
|
| 746 | - } /* End if (eq <= 0.65) */ |
|
| 747 | - |
|
| 748 | - if ($eq < 0.7) { |
|
| 749 | - $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * |
|
| 750 | - $sat->deep_arg->eosq + 5542.21 * $eoc; |
|
| 751 | - $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * |
|
| 752 | - $sat->deep_arg->eosq + 5337.524 * $eoc; |
|
| 753 | - $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
|
| 754 | - $sat->deep_arg->eosq + 5341.4 * $eoc; |
|
| 755 | - } |
|
| 756 | - else { |
|
| 757 | - $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
|
| 758 | - $sat->deep_arg->eosq + 109377.94 * $eoc; |
|
| 759 | - $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
|
| 760 | - $sat->deep_arg->eosq + 146349.42 * $eoc; |
|
| 761 | - $g532 = -40023.88 + 170470.89 * $eq - 242699.48* |
|
| 762 | - $sat->deep_arg->eosq + 115605.82 * $eoc; |
|
| 763 | - } /* End if (eq <= 0.7) */ |
|
| 764 | - |
|
| 765 | - $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; |
|
| 766 | - $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | - $f221 = 1.5 * $sini2; |
|
| 768 | - $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * |
|
| 769 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 770 | - $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2* |
|
| 771 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 772 | - $f441 = 35 * $sini2 * $f220; |
|
| 773 | - $f442 = 39.3750 * $sini2 * $sini2; |
|
| 774 | - $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * |
|
| 775 | - $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + |
|
| 776 | - 6 * $sat->deep_arg->theta2)); |
|
| 777 | - $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * |
|
| 778 | - $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | - * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); |
|
| 780 | - $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * |
|
| 781 | - $sat->deep_arg->cosio + $sat->deep_arg->theta2 * |
|
| 782 | - (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); |
|
| 783 | - $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + |
|
| 784 | - $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * |
|
| 785 | - $sat->deep_arg->theta2)); |
|
| 786 | - $xno2 = $sat->dps->xnq * $sat->dps->xnq; |
|
| 787 | - $ainv2 = $aqnv * $aqnv; |
|
| 788 | - $temp1 = 3 * $xno2 * $ainv2; |
|
| 789 | - $temp = $temp1 * Predict::root22; |
|
| 790 | - $sat->dps->d2201 = $temp * $f220 * $g201; |
|
| 791 | - $sat->dps->d2211 = $temp * $f221 * $g211; |
|
| 792 | - $temp1 = $temp1 * $aqnv; |
|
| 793 | - $temp = $temp1 * Predict::root32; |
|
| 794 | - $sat->dps->d3210 = $temp * $f321 * $g310; |
|
| 795 | - $sat->dps->d3222 = $temp * $f322 * $g322; |
|
| 796 | - $temp1 = $temp1 * $aqnv; |
|
| 797 | - $temp = 2 * $temp1 * Predict::root44; |
|
| 798 | - $sat->dps->d4410 = $temp * $f441 * $g410; |
|
| 799 | - $sat->dps->d4422 = $temp * $f442 * $g422; |
|
| 800 | - $temp1 = $temp1 * $aqnv; |
|
| 801 | - $temp = $temp1 * Predict::root52; |
|
| 802 | - $sat->dps->d5220 = $temp * $f522 * $g520; |
|
| 803 | - $sat->dps->d5232 = $temp * $f523 * $g532; |
|
| 804 | - $temp = 2 * $temp1 * Predict::root54; |
|
| 805 | - $sat->dps->d5421 = $temp * $f542 * $g521; |
|
| 806 | - $sat->dps->d5433 = $temp * $f543 * $g533; |
|
| 807 | - $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; |
|
| 808 | - $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + |
|
| 809 | - $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; |
|
| 810 | - $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssh + $sat->dps->ssh; |
|
| 811 | - } else { |
|
| 812 | - $sat->flags |= self::RESONANCE_FLAG; |
|
| 813 | - $sat->flags |= self::SYNCHRONOUS_FLAG; |
|
| 814 | - /* Synchronous resonance terms initialization */ |
|
| 815 | - $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); |
|
| 816 | - $g310 = 1 + 2 * $sat->deep_arg->eosq; |
|
| 817 | - $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); |
|
| 818 | - $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); |
|
| 819 | - $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * |
|
| 820 | - (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); |
|
| 821 | - $f330 = 1 + $sat->deep_arg->cosio; |
|
| 822 | - $f330 = 1.875 * $f330 * $f330 * $f330; |
|
| 823 | - $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; |
|
| 824 | - $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; |
|
| 825 | - $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; |
|
| 826 | - $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; |
|
| 827 | - $sat->dps->fasx2 = 0.13130908; |
|
| 828 | - $sat->dps->fasx4 = 2.8843198; |
|
| 829 | - $sat->dps->fasx6 = 0.37448087; |
|
| 830 | - $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->omegao - $sat->dps->thgr; |
|
| 831 | - $bfact = $sat->deep_arg->xmdot + $xpidot - Predict::thdt; |
|
| 832 | - $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssg + $sat->dps->ssh; |
|
| 833 | - } /* End if( !(xnq < 0.0052359877) && (xnq > 0.0034906585) ) */ |
|
| 834 | - |
|
| 835 | - $sat->dps->xfact = $bfact - $sat->dps->xnq; |
|
| 836 | - |
|
| 837 | - /* Initialize integrator */ |
|
| 838 | - $sat->dps->xli = $sat->dps->xlamo; |
|
| 839 | - $sat->dps->xni = $sat->dps->xnq; |
|
| 840 | - $sat->dps->atime = 0; |
|
| 841 | - $sat->dps->stepp = 720; |
|
| 842 | - $sat->dps->stepn = -720; |
|
| 843 | - $sat->dps->step2 = 259200; |
|
| 844 | - /* End case self::dpinit: */ |
|
| 845 | - return; |
|
| 846 | - |
|
| 847 | - case self::dpsec: /* Entrance for deep space secular effects */ |
|
| 848 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; |
|
| 849 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; |
|
| 850 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; |
|
| 851 | - $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; |
|
| 852 | - $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; |
|
| 853 | - if ($sat->deep_arg->xinc < 0) { |
|
| 854 | - $sat->deep_arg->xinc = -$sat->deep_arg->xinc; |
|
| 855 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; |
|
| 856 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; |
|
| 857 | - } |
|
| 858 | - if(~$sat->flags & self::RESONANCE_FLAG ) { |
|
| 859 | - return; |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - do { |
|
| 863 | - if ( ($sat->dps->atime == 0) || |
|
| 864 | - (($sat->deep_arg->t >= 0) && ($sat->dps->atime < 0)) || |
|
| 865 | - (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0)) ) { |
|
| 866 | - /* Epoch restart */ |
|
| 867 | - if ($sat->deep_arg->t >= 0) { |
|
| 868 | - $delt = $sat->dps->stepp; |
|
| 869 | - } else { |
|
| 870 | - $delt = $sat->dps->stepn; |
|
| 871 | - } |
|
| 872 | - |
|
| 873 | - $sat->dps->atime = 0; |
|
| 874 | - $sat->dps->xni = $sat->dps->xnq; |
|
| 875 | - $sat->dps->xli = $sat->dps->xlamo; |
|
| 876 | - } else { |
|
| 877 | - if (abs($sat->deep_arg->t) >= abs($sat->dps->atime)) { |
|
| 878 | - if ($sat->deep_arg->t > 0) { |
|
| 879 | - $delt = $sat->dps->stepp; |
|
| 880 | - } else { |
|
| 881 | - $delt = $sat->dps->stepn; |
|
| 882 | - } |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - do { |
|
| 887 | - if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { |
|
| 888 | - $sat->flags |= self::DO_LOOP_FLAG; |
|
| 889 | - $sat->flags &= ~self::EPOCH_RESTART_FLAG; |
|
| 890 | - } |
|
| 891 | - else { |
|
| 892 | - $ft = $sat->deep_arg->t - $sat->dps->atime; |
|
| 893 | - $sat->flags &= ~self::DO_LOOP_FLAG; |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - if (abs($sat->deep_arg->t) < abs($sat->dps->atime)) { |
|
| 897 | - if ($sat->deep_arg->t >= 0) { |
|
| 898 | - $delt = $sat->dps->stepn; |
|
| 899 | - } else { |
|
| 900 | - $delt = $sat->dps->stepp; |
|
| 901 | - } |
|
| 902 | - $sat->flags |= (self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG); |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - /* Dot terms calculated */ |
|
| 906 | - if ($sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 907 | - $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | - + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | - $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | - + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 911 | - } else { |
|
| 912 | - $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; |
|
| 913 | - $x2omi = $xomi + $xomi; |
|
| 914 | - $x2li = $sat->dps->xli + $sat->dps->xli; |
|
| 915 | - $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | - + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) |
|
| 917 | - + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | - + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | - + $sat->dps->d4410 * sin($x2omi + $x2li- Predict::g44) |
|
| 920 | - + $sat->dps->d4422 * sin($x2li- Predict::g44) |
|
| 921 | - + $sat->dps->d5220 * sin($xomi + $sat->dps->xli- Predict::g52) |
|
| 922 | - + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli- Predict::g52) |
|
| 923 | - + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) |
|
| 924 | - + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | - $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli- Predict::g22) |
|
| 926 | - + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) |
|
| 927 | - + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | - + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | - + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | - + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | - + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) |
|
| 932 | - + $sat->dps->d4422 * cos($x2li - Predict::g44) |
|
| 933 | - + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) |
|
| 934 | - + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); |
|
| 935 | - } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ |
|
| 936 | - |
|
| 937 | - $xldot = $sat->dps->xni + $sat->dps->xfact; |
|
| 938 | - $xnddt = $xnddt * $xldot; |
|
| 939 | - |
|
| 940 | - if ($sat->flags & self::DO_LOOP_FLAG) { |
|
| 941 | - $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; |
|
| 942 | - $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; |
|
| 943 | - $sat->dps->atime = $sat->dps->atime + $delt; |
|
| 944 | - } |
|
| 945 | - } while (($sat->flags & self::DO_LOOP_FLAG) && |
|
| 946 | - (~$sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 947 | - } |
|
| 948 | - while (($sat->flags & self::DO_LOOP_FLAG) && ($sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 949 | - |
|
| 950 | - $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; |
|
| 951 | - $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; |
|
| 952 | - $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; |
|
| 953 | - |
|
| 954 | - if (~$sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 955 | - $sat->deep_arg->xll = $xl + $temp + $temp; |
|
| 956 | - } else { |
|
| 957 | - $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - return; |
|
| 961 | - /* End case dpsec: */ |
|
| 962 | - |
|
| 963 | - case self::dpper: /* Entrance for lunar-solar periodics */ |
|
| 964 | - $sinis = sin($sat->deep_arg->xinc); |
|
| 965 | - $cosis = cos($sat->deep_arg->xinc); |
|
| 966 | - if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { |
|
| 967 | - $sat->dps->savtsn = $sat->deep_arg->t; |
|
| 968 | - $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; |
|
| 969 | - $zf = $zm + 2 * Predict::zes * sin($zm); |
|
| 970 | - $sinzf = sin($zf); |
|
| 971 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 972 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 973 | - $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; |
|
| 974 | - $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; |
|
| 975 | - $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; |
|
| 976 | - $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; |
|
| 977 | - $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; |
|
| 978 | - $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; |
|
| 979 | - $zf = $zm + 2 * Predict::zel * sin($zm); |
|
| 980 | - $sinzf = sin($zf); |
|
| 981 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 982 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 983 | - $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; |
|
| 984 | - $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; |
|
| 985 | - $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; |
|
| 986 | - $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; |
|
| 987 | - $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; |
|
| 988 | - $sat->dps->pe = $ses + $sel; |
|
| 989 | - $sat->dps->pinc = $sis + $sil; |
|
| 990 | - $sat->dps->pl = $sls + $sll; |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - $pgh = $sat->dps->sghs + $sat->dps->sghl; |
|
| 994 | - $ph = $sat->dps->shs + $sat->dps->sh1; |
|
| 995 | - $sat->deep_arg->xinc = $sat->deep_arg->xinc + $sat->dps->pinc; |
|
| 996 | - $sat->deep_arg->em = $sat->deep_arg->em + $sat->dps->pe; |
|
| 997 | - |
|
| 998 | - if ($sat->dps->xqncl >= 0.2) { |
|
| 999 | - /* Apply periodics directly */ |
|
| 1000 | - $ph = $ph / $sat->deep_arg->sinio; |
|
| 1001 | - $pgh = $pgh - $sat->deep_arg->cosio * $ph; |
|
| 1002 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; |
|
| 1003 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; |
|
| 1004 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1005 | - } else { |
|
| 1006 | - /* Apply periodics with Lyddane modification */ |
|
| 1007 | - $sinok = sin($sat->deep_arg->xnode); |
|
| 1008 | - $cosok = cos($sat->deep_arg->xnode); |
|
| 1009 | - $alfdp = $sinis * $sinok; |
|
| 1010 | - $betdp = $sinis * $cosok; |
|
| 1011 | - $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; |
|
| 1012 | - $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; |
|
| 1013 | - $alfdp = $alfdp + $dalf; |
|
| 1014 | - $betdp = $betdp + $dbet; |
|
| 1015 | - $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); |
|
| 1016 | - $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; |
|
| 1017 | - $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; |
|
| 1018 | - $xls = $xls + $dls; |
|
| 1019 | - $xnoh = $sat->deep_arg->xnode; |
|
| 1020 | - $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); |
|
| 1021 | - |
|
| 1022 | - /* This is a patch to Lyddane modification */ |
|
| 1023 | - /* suggested by Rob Matson. */ |
|
| 1024 | - if(abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1025 | - if ($sat->deep_arg->xnode < $xnoh) { |
|
| 1026 | - $sat->deep_arg->xnode += Predict::twopi; |
|
| 1027 | - } else { |
|
| 1028 | - $sat->deep_arg->xnode -= Predict::twopi; |
|
| 1029 | - } |
|
| 1030 | - } |
|
| 1031 | - |
|
| 1032 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1033 | - $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * |
|
| 1034 | - $sat->deep_arg->xnode; |
|
| 1035 | - } /* End case dpper: */ |
|
| 1036 | - return; |
|
| 1037 | - |
|
| 1038 | - } /* End switch(ientry) */ |
|
| 1039 | - |
|
| 1040 | - } /* End of Deep() */ |
|
| 1041 | - |
|
| 1042 | - /** |
|
| 1043 | - * Singleton |
|
| 1044 | - * |
|
| 1045 | - * @param Predict_Sat $sat The current satellite data instance |
|
| 1046 | - * |
|
| 1047 | - * @return Predict_SGPSDP |
|
| 1048 | - */ |
|
| 1049 | - public static function getInstance(Predict_Sat $sat) |
|
| 1050 | - { |
|
| 1051 | - static $instances = array(); |
|
| 1052 | - $catnr = $sat->tle->catnr; |
|
| 1053 | - if (!isset($instances[$catnr])) { |
|
| 1054 | - $instances[$catnr] = new self(); |
|
| 1055 | - } |
|
| 1056 | - return $instances[$catnr]; |
|
| 1057 | - } |
|
| 59 | + const dpinit = 1; /* Deep-space initialization code */ |
|
| 60 | + const dpsec = 2; /* Deep-space secular code */ |
|
| 61 | + const dpper = 3; /* Deep-space periodic code */ |
|
| 62 | + |
|
| 63 | + /* SGP4 */ |
|
| 64 | + /* This function is used to calculate the position and velocity */ |
|
| 65 | + /* of near-earth (period < 225 minutes) satellites. tsince is */ |
|
| 66 | + /* time since epoch in minutes, tle is a pointer to a tle_t */ |
|
| 67 | + /* structure with Keplerian orbital elements and pos and vel */ |
|
| 68 | + /* are vector_t structures returning ECI satellite position and */ |
|
| 69 | + /* velocity. Use Convert_Sat_State() to convert to km and km/s.*/ |
|
| 70 | + public function SGP4(Predict_Sat $sat, $tsince) |
|
| 71 | + { |
|
| 72 | + /* Initialization */ |
|
| 73 | + if (~$sat->flags & self::SGP4_INITIALIZED_FLAG) { |
|
| 74 | + $sat->flags |= self::SGP4_INITIALIZED_FLAG; |
|
| 75 | + |
|
| 76 | + /* Recover original mean motion (xnodp) and */ |
|
| 77 | + /* semimajor axis (aodp) from input elements. */ |
|
| 78 | + $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 79 | + $sat->sgps->cosio = cos($sat->tle->xincl); |
|
| 80 | + $theta2 = $sat->sgps->cosio * $sat->sgps->cosio; |
|
| 81 | + $sat->sgps->x3thm1 = 3 * $theta2 - 1.0; |
|
| 82 | + $eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 83 | + $betao2 = 1 - $eosq; |
|
| 84 | + $betao = sqrt($betao2); |
|
| 85 | + $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($a1 * $a1 * $betao * $betao2); |
|
| 86 | + $ao = $a1 * (1 - $del1 * (0.5 * Predict::tothrd + $del1 * (1 + 134.0 / 81.0 * $del1))); |
|
| 87 | + $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($ao * $ao * $betao * $betao2); |
|
| 88 | + $sat->sgps->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 89 | + $sat->sgps->aodp = $ao / (1.0 - $delo); |
|
| 90 | + |
|
| 91 | + /* For perigee less than 220 kilometers, the "simple" flag is set */ |
|
| 92 | + /* and the equations are truncated to linear variation in sqrt a */ |
|
| 93 | + /* and quadratic variation in mean anomaly. Also, the c3 term, */ |
|
| 94 | + /* the delta omega term, and the delta m term are dropped. */ |
|
| 95 | + if (($sat->sgps->aodp * (1.0 - $sat->tle->eo) / Predict::ae) < (220.0 / Predict::xkmper + Predict::ae)) { |
|
| 96 | + $sat->flags |= self::SIMPLE_FLAG; |
|
| 97 | + } else { |
|
| 98 | + $sat->flags &= ~self::SIMPLE_FLAG; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + /* For perigee below 156 km, the */ |
|
| 102 | + /* values of s and qoms2t are altered. */ |
|
| 103 | + $s4 = Predict::__s__; |
|
| 104 | + $qoms24 = Predict::qoms2t; |
|
| 105 | + $perige = ($sat->sgps->aodp * (1 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 106 | + if ($perige < 156.0) { |
|
| 107 | + if ($perige <= 98.0) { |
|
| 108 | + $s4 = 20.0; |
|
| 109 | + } else { |
|
| 110 | + $s4 = $perige - 78.0; |
|
| 111 | + } |
|
| 112 | + $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 113 | + $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 114 | + }; /* FIXME FIXME: End of if(perige <= 98) NO WAY!!!! */ |
|
| 115 | + |
|
| 116 | + $pinvsq = 1.0 / ($sat->sgps->aodp * $sat->sgps->aodp * $betao2 * $betao2); |
|
| 117 | + $tsi = 1.0 / ($sat->sgps->aodp - $s4); |
|
| 118 | + $sat->sgps->eta = $sat->sgps->aodp * $sat->tle->eo * $tsi; |
|
| 119 | + $etasq = $sat->sgps->eta * $sat->sgps->eta; |
|
| 120 | + $eeta = $sat->tle->eo * $sat->sgps->eta; |
|
| 121 | + $psisq = abs(1.0 - $etasq); |
|
| 122 | + $coef = $qoms24 * pow($tsi, 4); |
|
| 123 | + $coef1 = $coef / pow($psisq, 3.5); |
|
| 124 | + $c2 = $coef1 * $sat->sgps->xnodp * ($sat->sgps->aodp * |
|
| 125 | + (1.0 + 1.5 * $etasq + $eeta * (4.0 + $etasq)) + |
|
| 126 | + 0.75 * Predict::ck2 * $tsi / $psisq * $sat->sgps->x3thm1 * |
|
| 127 | + (8.0 + 3.0 * $etasq * (8 + $etasq))); |
|
| 128 | + $sat->sgps->c1 = $c2 * $sat->tle->bstar; |
|
| 129 | + $sat->sgps->sinio = sin($sat->tle->xincl); |
|
| 130 | + $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 131 | + $c3 = $coef * $tsi * $a3ovk2 * $sat->sgps->xnodp * Predict::ae * $sat->sgps->sinio / $sat->tle->eo; |
|
| 132 | + $sat->sgps->x1mth2 = 1.0 - $theta2; |
|
| 133 | + $sat->sgps->c4 = 2.0 * $sat->sgps->xnodp * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 134 | + ($sat->sgps->eta * (2.0 + 0.5 * $etasq) + |
|
| 135 | + $sat->tle->eo * (0.5 + 2.0 * $etasq) - |
|
| 136 | + 2.0 * Predict::ck2 * $tsi / ($sat->sgps->aodp * $psisq) * |
|
| 137 | + (-3.0 * $sat->sgps->x3thm1 * (1.0 - 2.0 * $eeta + $etasq * (1.5 - 0.5 * $eeta)) + |
|
| 138 | + 0.75 * $sat->sgps->x1mth2 * (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 139 | + cos(2.0 * $sat->tle->omegao))); |
|
| 140 | + $sat->sgps->c5 = 2.0 * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 141 | + (1.0 + 2.75 * ($etasq + $eeta) + $eeta * $etasq); |
|
| 142 | + $theta4 = $theta2 * $theta2; |
|
| 143 | + $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->sgps->xnodp; |
|
| 144 | + $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 145 | + $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->sgps->xnodp; |
|
| 146 | + $sat->sgps->xmdot = $sat->sgps->xnodp + 0.5 * $temp1 * $betao * $sat->sgps->x3thm1 + |
|
| 147 | + 0.0625 * $temp2 * $betao * (13.0 - 78.0 * $theta2 + 137.0 * $theta4); |
|
| 148 | + $x1m5th = 1.0 - 5.0 * $theta2; |
|
| 149 | + $sat->sgps->omgdot = -0.5 * $temp1 * $x1m5th + |
|
| 150 | + 0.0625 * $temp2 * (7.0 - 114.0 * $theta2 + 395.0 * $theta4) + |
|
| 151 | + $temp3 * (3.0 - 36.0 * $theta2 + 49.0 * $theta4); |
|
| 152 | + $xhdot1 = -$temp1 * $sat->sgps->cosio; |
|
| 153 | + $sat->sgps->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $theta2) + |
|
| 154 | + 2.0 * $temp3 * (3.0 - 7.0 * $theta2)) * $sat->sgps->cosio; |
|
| 155 | + $sat->sgps->omgcof = $sat->tle->bstar * $c3 * cos($sat->tle->omegao); |
|
| 156 | + $sat->sgps->xmcof = -Predict::tothrd * $coef * $sat->tle->bstar * Predict::ae / $eeta; |
|
| 157 | + $sat->sgps->xnodcf = 3.5 * $betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 158 | + $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 159 | + $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->sgps->sinio * |
|
| 160 | + (3.0 + 5.0 * $sat->sgps->cosio) / (1.0 + $sat->sgps->cosio); |
|
| 161 | + $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->sgps->sinio; |
|
| 162 | + $sat->sgps->delmo = pow(1.0 + $sat->sgps->eta * cos($sat->tle->xmo), 3); |
|
| 163 | + $sat->sgps->sinmo = sin($sat->tle->xmo); |
|
| 164 | + $sat->sgps->x7thm1 = 7.0 * $theta2 - 1.0; |
|
| 165 | + if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 166 | + $c1sq = $sat->sgps->c1 * $sat->sgps->c1; |
|
| 167 | + $sat->sgps->d2 = 4.0 * $sat->sgps->aodp * $tsi * $c1sq; |
|
| 168 | + $temp = $sat->sgps->d2 * $tsi * $sat->sgps->c1 / 3.0; |
|
| 169 | + $sat->sgps->d3 = (17.0 * $sat->sgps->aodp + $s4) * $temp; |
|
| 170 | + $sat->sgps->d4 = 0.5 * $temp * $sat->sgps->aodp * $tsi * |
|
| 171 | + (221.0 * $sat->sgps->aodp + 31.0 * $s4) * $sat->sgps->c1; |
|
| 172 | + $sat->sgps->t3cof = $sat->sgps->d2 + 2.0 * $c1sq; |
|
| 173 | + $sat->sgps->t4cof = 0.25 * (3.0 * $sat->sgps->d3 + $sat->sgps->c1 * |
|
| 174 | + (12.0 * $sat->sgps->d2 + 10.0 * $c1sq)); |
|
| 175 | + $sat->sgps->t5cof = 0.2 * (3.0 * $sat->sgps->d4 + |
|
| 176 | + 12.0 * $sat->sgps->c1 * $sat->sgps->d3 + |
|
| 177 | + 6.0 * $sat->sgps->d2 * $sat->sgps->d2 + |
|
| 178 | + 15.0 * $c1sq * (2.0 * $sat->sgps->d2 + $c1sq)); |
|
| 179 | + }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
|
| 180 | + }; /* End of SGP4() initialization */ |
|
| 181 | + |
|
| 182 | + /* Update for secular gravity and atmospheric drag. */ |
|
| 183 | + $xmdf = $sat->tle->xmo + $sat->sgps->xmdot * $tsince; |
|
| 184 | + $omgadf = $sat->tle->omegao + $sat->sgps->omgdot * $tsince; |
|
| 185 | + $xnoddf = $sat->tle->xnodeo + $sat->sgps->xnodot * $tsince; |
|
| 186 | + $omega = $omgadf; |
|
| 187 | + $xmp = $xmdf; |
|
| 188 | + $tsq = $tsince * $tsince; |
|
| 189 | + $xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 190 | + $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 191 | + $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 192 | + $templ = $sat->sgps->t2cof * $tsq; |
|
| 193 | + if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 194 | + $delomg = $sat->sgps->omgcof * $tsince; |
|
| 195 | + $delm = $sat->sgps->xmcof * (pow(1 + $sat->sgps->eta * cos($xmdf), 3) - $sat->sgps->delmo); |
|
| 196 | + $temp = $delomg + $delm; |
|
| 197 | + $xmp = $xmdf + $temp; |
|
| 198 | + $omega = $omgadf - $temp; |
|
| 199 | + $tcube = $tsq * $tsince; |
|
| 200 | + $tfour = $tsince * $tcube; |
|
| 201 | + $tempa = $tempa - $sat->sgps->d2 * $tsq - $sat->sgps->d3 * $tcube - $sat->sgps->d4 * $tfour; |
|
| 202 | + $tempe = $tempe + $sat->tle->bstar * $sat->sgps->c5 * (sin($xmp) - $sat->sgps->sinmo); |
|
| 203 | + $templ = $templ + $sat->sgps->t3cof * $tcube + $tfour * |
|
| 204 | + ($sat->sgps->t4cof + $tsince * $sat->sgps->t5cof); |
|
| 205 | + }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
|
| 206 | + |
|
| 207 | + $a = $sat->sgps->aodp * pow($tempa, 2); |
|
| 208 | + $e = $sat->tle->eo - $tempe; |
|
| 209 | + $xl = $xmp + $omega + $xnode + $sat->sgps->xnodp * $templ; |
|
| 210 | + $beta = sqrt(1.0 - ($e * $e)); |
|
| 211 | + $xn = Predict::xke / pow($a, 1.5); |
|
| 212 | + |
|
| 213 | + /* Long period periodics */ |
|
| 214 | + $axn = $e * cos($omega); |
|
| 215 | + $temp = 1.0 / ($a * $beta * $beta); |
|
| 216 | + $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 217 | + $aynl = $temp * $sat->sgps->aycof; |
|
| 218 | + $xlt = $xl + $xll; |
|
| 219 | + $ayn = $e * sin($omega) + $aynl; |
|
| 220 | + |
|
| 221 | + /* Solve Kepler's' Equation */ |
|
| 222 | + $capu = Predict_Math::FMod2p($xlt - $xnode); |
|
| 223 | + $temp2 = $capu; |
|
| 224 | + |
|
| 225 | + $i = 0; |
|
| 226 | + do { |
|
| 227 | + $sinepw = sin($temp2); |
|
| 228 | + $cosepw = cos($temp2); |
|
| 229 | + $temp3 = $axn * $sinepw; |
|
| 230 | + $temp4 = $ayn * $cosepw; |
|
| 231 | + $temp5 = $axn * $cosepw; |
|
| 232 | + $temp6 = $ayn * $sinepw; |
|
| 233 | + $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 234 | + if (abs($epw - $temp2) <= Predict::e6a) { |
|
| 235 | + break; |
|
| 236 | + } |
|
| 237 | + $temp2 = $epw; |
|
| 238 | + } while ($i++ < 10); |
|
| 239 | + |
|
| 240 | + /* Short period preliminary quantities */ |
|
| 241 | + $ecose = $temp5 + $temp6; |
|
| 242 | + $esine = $temp3 - $temp4; |
|
| 243 | + $elsq = $axn * $axn + $ayn * $ayn; |
|
| 244 | + $temp = 1.0 - $elsq; |
|
| 245 | + $pl = $a * $temp; |
|
| 246 | + $r = $a * (1.0 - $ecose); |
|
| 247 | + $temp1 = 1.0 / $r; |
|
| 248 | + $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 249 | + $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 250 | + $temp2 = $a * $temp1; |
|
| 251 | + $betal = sqrt($temp); |
|
| 252 | + $temp3 = 1.0 / (1.0 + $betal); |
|
| 253 | + $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 254 | + $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 255 | + $u = Predict_Math::AcTan($sinu, $cosu); |
|
| 256 | + $sin2u = 2.0 * $sinu * $cosu; |
|
| 257 | + $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 258 | + $temp = 1.0 / $pl; |
|
| 259 | + $temp1 = Predict::ck2 * $temp; |
|
| 260 | + $temp2 = $temp1 * $temp; |
|
| 261 | + |
|
| 262 | + /* Update for short periodics */ |
|
| 263 | + $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 264 | + 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 265 | + $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 266 | + $xnodek = $xnode + 1.5 * $temp2 * $sat->sgps->cosio * $sin2u; |
|
| 267 | + $xinck = $sat->tle->xincl + 1.5 * $temp2 * $sat->sgps->cosio * $sat->sgps->sinio * $cos2u; |
|
| 268 | + $rdotk = $rdot - $xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 269 | + $rfdotk = $rfdot + $xn * $temp1 * ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /* Orientation vectors */ |
|
| 273 | + $sinuk = sin($uk); |
|
| 274 | + $cosuk = cos($uk); |
|
| 275 | + $sinik = sin($xinck); |
|
| 276 | + $cosik = cos($xinck); |
|
| 277 | + $sinnok = sin($xnodek); |
|
| 278 | + $cosnok = cos($xnodek); |
|
| 279 | + $xmx = -$sinnok * $cosik; |
|
| 280 | + $xmy = $cosnok * $cosik; |
|
| 281 | + $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 282 | + $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 283 | + $uz = $sinik * $sinuk; |
|
| 284 | + $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 285 | + $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 286 | + $vz = $sinik * $cosuk; |
|
| 287 | + |
|
| 288 | + /* Position and velocity */ |
|
| 289 | + $sat->pos->x = $rk * $ux; |
|
| 290 | + $sat->pos->y = $rk * $uy; |
|
| 291 | + $sat->pos->z = $rk * $uz; |
|
| 292 | + $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 293 | + $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 294 | + $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 295 | + |
|
| 296 | + $sat->phase = $xlt - $xnode - $omgadf + Predict::twopi; |
|
| 297 | + if ($sat->phase < 0) { |
|
| 298 | + $sat->phase += Predict::twopi; |
|
| 299 | + } |
|
| 300 | + $sat->phase = Predict_Math::FMod2p($sat->phase); |
|
| 301 | + |
|
| 302 | + $sat->tle->omegao1 = $omega; |
|
| 303 | + $sat->tle->xincl1 = $xinck; |
|
| 304 | + $sat->tle->xnodeo1 = $xnodek; |
|
| 305 | + |
|
| 306 | + } /*SGP4*/ |
|
| 307 | + |
|
| 308 | + /* SDP4 */ |
|
| 309 | + /* This function is used to calculate the position and velocity */ |
|
| 310 | + /* of deep-space (period > 225 minutes) satellites. tsince is */ |
|
| 311 | + /* time since epoch in minutes, tle is a pointer to a tle_t */ |
|
| 312 | + /* structure with Keplerian orbital elements and pos and vel */ |
|
| 313 | + /* are vector_t structures returning ECI satellite position and */ |
|
| 314 | + /* velocity. Use Convert_Sat_State() to convert to km and km/s. */ |
|
| 315 | + public function SDP4(Predict_Sat $sat, $tsince) |
|
| 316 | + { |
|
| 317 | + /* Initialization */ |
|
| 318 | + if (~$sat->flags & self::SDP4_INITIALIZED_FLAG) { |
|
| 319 | + |
|
| 320 | + $sat->flags |= self::SDP4_INITIALIZED_FLAG; |
|
| 321 | + |
|
| 322 | + /* Recover original mean motion (xnodp) and */ |
|
| 323 | + /* semimajor axis (aodp) from input elements. */ |
|
| 324 | + $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 325 | + $sat->deep_arg->cosio = cos($sat->tle->xincl); |
|
| 326 | + $sat->deep_arg->theta2 = $sat->deep_arg->cosio * $sat->deep_arg->cosio; |
|
| 327 | + $sat->sgps->x3thm1 = 3.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 328 | + $sat->deep_arg->eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 329 | + $sat->deep_arg->betao2 = 1.0 - $sat->deep_arg->eosq; |
|
| 330 | + $sat->deep_arg->betao = sqrt($sat->deep_arg->betao2); |
|
| 331 | + $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 332 | + ($a1 * $a1 * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 333 | + $ao = $a1 * (1.0 - $del1 * (0.5 * Predict::tothrd + $del1 * (1.0 + 134.0 / 81.0 * $del1))); |
|
| 334 | + $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 335 | + ($ao * $ao * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 336 | + $sat->deep_arg->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 337 | + $sat->deep_arg->aodp = $ao / (1.0 - $delo); |
|
| 338 | + |
|
| 339 | + /* For perigee below 156 km, the values */ |
|
| 340 | + /* of s and qoms2t are altered. */ |
|
| 341 | + $s4 = Predict::__s__; |
|
| 342 | + $qoms24 = Predict::qoms2t; |
|
| 343 | + $perige = ($sat->deep_arg->aodp * (1.0 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 344 | + if ($perige < 156.0) { |
|
| 345 | + if ($perige <= 98.0) { |
|
| 346 | + $s4 = 20.0; |
|
| 347 | + } else { |
|
| 348 | + $s4 = $perige - 78.0; |
|
| 349 | + } |
|
| 350 | + $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 351 | + $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 352 | + } |
|
| 353 | + $pinvsq = 1.0 / ($sat->deep_arg->aodp * $sat->deep_arg->aodp * |
|
| 354 | + $sat->deep_arg->betao2 * $sat->deep_arg->betao2); |
|
| 355 | + $sat->deep_arg->sing = sin($sat->tle->omegao); |
|
| 356 | + $sat->deep_arg->cosg = cos($sat->tle->omegao); |
|
| 357 | + $tsi = 1.0 / ($sat->deep_arg->aodp - $s4); |
|
| 358 | + $eta = $sat->deep_arg->aodp * $sat->tle->eo * $tsi; |
|
| 359 | + $etasq = $eta * $eta; |
|
| 360 | + $eeta = $sat->tle->eo * $eta; |
|
| 361 | + $psisq = abs(1.0 - $etasq); |
|
| 362 | + $coef = $qoms24 * pow($tsi, 4); |
|
| 363 | + $coef1 = $coef / pow($psisq, 3.5); |
|
| 364 | + $c2 = $coef1 * $sat->deep_arg->xnodp * ($sat->deep_arg->aodp * |
|
| 365 | + (1.0 + 1.5 * $etasq + $eeta * |
|
| 366 | + (4.0 + $etasq)) + 0.75 * Predict::ck2 * $tsi / $psisq * |
|
| 367 | + $sat->sgps->x3thm1 * (8.0 + 3.0 * $etasq * |
|
| 368 | + (8.0 + $etasq))); |
|
| 369 | + $sat->sgps->c1 = $sat->tle->bstar * $c2; |
|
| 370 | + $sat->deep_arg->sinio = sin($sat->tle->xincl); |
|
| 371 | + $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 372 | + $sat->sgps->x1mth2 = 1.0 - $sat->deep_arg->theta2; |
|
| 373 | + $sat->sgps->c4 = 2.0 * $sat->deep_arg->xnodp * $coef1 * |
|
| 374 | + $sat->deep_arg->aodp * $sat->deep_arg->betao2 * |
|
| 375 | + ($eta * (2.0 + 0.5 * $etasq) + $sat->tle->eo * |
|
| 376 | + (0.5 + 2.0 * $etasq) - 2.0 * Predict::ck2 * $tsi / |
|
| 377 | + ($sat->deep_arg->aodp * $psisq) * (-3.0 * $sat->sgps->x3thm1 * |
|
| 378 | + (1.0 - 2.0 * $eeta + $etasq * |
|
| 379 | + (1.5 - 0.5 * $eeta)) + |
|
| 380 | + 0.75 * $sat->sgps->x1mth2 * |
|
| 381 | + (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 382 | + cos(2.0 * $sat->tle->omegao))); |
|
| 383 | + $theta4 = $sat->deep_arg->theta2 * $sat->deep_arg->theta2; |
|
| 384 | + $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->deep_arg->xnodp; |
|
| 385 | + $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 386 | + $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->deep_arg->xnodp; |
|
| 387 | + $sat->deep_arg->xmdot = $sat->deep_arg->xnodp + 0.5 * $temp1 * $sat->deep_arg->betao * |
|
| 388 | + $sat->sgps->x3thm1 + 0.0625 * $temp2 * $sat->deep_arg->betao * |
|
| 389 | + (13.0 - 78.0 * $sat->deep_arg->theta2 + 137.0 * $theta4); |
|
| 390 | + $x1m5th = 1.0 - 5.0 * $sat->deep_arg->theta2; |
|
| 391 | + $sat->deep_arg->omgdot = -0.5 * $temp1 * $x1m5th + 0.0625 * $temp2 * |
|
| 392 | + (7.0 - 114.0 * $sat->deep_arg->theta2 + 395.0 * $theta4) + |
|
| 393 | + $temp3 * (3.0 - 36.0 * $sat->deep_arg->theta2 + 49.0 * $theta4); |
|
| 394 | + $xhdot1 = -$temp1 * $sat->deep_arg->cosio; |
|
| 395 | + $sat->deep_arg->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $sat->deep_arg->theta2) + |
|
| 396 | + 2.0 * $temp3 * (3.0 - 7.0 * $sat->deep_arg->theta2)) * |
|
| 397 | + $sat->deep_arg->cosio; |
|
| 398 | + $sat->sgps->xnodcf = 3.5 * $sat->deep_arg->betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 399 | + $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 400 | + $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->deep_arg->sinio * |
|
| 401 | + (3.0 + 5.0 * $sat->deep_arg->cosio) / (1.0 + $sat->deep_arg->cosio); |
|
| 402 | + $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->deep_arg->sinio; |
|
| 403 | + $sat->sgps->x7thm1 = 7.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 404 | + |
|
| 405 | + /* initialize Deep() */ |
|
| 406 | + $this->Deep(self::dpinit, $sat); |
|
| 407 | + }; /*End of SDP4() initialization */ |
|
| 408 | + |
|
| 409 | + /* Update for secular gravity and atmospheric drag */ |
|
| 410 | + $xmdf = $sat->tle->xmo + $sat->deep_arg->xmdot * $tsince; |
|
| 411 | + $sat->deep_arg->omgadf = $sat->tle->omegao + $sat->deep_arg->omgdot * $tsince; |
|
| 412 | + $xnoddf = $sat->tle->xnodeo + $sat->deep_arg->xnodot * $tsince; |
|
| 413 | + $tsq = $tsince * $tsince; |
|
| 414 | + $sat->deep_arg->xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 415 | + $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 416 | + $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 417 | + $templ = $sat->sgps->t2cof * $tsq; |
|
| 418 | + $sat->deep_arg->xn = $sat->deep_arg->xnodp; |
|
| 419 | + |
|
| 420 | + /* Update for deep-space secular effects */ |
|
| 421 | + $sat->deep_arg->xll = $xmdf; |
|
| 422 | + $sat->deep_arg->t = $tsince; |
|
| 423 | + |
|
| 424 | + $this->Deep(self::dpsec, $sat); |
|
| 425 | + |
|
| 426 | + $xmdf = $sat->deep_arg->xll; |
|
| 427 | + $a = pow(Predict::xke / $sat->deep_arg->xn, Predict::tothrd) * $tempa * $tempa; |
|
| 428 | + $sat->deep_arg->em = $sat->deep_arg->em - $tempe; |
|
| 429 | + $xmam = $xmdf + $sat->deep_arg->xnodp * $templ; |
|
| 430 | + |
|
| 431 | + /* Update for deep-space periodic effects */ |
|
| 432 | + $sat->deep_arg->xll = $xmam; |
|
| 433 | + |
|
| 434 | + $this->Deep(self::dpper, $sat); |
|
| 435 | + |
|
| 436 | + $xmam = $sat->deep_arg->xll; |
|
| 437 | + $xl = $xmam + $sat->deep_arg->omgadf + $sat->deep_arg->xnode; |
|
| 438 | + $beta = sqrt(1.0 - $sat->deep_arg->em * $sat->deep_arg->em); |
|
| 439 | + $sat->deep_arg->xn = Predict::xke / pow($a, 1.5); |
|
| 440 | + |
|
| 441 | + /* Long period periodics */ |
|
| 442 | + $axn = $sat->deep_arg->em * cos($sat->deep_arg->omgadf); |
|
| 443 | + $temp = 1.0 / ($a * $beta * $beta); |
|
| 444 | + $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 445 | + $aynl = $temp * $sat->sgps->aycof; |
|
| 446 | + $xlt = $xl + $xll; |
|
| 447 | + $ayn = $sat->deep_arg->em * sin($sat->deep_arg->omgadf) + $aynl; |
|
| 448 | + |
|
| 449 | + /* Solve Kepler's Equation */ |
|
| 450 | + $capu = Predict_Math::FMod2p ($xlt - $sat->deep_arg->xnode); |
|
| 451 | + $temp2 = $capu; |
|
| 452 | + |
|
| 453 | + $i = 0; |
|
| 454 | + do { |
|
| 455 | + $sinepw = sin($temp2); |
|
| 456 | + $cosepw = cos($temp2); |
|
| 457 | + $temp3 = $axn * $sinepw; |
|
| 458 | + $temp4 = $ayn * $cosepw; |
|
| 459 | + $temp5 = $axn * $cosepw; |
|
| 460 | + $temp6 = $ayn * $sinepw; |
|
| 461 | + $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 462 | + if (abs($epw - $temp2) <= Predict::e6a) { |
|
| 463 | + break; |
|
| 464 | + } |
|
| 465 | + $temp2 = $epw; |
|
| 466 | + } while ($i++ < 10); |
|
| 467 | + |
|
| 468 | + /* Short period preliminary quantities */ |
|
| 469 | + $ecose = $temp5 + $temp6; |
|
| 470 | + $esine = $temp3 - $temp4; |
|
| 471 | + $elsq = $axn * $axn + $ayn * $ayn; |
|
| 472 | + $temp = 1.0 - $elsq; |
|
| 473 | + $pl = $a * $temp; |
|
| 474 | + $r = $a * (1.0 - $ecose); |
|
| 475 | + $temp1 = 1.0 / $r; |
|
| 476 | + $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 477 | + $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 478 | + $temp2 = $a * $temp1; |
|
| 479 | + $betal = sqrt($temp); |
|
| 480 | + $temp3 = 1.0 / (1.0 + $betal); |
|
| 481 | + $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 482 | + $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 483 | + $u = Predict_Math::AcTan($sinu, $cosu); |
|
| 484 | + $sin2u = 2.0 * $sinu * $cosu; |
|
| 485 | + $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 486 | + $temp = 1.0 / $pl; |
|
| 487 | + $temp1 = Predict::ck2 * $temp; |
|
| 488 | + $temp2 = $temp1 * $temp; |
|
| 489 | + |
|
| 490 | + /* Update for short periodics */ |
|
| 491 | + $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 492 | + 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 493 | + $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 494 | + $xnodek = $sat->deep_arg->xnode + 1.5 * $temp2 * $sat->deep_arg->cosio * $sin2u; |
|
| 495 | + $xinck = $sat->deep_arg->xinc + 1.5 * $temp2 * |
|
| 496 | + $sat->deep_arg->cosio * $sat->deep_arg->sinio * $cos2u; |
|
| 497 | + $rdotk = $rdot - $sat->deep_arg->xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 498 | + $rfdotk = $rfdot + $sat->deep_arg->xn * $temp1 * |
|
| 499 | + ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 500 | + |
|
| 501 | + /* Orientation vectors */ |
|
| 502 | + $sinuk = sin($uk); |
|
| 503 | + $cosuk = cos($uk); |
|
| 504 | + $sinik = sin($xinck); |
|
| 505 | + $cosik = cos($xinck); |
|
| 506 | + $sinnok = sin($xnodek); |
|
| 507 | + $cosnok = cos($xnodek); |
|
| 508 | + $xmx = -$sinnok * $cosik; |
|
| 509 | + $xmy = $cosnok * $cosik; |
|
| 510 | + $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 511 | + $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 512 | + $uz = $sinik * $sinuk; |
|
| 513 | + $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 514 | + $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 515 | + $vz = $sinik * $cosuk; |
|
| 516 | + |
|
| 517 | + /* Position and velocity */ |
|
| 518 | + $sat->pos->x = $rk * $ux; |
|
| 519 | + $sat->pos->y = $rk * $uy; |
|
| 520 | + $sat->pos->z = $rk * $uz; |
|
| 521 | + $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 522 | + $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 523 | + $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 524 | + |
|
| 525 | + /* Phase in rads */ |
|
| 526 | + $sat->phase = $xlt - $sat->deep_arg->xnode - $sat->deep_arg->omgadf + Predict::twopi; |
|
| 527 | + if ($sat->phase < 0.0) { |
|
| 528 | + $sat->phase += Predict::twopi; |
|
| 529 | + } |
|
| 530 | + $sat->phase = Predict_Math::FMod2p ($sat->phase); |
|
| 531 | + |
|
| 532 | + $sat->tle->omegao1 = $sat->deep_arg->omgadf; |
|
| 533 | + $sat->tle->xincl1 = $sat->deep_arg->xinc; |
|
| 534 | + $sat->tle->xnodeo1 = $sat->deep_arg->xnode; |
|
| 535 | + } /* SDP4 */ |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + /* DEEP */ |
|
| 539 | + /* This function is used by SDP4 to add lunar and solar */ |
|
| 540 | + /* perturbation effects to deep-space orbit objects. */ |
|
| 541 | + public function Deep($ientry, Predict_Sat $sat) |
|
| 542 | + { |
|
| 543 | + switch ($ientry) { |
|
| 544 | + case self::dpinit : /* Entrance for deep space initialization */ |
|
| 545 | + $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); |
|
| 546 | + $eq = $sat->tle->eo; |
|
| 547 | + $sat->dps->xnq = $sat->deep_arg->xnodp; |
|
| 548 | + $aqnv = 1.0 / $sat->deep_arg->aodp; |
|
| 549 | + $sat->dps->xqncl = $sat->tle->xincl; |
|
| 550 | + $xmao = $sat->tle->xmo; |
|
| 551 | + $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; |
|
| 552 | + $sinq = sin($sat->tle->xnodeo); |
|
| 553 | + $cosq = cos($sat->tle->xnodeo); |
|
| 554 | + $sat->dps->omegaq = $sat->tle->omegao; |
|
| 555 | + $sat->dps->preep = 0; |
|
| 556 | + |
|
| 557 | + /* Initialize lunar solar terms */ |
|
| 558 | + $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 559 | + if ($day != $sat->dps->preep) { |
|
| 560 | + $sat->dps->preep = $day; |
|
| 561 | + $xnodce = 4.5236020 - 9.2422029E-4 * $day; |
|
| 562 | + $stem = sin($xnodce); |
|
| 563 | + $ctem = cos($xnodce); |
|
| 564 | + $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; |
|
| 565 | + $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); |
|
| 566 | + $sat->dps->zsinhl = 0.089683511 * $stem / $sat->dps->zsinil; |
|
| 567 | + $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); |
|
| 568 | + $c = 4.7199672 + 0.22997150 * $day; |
|
| 569 | + $gam = 5.8351514 + 0.0019443680 * $day; |
|
| 570 | + $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); |
|
| 571 | + $zx = 0.39785416 * $stem / $sat->dps->zsinil; |
|
| 572 | + $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; |
|
| 573 | + $zx = Predict_Math::AcTan($zx, $zy); |
|
| 574 | + $zx = $gam + $zx - $xnodce; |
|
| 575 | + $sat->dps->zcosgl = cos($zx); |
|
| 576 | + $sat->dps->zsingl = sin($zx); |
|
| 577 | + $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; |
|
| 578 | + $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); |
|
| 579 | + } /* End if(day != preep) */ |
|
| 580 | + |
|
| 581 | + /* Do solar terms */ |
|
| 582 | + $sat->dps->savtsn = 1E20; |
|
| 583 | + $zcosg = Predict::zcosgs; |
|
| 584 | + $zsing = Predict::zsings; |
|
| 585 | + $zcosi = Predict::zcosis; |
|
| 586 | + $zsini = Predict::zsinis; |
|
| 587 | + $zcosh = $cosq; |
|
| 588 | + $zsinh = $sinq; |
|
| 589 | + $cc = Predict::c1ss; |
|
| 590 | + $zn = Predict::zns; |
|
| 591 | + $ze = Predict::zes; |
|
| 592 | + $zmo = $sat->dps->zmos; |
|
| 593 | + $xnoi = 1.0 / $sat->dps->xnq; |
|
| 594 | + |
|
| 595 | + /* Loop breaks when Solar terms are done a second */ |
|
| 596 | + /* time, after Lunar terms are initialized */ |
|
| 597 | + for(;;) { |
|
| 598 | + /* Solar terms done again after Lunar terms are done */ |
|
| 599 | + $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; |
|
| 600 | + $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; |
|
| 601 | + $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; |
|
| 602 | + $a8 = $zsing * $zsini; |
|
| 603 | + $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; |
|
| 604 | + $a10 = $zcosg * $zsini; |
|
| 605 | + $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; |
|
| 606 | + $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; |
|
| 607 | + $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; |
|
| 608 | + $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; |
|
| 609 | + $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; |
|
| 610 | + $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; |
|
| 611 | + $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; |
|
| 612 | + $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; |
|
| 613 | + $x5 = $a5 * $sat->deep_arg->sing; |
|
| 614 | + $x6 = $a6 * $sat->deep_arg->sing; |
|
| 615 | + $x7 = $a5 * $sat->deep_arg->cosg; |
|
| 616 | + $x8 = $a6 * $sat->deep_arg->cosg; |
|
| 617 | + $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; |
|
| 618 | + $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; |
|
| 619 | + $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; |
|
| 620 | + $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; |
|
| 621 | + $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; |
|
| 622 | + $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; |
|
| 623 | + $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); |
|
| 624 | + $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * |
|
| 625 | + (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); |
|
| 626 | + $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); |
|
| 627 | + $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); |
|
| 628 | + $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * |
|
| 629 | + (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); |
|
| 630 | + $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); |
|
| 631 | + $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; |
|
| 632 | + $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; |
|
| 633 | + $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; |
|
| 634 | + $s3 = $cc * $xnoi; |
|
| 635 | + $s2 = -0.5 * $s3 / $sat->deep_arg->betao; |
|
| 636 | + $s4 = $s3 * $sat->deep_arg->betao; |
|
| 637 | + $s1 = -15 * $eq * $s4; |
|
| 638 | + $s5 = $x1 * $x3 + $x2 * $x4; |
|
| 639 | + $s6 = $x2 * $x3 + $x1 * $x4; |
|
| 640 | + $s7 = $x2 * $x4 - $x1 * $x3; |
|
| 641 | + $se = $s1 * $zn * $s5; |
|
| 642 | + $si = $s2 * $zn * ($z11 + $z13); |
|
| 643 | + $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); |
|
| 644 | + $sgh = $s4 * $zn * ($z31 + $z33 - 6); |
|
| 645 | + $sh = -$zn * $s2 * ($z21 + $z23); |
|
| 646 | + if ($sat->dps->xqncl < 5.2359877E-2) { |
|
| 647 | + $sh = 0; |
|
| 648 | + } |
|
| 649 | + $sat->dps->ee2 = 2 * $s1 * $s6; |
|
| 650 | + $sat->dps->e3 = 2 * $s1 * $s7; |
|
| 651 | + $sat->dps->xi2 = 2 * $s2 * $z12; |
|
| 652 | + $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); |
|
| 653 | + $sat->dps->xl2 = -2 * $s3 * $z2; |
|
| 654 | + $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); |
|
| 655 | + $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; |
|
| 656 | + $sat->dps->xgh2 = 2 * $s4 * $z32; |
|
| 657 | + $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); |
|
| 658 | + $sat->dps->xgh4 = -18 * $s4 * $ze; |
|
| 659 | + $sat->dps->xh2 = -2 * $s2 * $z22; |
|
| 660 | + $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); |
|
| 661 | + |
|
| 662 | + if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { |
|
| 663 | + break; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + /* Do lunar terms */ |
|
| 667 | + $sat->dps->sse = $se; |
|
| 668 | + $sat->dps->ssi = $si; |
|
| 669 | + $sat->dps->ssl = $sl; |
|
| 670 | + $sat->dps->ssh = $sh / $sat->deep_arg->sinio; |
|
| 671 | + $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; |
|
| 672 | + $sat->dps->se2 = $sat->dps->ee2; |
|
| 673 | + $sat->dps->si2 = $sat->dps->xi2; |
|
| 674 | + $sat->dps->sl2 = $sat->dps->xl2; |
|
| 675 | + $sat->dps->sgh2 = $sat->dps->xgh2; |
|
| 676 | + $sat->dps->sh2 = $sat->dps->xh2; |
|
| 677 | + $sat->dps->se3 = $sat->dps->e3; |
|
| 678 | + $sat->dps->si3 = $sat->dps->xi3; |
|
| 679 | + $sat->dps->sl3 = $sat->dps->xl3; |
|
| 680 | + $sat->dps->sgh3 = $sat->dps->xgh3; |
|
| 681 | + $sat->dps->sh3 = $sat->dps->xh3; |
|
| 682 | + $sat->dps->sl4 = $sat->dps->xl4; |
|
| 683 | + $sat->dps->sgh4 = $sat->dps->xgh4; |
|
| 684 | + $zcosg = $sat->dps->zcosgl; |
|
| 685 | + $zsing = $sat->dps->zsingl; |
|
| 686 | + $zcosi = $sat->dps->zcosil; |
|
| 687 | + $zsini = $sat->dps->zsinil; |
|
| 688 | + $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; |
|
| 689 | + $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; |
|
| 690 | + $zn = Predict::znl; |
|
| 691 | + $cc = Predict::c1l; |
|
| 692 | + $ze = Predict::zel; |
|
| 693 | + $zmo = $sat->dps->zmol; |
|
| 694 | + $sat->flags |= self::LUNAR_TERMS_DONE_FLAG; |
|
| 695 | + } /* End of for(;;) */ |
|
| 696 | + |
|
| 697 | + $sat->dps->sse = $sat->dps->sse + $se; |
|
| 698 | + $sat->dps->ssi = $sat->dps->ssi + $si; |
|
| 699 | + $sat->dps->ssl = $sat->dps->ssl + $sl; |
|
| 700 | + $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; |
|
| 701 | + $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; |
|
| 702 | + |
|
| 703 | + /* Geopotential resonance initialization for 12 hour orbits */ |
|
| 704 | + $sat->flags &= ~self::RESONANCE_FLAG; |
|
| 705 | + $sat->flags &= ~self::SYNCHRONOUS_FLAG; |
|
| 706 | + |
|
| 707 | + if (!(($sat->dps->xnq < 0.0052359877) && ($sat->dps->xnq > 0.0034906585))) { |
|
| 708 | + if( ($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924) ) { |
|
| 709 | + return; |
|
| 710 | + } |
|
| 711 | + if ($eq < 0.5) { |
|
| 712 | + return; |
|
| 713 | + } |
|
| 714 | + $sat->flags |= self::RESONANCE_FLAG; |
|
| 715 | + $eoc = $eq * $sat->deep_arg->eosq; |
|
| 716 | + $g201 = -0.306 - ($eq - 0.64) * 0.440; |
|
| 717 | + if ($eq <= 0.65) { |
|
| 718 | + $g211 = 3.616 - 13.247 * $eq + 16.290 * $sat->deep_arg->eosq; |
|
| 719 | + $g310 = -19.302 + 117.390 * $eq - 228.419 * |
|
| 720 | + $sat->deep_arg->eosq + 156.591 * $eoc; |
|
| 721 | + $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * |
|
| 722 | + $sat->deep_arg->eosq + 146.5816 * $eoc; |
|
| 723 | + $g410 = -41.122 + 242.694 * $eq - 471.094 * |
|
| 724 | + $sat->deep_arg->eosq + 313.953 * $eoc; |
|
| 725 | + $g422 = -146.407 + 841.880 * $eq - 1629.014 * |
|
| 726 | + $sat->deep_arg->eosq + 1083.435 * $eoc; |
|
| 727 | + $g520 = -532.114 + 3017.977 * $eq - 5740 * |
|
| 728 | + $sat->deep_arg->eosq + 3708.276 * $eoc; |
|
| 729 | + } else { |
|
| 730 | + $g211 = -72.099 + 331.819 * $eq - 508.738 * |
|
| 731 | + $sat->deep_arg->eosq + 266.724 * $eoc; |
|
| 732 | + $g310 = -346.844 + 1582.851 * $eq - 2415.925 * |
|
| 733 | + $sat->deep_arg->eosq + 1246.113 * $eoc; |
|
| 734 | + $g322 = -342.585 + 1554.908 * $eq - 2366.899 * |
|
| 735 | + $sat->deep_arg->eosq + 1215.972 * $eoc; |
|
| 736 | + $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * |
|
| 737 | + $sat->deep_arg->eosq + 3651.957 * $eoc; |
|
| 738 | + $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * |
|
| 739 | + $sat->deep_arg->eosq+ 12422.52 * $eoc; |
|
| 740 | + if ($eq <= 0.715) { |
|
| 741 | + $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; |
|
| 742 | + } else { |
|
| 743 | + $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * |
|
| 744 | + $sat->deep_arg->eosq + 31324.56 * $eoc; |
|
| 745 | + } |
|
| 746 | + } /* End if (eq <= 0.65) */ |
|
| 747 | + |
|
| 748 | + if ($eq < 0.7) { |
|
| 749 | + $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * |
|
| 750 | + $sat->deep_arg->eosq + 5542.21 * $eoc; |
|
| 751 | + $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * |
|
| 752 | + $sat->deep_arg->eosq + 5337.524 * $eoc; |
|
| 753 | + $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
|
| 754 | + $sat->deep_arg->eosq + 5341.4 * $eoc; |
|
| 755 | + } |
|
| 756 | + else { |
|
| 757 | + $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
|
| 758 | + $sat->deep_arg->eosq + 109377.94 * $eoc; |
|
| 759 | + $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
|
| 760 | + $sat->deep_arg->eosq + 146349.42 * $eoc; |
|
| 761 | + $g532 = -40023.88 + 170470.89 * $eq - 242699.48* |
|
| 762 | + $sat->deep_arg->eosq + 115605.82 * $eoc; |
|
| 763 | + } /* End if (eq <= 0.7) */ |
|
| 764 | + |
|
| 765 | + $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; |
|
| 766 | + $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | + $f221 = 1.5 * $sini2; |
|
| 768 | + $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * |
|
| 769 | + $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 770 | + $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2* |
|
| 771 | + $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 772 | + $f441 = 35 * $sini2 * $f220; |
|
| 773 | + $f442 = 39.3750 * $sini2 * $sini2; |
|
| 774 | + $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * |
|
| 775 | + $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + |
|
| 776 | + 6 * $sat->deep_arg->theta2)); |
|
| 777 | + $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * |
|
| 778 | + $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | + * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); |
|
| 780 | + $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * |
|
| 781 | + $sat->deep_arg->cosio + $sat->deep_arg->theta2 * |
|
| 782 | + (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); |
|
| 783 | + $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + |
|
| 784 | + $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * |
|
| 785 | + $sat->deep_arg->theta2)); |
|
| 786 | + $xno2 = $sat->dps->xnq * $sat->dps->xnq; |
|
| 787 | + $ainv2 = $aqnv * $aqnv; |
|
| 788 | + $temp1 = 3 * $xno2 * $ainv2; |
|
| 789 | + $temp = $temp1 * Predict::root22; |
|
| 790 | + $sat->dps->d2201 = $temp * $f220 * $g201; |
|
| 791 | + $sat->dps->d2211 = $temp * $f221 * $g211; |
|
| 792 | + $temp1 = $temp1 * $aqnv; |
|
| 793 | + $temp = $temp1 * Predict::root32; |
|
| 794 | + $sat->dps->d3210 = $temp * $f321 * $g310; |
|
| 795 | + $sat->dps->d3222 = $temp * $f322 * $g322; |
|
| 796 | + $temp1 = $temp1 * $aqnv; |
|
| 797 | + $temp = 2 * $temp1 * Predict::root44; |
|
| 798 | + $sat->dps->d4410 = $temp * $f441 * $g410; |
|
| 799 | + $sat->dps->d4422 = $temp * $f442 * $g422; |
|
| 800 | + $temp1 = $temp1 * $aqnv; |
|
| 801 | + $temp = $temp1 * Predict::root52; |
|
| 802 | + $sat->dps->d5220 = $temp * $f522 * $g520; |
|
| 803 | + $sat->dps->d5232 = $temp * $f523 * $g532; |
|
| 804 | + $temp = 2 * $temp1 * Predict::root54; |
|
| 805 | + $sat->dps->d5421 = $temp * $f542 * $g521; |
|
| 806 | + $sat->dps->d5433 = $temp * $f543 * $g533; |
|
| 807 | + $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; |
|
| 808 | + $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + |
|
| 809 | + $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; |
|
| 810 | + $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssh + $sat->dps->ssh; |
|
| 811 | + } else { |
|
| 812 | + $sat->flags |= self::RESONANCE_FLAG; |
|
| 813 | + $sat->flags |= self::SYNCHRONOUS_FLAG; |
|
| 814 | + /* Synchronous resonance terms initialization */ |
|
| 815 | + $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); |
|
| 816 | + $g310 = 1 + 2 * $sat->deep_arg->eosq; |
|
| 817 | + $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); |
|
| 818 | + $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); |
|
| 819 | + $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * |
|
| 820 | + (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); |
|
| 821 | + $f330 = 1 + $sat->deep_arg->cosio; |
|
| 822 | + $f330 = 1.875 * $f330 * $f330 * $f330; |
|
| 823 | + $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; |
|
| 824 | + $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; |
|
| 825 | + $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; |
|
| 826 | + $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; |
|
| 827 | + $sat->dps->fasx2 = 0.13130908; |
|
| 828 | + $sat->dps->fasx4 = 2.8843198; |
|
| 829 | + $sat->dps->fasx6 = 0.37448087; |
|
| 830 | + $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->omegao - $sat->dps->thgr; |
|
| 831 | + $bfact = $sat->deep_arg->xmdot + $xpidot - Predict::thdt; |
|
| 832 | + $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssg + $sat->dps->ssh; |
|
| 833 | + } /* End if( !(xnq < 0.0052359877) && (xnq > 0.0034906585) ) */ |
|
| 834 | + |
|
| 835 | + $sat->dps->xfact = $bfact - $sat->dps->xnq; |
|
| 836 | + |
|
| 837 | + /* Initialize integrator */ |
|
| 838 | + $sat->dps->xli = $sat->dps->xlamo; |
|
| 839 | + $sat->dps->xni = $sat->dps->xnq; |
|
| 840 | + $sat->dps->atime = 0; |
|
| 841 | + $sat->dps->stepp = 720; |
|
| 842 | + $sat->dps->stepn = -720; |
|
| 843 | + $sat->dps->step2 = 259200; |
|
| 844 | + /* End case self::dpinit: */ |
|
| 845 | + return; |
|
| 846 | + |
|
| 847 | + case self::dpsec: /* Entrance for deep space secular effects */ |
|
| 848 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; |
|
| 849 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; |
|
| 850 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; |
|
| 851 | + $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; |
|
| 852 | + $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; |
|
| 853 | + if ($sat->deep_arg->xinc < 0) { |
|
| 854 | + $sat->deep_arg->xinc = -$sat->deep_arg->xinc; |
|
| 855 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; |
|
| 856 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; |
|
| 857 | + } |
|
| 858 | + if(~$sat->flags & self::RESONANCE_FLAG ) { |
|
| 859 | + return; |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + do { |
|
| 863 | + if ( ($sat->dps->atime == 0) || |
|
| 864 | + (($sat->deep_arg->t >= 0) && ($sat->dps->atime < 0)) || |
|
| 865 | + (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0)) ) { |
|
| 866 | + /* Epoch restart */ |
|
| 867 | + if ($sat->deep_arg->t >= 0) { |
|
| 868 | + $delt = $sat->dps->stepp; |
|
| 869 | + } else { |
|
| 870 | + $delt = $sat->dps->stepn; |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + $sat->dps->atime = 0; |
|
| 874 | + $sat->dps->xni = $sat->dps->xnq; |
|
| 875 | + $sat->dps->xli = $sat->dps->xlamo; |
|
| 876 | + } else { |
|
| 877 | + if (abs($sat->deep_arg->t) >= abs($sat->dps->atime)) { |
|
| 878 | + if ($sat->deep_arg->t > 0) { |
|
| 879 | + $delt = $sat->dps->stepp; |
|
| 880 | + } else { |
|
| 881 | + $delt = $sat->dps->stepn; |
|
| 882 | + } |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + do { |
|
| 887 | + if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { |
|
| 888 | + $sat->flags |= self::DO_LOOP_FLAG; |
|
| 889 | + $sat->flags &= ~self::EPOCH_RESTART_FLAG; |
|
| 890 | + } |
|
| 891 | + else { |
|
| 892 | + $ft = $sat->deep_arg->t - $sat->dps->atime; |
|
| 893 | + $sat->flags &= ~self::DO_LOOP_FLAG; |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + if (abs($sat->deep_arg->t) < abs($sat->dps->atime)) { |
|
| 897 | + if ($sat->deep_arg->t >= 0) { |
|
| 898 | + $delt = $sat->dps->stepn; |
|
| 899 | + } else { |
|
| 900 | + $delt = $sat->dps->stepp; |
|
| 901 | + } |
|
| 902 | + $sat->flags |= (self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG); |
|
| 903 | + } |
|
| 904 | + |
|
| 905 | + /* Dot terms calculated */ |
|
| 906 | + if ($sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 907 | + $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | + + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | + $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | + + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 911 | + } else { |
|
| 912 | + $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; |
|
| 913 | + $x2omi = $xomi + $xomi; |
|
| 914 | + $x2li = $sat->dps->xli + $sat->dps->xli; |
|
| 915 | + $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | + + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) |
|
| 917 | + + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | + + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | + + $sat->dps->d4410 * sin($x2omi + $x2li- Predict::g44) |
|
| 920 | + + $sat->dps->d4422 * sin($x2li- Predict::g44) |
|
| 921 | + + $sat->dps->d5220 * sin($xomi + $sat->dps->xli- Predict::g52) |
|
| 922 | + + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli- Predict::g52) |
|
| 923 | + + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) |
|
| 924 | + + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | + $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli- Predict::g22) |
|
| 926 | + + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) |
|
| 927 | + + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | + + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | + + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | + + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | + + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) |
|
| 932 | + + $sat->dps->d4422 * cos($x2li - Predict::g44) |
|
| 933 | + + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) |
|
| 934 | + + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); |
|
| 935 | + } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ |
|
| 936 | + |
|
| 937 | + $xldot = $sat->dps->xni + $sat->dps->xfact; |
|
| 938 | + $xnddt = $xnddt * $xldot; |
|
| 939 | + |
|
| 940 | + if ($sat->flags & self::DO_LOOP_FLAG) { |
|
| 941 | + $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; |
|
| 942 | + $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; |
|
| 943 | + $sat->dps->atime = $sat->dps->atime + $delt; |
|
| 944 | + } |
|
| 945 | + } while (($sat->flags & self::DO_LOOP_FLAG) && |
|
| 946 | + (~$sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 947 | + } |
|
| 948 | + while (($sat->flags & self::DO_LOOP_FLAG) && ($sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 949 | + |
|
| 950 | + $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; |
|
| 951 | + $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; |
|
| 952 | + $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; |
|
| 953 | + |
|
| 954 | + if (~$sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 955 | + $sat->deep_arg->xll = $xl + $temp + $temp; |
|
| 956 | + } else { |
|
| 957 | + $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + return; |
|
| 961 | + /* End case dpsec: */ |
|
| 962 | + |
|
| 963 | + case self::dpper: /* Entrance for lunar-solar periodics */ |
|
| 964 | + $sinis = sin($sat->deep_arg->xinc); |
|
| 965 | + $cosis = cos($sat->deep_arg->xinc); |
|
| 966 | + if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { |
|
| 967 | + $sat->dps->savtsn = $sat->deep_arg->t; |
|
| 968 | + $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; |
|
| 969 | + $zf = $zm + 2 * Predict::zes * sin($zm); |
|
| 970 | + $sinzf = sin($zf); |
|
| 971 | + $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 972 | + $f3 = -0.5 * $sinzf * cos($zf); |
|
| 973 | + $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; |
|
| 974 | + $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; |
|
| 975 | + $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; |
|
| 976 | + $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; |
|
| 977 | + $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; |
|
| 978 | + $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; |
|
| 979 | + $zf = $zm + 2 * Predict::zel * sin($zm); |
|
| 980 | + $sinzf = sin($zf); |
|
| 981 | + $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 982 | + $f3 = -0.5 * $sinzf * cos($zf); |
|
| 983 | + $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; |
|
| 984 | + $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; |
|
| 985 | + $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; |
|
| 986 | + $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; |
|
| 987 | + $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; |
|
| 988 | + $sat->dps->pe = $ses + $sel; |
|
| 989 | + $sat->dps->pinc = $sis + $sil; |
|
| 990 | + $sat->dps->pl = $sls + $sll; |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + $pgh = $sat->dps->sghs + $sat->dps->sghl; |
|
| 994 | + $ph = $sat->dps->shs + $sat->dps->sh1; |
|
| 995 | + $sat->deep_arg->xinc = $sat->deep_arg->xinc + $sat->dps->pinc; |
|
| 996 | + $sat->deep_arg->em = $sat->deep_arg->em + $sat->dps->pe; |
|
| 997 | + |
|
| 998 | + if ($sat->dps->xqncl >= 0.2) { |
|
| 999 | + /* Apply periodics directly */ |
|
| 1000 | + $ph = $ph / $sat->deep_arg->sinio; |
|
| 1001 | + $pgh = $pgh - $sat->deep_arg->cosio * $ph; |
|
| 1002 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; |
|
| 1003 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; |
|
| 1004 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1005 | + } else { |
|
| 1006 | + /* Apply periodics with Lyddane modification */ |
|
| 1007 | + $sinok = sin($sat->deep_arg->xnode); |
|
| 1008 | + $cosok = cos($sat->deep_arg->xnode); |
|
| 1009 | + $alfdp = $sinis * $sinok; |
|
| 1010 | + $betdp = $sinis * $cosok; |
|
| 1011 | + $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; |
|
| 1012 | + $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; |
|
| 1013 | + $alfdp = $alfdp + $dalf; |
|
| 1014 | + $betdp = $betdp + $dbet; |
|
| 1015 | + $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); |
|
| 1016 | + $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; |
|
| 1017 | + $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; |
|
| 1018 | + $xls = $xls + $dls; |
|
| 1019 | + $xnoh = $sat->deep_arg->xnode; |
|
| 1020 | + $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); |
|
| 1021 | + |
|
| 1022 | + /* This is a patch to Lyddane modification */ |
|
| 1023 | + /* suggested by Rob Matson. */ |
|
| 1024 | + if(abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1025 | + if ($sat->deep_arg->xnode < $xnoh) { |
|
| 1026 | + $sat->deep_arg->xnode += Predict::twopi; |
|
| 1027 | + } else { |
|
| 1028 | + $sat->deep_arg->xnode -= Predict::twopi; |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 1031 | + |
|
| 1032 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1033 | + $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * |
|
| 1034 | + $sat->deep_arg->xnode; |
|
| 1035 | + } /* End case dpper: */ |
|
| 1036 | + return; |
|
| 1037 | + |
|
| 1038 | + } /* End switch(ientry) */ |
|
| 1039 | + |
|
| 1040 | + } /* End of Deep() */ |
|
| 1041 | + |
|
| 1042 | + /** |
|
| 1043 | + * Singleton |
|
| 1044 | + * |
|
| 1045 | + * @param Predict_Sat $sat The current satellite data instance |
|
| 1046 | + * |
|
| 1047 | + * @return Predict_SGPSDP |
|
| 1048 | + */ |
|
| 1049 | + public static function getInstance(Predict_Sat $sat) |
|
| 1050 | + { |
|
| 1051 | + static $instances = array(); |
|
| 1052 | + $catnr = $sat->tle->catnr; |
|
| 1053 | + if (!isset($instances[$catnr])) { |
|
| 1054 | + $instances[$catnr] = new self(); |
|
| 1055 | + } |
|
| 1056 | + return $instances[$catnr]; |
|
| 1057 | + } |
|
| 1058 | 1058 | } |
| 1059 | 1059 | ?> |
@@ -541,499 +541,499 @@ |
||
| 541 | 541 | public function Deep($ientry, Predict_Sat $sat) |
| 542 | 542 | { |
| 543 | 543 | switch ($ientry) { |
| 544 | - case self::dpinit : /* Entrance for deep space initialization */ |
|
| 545 | - $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); |
|
| 546 | - $eq = $sat->tle->eo; |
|
| 547 | - $sat->dps->xnq = $sat->deep_arg->xnodp; |
|
| 548 | - $aqnv = 1.0 / $sat->deep_arg->aodp; |
|
| 549 | - $sat->dps->xqncl = $sat->tle->xincl; |
|
| 550 | - $xmao = $sat->tle->xmo; |
|
| 551 | - $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; |
|
| 552 | - $sinq = sin($sat->tle->xnodeo); |
|
| 553 | - $cosq = cos($sat->tle->xnodeo); |
|
| 554 | - $sat->dps->omegaq = $sat->tle->omegao; |
|
| 555 | - $sat->dps->preep = 0; |
|
| 556 | - |
|
| 557 | - /* Initialize lunar solar terms */ |
|
| 558 | - $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 559 | - if ($day != $sat->dps->preep) { |
|
| 560 | - $sat->dps->preep = $day; |
|
| 561 | - $xnodce = 4.5236020 - 9.2422029E-4 * $day; |
|
| 562 | - $stem = sin($xnodce); |
|
| 563 | - $ctem = cos($xnodce); |
|
| 564 | - $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; |
|
| 565 | - $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); |
|
| 566 | - $sat->dps->zsinhl = 0.089683511 * $stem / $sat->dps->zsinil; |
|
| 567 | - $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); |
|
| 568 | - $c = 4.7199672 + 0.22997150 * $day; |
|
| 569 | - $gam = 5.8351514 + 0.0019443680 * $day; |
|
| 570 | - $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); |
|
| 571 | - $zx = 0.39785416 * $stem / $sat->dps->zsinil; |
|
| 572 | - $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; |
|
| 573 | - $zx = Predict_Math::AcTan($zx, $zy); |
|
| 574 | - $zx = $gam + $zx - $xnodce; |
|
| 575 | - $sat->dps->zcosgl = cos($zx); |
|
| 576 | - $sat->dps->zsingl = sin($zx); |
|
| 577 | - $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; |
|
| 578 | - $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); |
|
| 579 | - } /* End if(day != preep) */ |
|
| 580 | - |
|
| 581 | - /* Do solar terms */ |
|
| 582 | - $sat->dps->savtsn = 1E20; |
|
| 583 | - $zcosg = Predict::zcosgs; |
|
| 584 | - $zsing = Predict::zsings; |
|
| 585 | - $zcosi = Predict::zcosis; |
|
| 586 | - $zsini = Predict::zsinis; |
|
| 587 | - $zcosh = $cosq; |
|
| 588 | - $zsinh = $sinq; |
|
| 589 | - $cc = Predict::c1ss; |
|
| 590 | - $zn = Predict::zns; |
|
| 591 | - $ze = Predict::zes; |
|
| 592 | - $zmo = $sat->dps->zmos; |
|
| 593 | - $xnoi = 1.0 / $sat->dps->xnq; |
|
| 594 | - |
|
| 595 | - /* Loop breaks when Solar terms are done a second */ |
|
| 596 | - /* time, after Lunar terms are initialized */ |
|
| 597 | - for(;;) { |
|
| 598 | - /* Solar terms done again after Lunar terms are done */ |
|
| 599 | - $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; |
|
| 600 | - $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; |
|
| 601 | - $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; |
|
| 602 | - $a8 = $zsing * $zsini; |
|
| 603 | - $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; |
|
| 604 | - $a10 = $zcosg * $zsini; |
|
| 605 | - $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; |
|
| 606 | - $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; |
|
| 607 | - $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; |
|
| 608 | - $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; |
|
| 609 | - $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; |
|
| 610 | - $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; |
|
| 611 | - $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; |
|
| 612 | - $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; |
|
| 613 | - $x5 = $a5 * $sat->deep_arg->sing; |
|
| 614 | - $x6 = $a6 * $sat->deep_arg->sing; |
|
| 615 | - $x7 = $a5 * $sat->deep_arg->cosg; |
|
| 616 | - $x8 = $a6 * $sat->deep_arg->cosg; |
|
| 617 | - $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; |
|
| 618 | - $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; |
|
| 619 | - $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; |
|
| 620 | - $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; |
|
| 621 | - $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; |
|
| 622 | - $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; |
|
| 623 | - $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); |
|
| 624 | - $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * |
|
| 625 | - (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); |
|
| 626 | - $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); |
|
| 627 | - $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); |
|
| 628 | - $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * |
|
| 629 | - (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); |
|
| 630 | - $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); |
|
| 631 | - $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; |
|
| 632 | - $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; |
|
| 633 | - $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; |
|
| 634 | - $s3 = $cc * $xnoi; |
|
| 635 | - $s2 = -0.5 * $s3 / $sat->deep_arg->betao; |
|
| 636 | - $s4 = $s3 * $sat->deep_arg->betao; |
|
| 637 | - $s1 = -15 * $eq * $s4; |
|
| 638 | - $s5 = $x1 * $x3 + $x2 * $x4; |
|
| 639 | - $s6 = $x2 * $x3 + $x1 * $x4; |
|
| 640 | - $s7 = $x2 * $x4 - $x1 * $x3; |
|
| 641 | - $se = $s1 * $zn * $s5; |
|
| 642 | - $si = $s2 * $zn * ($z11 + $z13); |
|
| 643 | - $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); |
|
| 644 | - $sgh = $s4 * $zn * ($z31 + $z33 - 6); |
|
| 645 | - $sh = -$zn * $s2 * ($z21 + $z23); |
|
| 646 | - if ($sat->dps->xqncl < 5.2359877E-2) { |
|
| 647 | - $sh = 0; |
|
| 648 | - } |
|
| 649 | - $sat->dps->ee2 = 2 * $s1 * $s6; |
|
| 650 | - $sat->dps->e3 = 2 * $s1 * $s7; |
|
| 651 | - $sat->dps->xi2 = 2 * $s2 * $z12; |
|
| 652 | - $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); |
|
| 653 | - $sat->dps->xl2 = -2 * $s3 * $z2; |
|
| 654 | - $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); |
|
| 655 | - $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; |
|
| 656 | - $sat->dps->xgh2 = 2 * $s4 * $z32; |
|
| 657 | - $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); |
|
| 658 | - $sat->dps->xgh4 = -18 * $s4 * $ze; |
|
| 659 | - $sat->dps->xh2 = -2 * $s2 * $z22; |
|
| 660 | - $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); |
|
| 661 | - |
|
| 662 | - if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { |
|
| 663 | - break; |
|
| 664 | - } |
|
| 665 | - |
|
| 666 | - /* Do lunar terms */ |
|
| 667 | - $sat->dps->sse = $se; |
|
| 668 | - $sat->dps->ssi = $si; |
|
| 669 | - $sat->dps->ssl = $sl; |
|
| 670 | - $sat->dps->ssh = $sh / $sat->deep_arg->sinio; |
|
| 671 | - $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; |
|
| 672 | - $sat->dps->se2 = $sat->dps->ee2; |
|
| 673 | - $sat->dps->si2 = $sat->dps->xi2; |
|
| 674 | - $sat->dps->sl2 = $sat->dps->xl2; |
|
| 675 | - $sat->dps->sgh2 = $sat->dps->xgh2; |
|
| 676 | - $sat->dps->sh2 = $sat->dps->xh2; |
|
| 677 | - $sat->dps->se3 = $sat->dps->e3; |
|
| 678 | - $sat->dps->si3 = $sat->dps->xi3; |
|
| 679 | - $sat->dps->sl3 = $sat->dps->xl3; |
|
| 680 | - $sat->dps->sgh3 = $sat->dps->xgh3; |
|
| 681 | - $sat->dps->sh3 = $sat->dps->xh3; |
|
| 682 | - $sat->dps->sl4 = $sat->dps->xl4; |
|
| 683 | - $sat->dps->sgh4 = $sat->dps->xgh4; |
|
| 684 | - $zcosg = $sat->dps->zcosgl; |
|
| 685 | - $zsing = $sat->dps->zsingl; |
|
| 686 | - $zcosi = $sat->dps->zcosil; |
|
| 687 | - $zsini = $sat->dps->zsinil; |
|
| 688 | - $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; |
|
| 689 | - $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; |
|
| 690 | - $zn = Predict::znl; |
|
| 691 | - $cc = Predict::c1l; |
|
| 692 | - $ze = Predict::zel; |
|
| 693 | - $zmo = $sat->dps->zmol; |
|
| 694 | - $sat->flags |= self::LUNAR_TERMS_DONE_FLAG; |
|
| 695 | - } /* End of for(;;) */ |
|
| 696 | - |
|
| 697 | - $sat->dps->sse = $sat->dps->sse + $se; |
|
| 698 | - $sat->dps->ssi = $sat->dps->ssi + $si; |
|
| 699 | - $sat->dps->ssl = $sat->dps->ssl + $sl; |
|
| 700 | - $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; |
|
| 701 | - $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; |
|
| 702 | - |
|
| 703 | - /* Geopotential resonance initialization for 12 hour orbits */ |
|
| 704 | - $sat->flags &= ~self::RESONANCE_FLAG; |
|
| 705 | - $sat->flags &= ~self::SYNCHRONOUS_FLAG; |
|
| 706 | - |
|
| 707 | - if (!(($sat->dps->xnq < 0.0052359877) && ($sat->dps->xnq > 0.0034906585))) { |
|
| 708 | - if( ($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924) ) { |
|
| 709 | - return; |
|
| 710 | - } |
|
| 711 | - if ($eq < 0.5) { |
|
| 712 | - return; |
|
| 713 | - } |
|
| 714 | - $sat->flags |= self::RESONANCE_FLAG; |
|
| 715 | - $eoc = $eq * $sat->deep_arg->eosq; |
|
| 716 | - $g201 = -0.306 - ($eq - 0.64) * 0.440; |
|
| 717 | - if ($eq <= 0.65) { |
|
| 718 | - $g211 = 3.616 - 13.247 * $eq + 16.290 * $sat->deep_arg->eosq; |
|
| 719 | - $g310 = -19.302 + 117.390 * $eq - 228.419 * |
|
| 720 | - $sat->deep_arg->eosq + 156.591 * $eoc; |
|
| 721 | - $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * |
|
| 722 | - $sat->deep_arg->eosq + 146.5816 * $eoc; |
|
| 723 | - $g410 = -41.122 + 242.694 * $eq - 471.094 * |
|
| 724 | - $sat->deep_arg->eosq + 313.953 * $eoc; |
|
| 725 | - $g422 = -146.407 + 841.880 * $eq - 1629.014 * |
|
| 726 | - $sat->deep_arg->eosq + 1083.435 * $eoc; |
|
| 727 | - $g520 = -532.114 + 3017.977 * $eq - 5740 * |
|
| 728 | - $sat->deep_arg->eosq + 3708.276 * $eoc; |
|
| 729 | - } else { |
|
| 730 | - $g211 = -72.099 + 331.819 * $eq - 508.738 * |
|
| 731 | - $sat->deep_arg->eosq + 266.724 * $eoc; |
|
| 732 | - $g310 = -346.844 + 1582.851 * $eq - 2415.925 * |
|
| 733 | - $sat->deep_arg->eosq + 1246.113 * $eoc; |
|
| 734 | - $g322 = -342.585 + 1554.908 * $eq - 2366.899 * |
|
| 735 | - $sat->deep_arg->eosq + 1215.972 * $eoc; |
|
| 736 | - $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * |
|
| 737 | - $sat->deep_arg->eosq + 3651.957 * $eoc; |
|
| 738 | - $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * |
|
| 739 | - $sat->deep_arg->eosq+ 12422.52 * $eoc; |
|
| 740 | - if ($eq <= 0.715) { |
|
| 741 | - $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; |
|
| 742 | - } else { |
|
| 743 | - $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * |
|
| 744 | - $sat->deep_arg->eosq + 31324.56 * $eoc; |
|
| 745 | - } |
|
| 746 | - } /* End if (eq <= 0.65) */ |
|
| 747 | - |
|
| 748 | - if ($eq < 0.7) { |
|
| 749 | - $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * |
|
| 750 | - $sat->deep_arg->eosq + 5542.21 * $eoc; |
|
| 751 | - $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * |
|
| 752 | - $sat->deep_arg->eosq + 5337.524 * $eoc; |
|
| 753 | - $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
|
| 754 | - $sat->deep_arg->eosq + 5341.4 * $eoc; |
|
| 755 | - } |
|
| 756 | - else { |
|
| 757 | - $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
|
| 758 | - $sat->deep_arg->eosq + 109377.94 * $eoc; |
|
| 759 | - $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
|
| 760 | - $sat->deep_arg->eosq + 146349.42 * $eoc; |
|
| 761 | - $g532 = -40023.88 + 170470.89 * $eq - 242699.48* |
|
| 762 | - $sat->deep_arg->eosq + 115605.82 * $eoc; |
|
| 763 | - } /* End if (eq <= 0.7) */ |
|
| 764 | - |
|
| 765 | - $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; |
|
| 766 | - $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | - $f221 = 1.5 * $sini2; |
|
| 768 | - $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * |
|
| 769 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 770 | - $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2* |
|
| 771 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 772 | - $f441 = 35 * $sini2 * $f220; |
|
| 773 | - $f442 = 39.3750 * $sini2 * $sini2; |
|
| 774 | - $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * |
|
| 775 | - $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + |
|
| 776 | - 6 * $sat->deep_arg->theta2)); |
|
| 777 | - $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * |
|
| 778 | - $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | - * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); |
|
| 780 | - $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * |
|
| 781 | - $sat->deep_arg->cosio + $sat->deep_arg->theta2 * |
|
| 782 | - (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); |
|
| 783 | - $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + |
|
| 784 | - $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * |
|
| 785 | - $sat->deep_arg->theta2)); |
|
| 786 | - $xno2 = $sat->dps->xnq * $sat->dps->xnq; |
|
| 787 | - $ainv2 = $aqnv * $aqnv; |
|
| 788 | - $temp1 = 3 * $xno2 * $ainv2; |
|
| 789 | - $temp = $temp1 * Predict::root22; |
|
| 790 | - $sat->dps->d2201 = $temp * $f220 * $g201; |
|
| 791 | - $sat->dps->d2211 = $temp * $f221 * $g211; |
|
| 792 | - $temp1 = $temp1 * $aqnv; |
|
| 793 | - $temp = $temp1 * Predict::root32; |
|
| 794 | - $sat->dps->d3210 = $temp * $f321 * $g310; |
|
| 795 | - $sat->dps->d3222 = $temp * $f322 * $g322; |
|
| 796 | - $temp1 = $temp1 * $aqnv; |
|
| 797 | - $temp = 2 * $temp1 * Predict::root44; |
|
| 798 | - $sat->dps->d4410 = $temp * $f441 * $g410; |
|
| 799 | - $sat->dps->d4422 = $temp * $f442 * $g422; |
|
| 800 | - $temp1 = $temp1 * $aqnv; |
|
| 801 | - $temp = $temp1 * Predict::root52; |
|
| 802 | - $sat->dps->d5220 = $temp * $f522 * $g520; |
|
| 803 | - $sat->dps->d5232 = $temp * $f523 * $g532; |
|
| 804 | - $temp = 2 * $temp1 * Predict::root54; |
|
| 805 | - $sat->dps->d5421 = $temp * $f542 * $g521; |
|
| 806 | - $sat->dps->d5433 = $temp * $f543 * $g533; |
|
| 807 | - $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; |
|
| 808 | - $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + |
|
| 809 | - $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; |
|
| 810 | - $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssh + $sat->dps->ssh; |
|
| 811 | - } else { |
|
| 812 | - $sat->flags |= self::RESONANCE_FLAG; |
|
| 813 | - $sat->flags |= self::SYNCHRONOUS_FLAG; |
|
| 814 | - /* Synchronous resonance terms initialization */ |
|
| 815 | - $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); |
|
| 816 | - $g310 = 1 + 2 * $sat->deep_arg->eosq; |
|
| 817 | - $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); |
|
| 818 | - $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); |
|
| 819 | - $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * |
|
| 820 | - (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); |
|
| 821 | - $f330 = 1 + $sat->deep_arg->cosio; |
|
| 822 | - $f330 = 1.875 * $f330 * $f330 * $f330; |
|
| 823 | - $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; |
|
| 824 | - $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; |
|
| 825 | - $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; |
|
| 826 | - $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; |
|
| 827 | - $sat->dps->fasx2 = 0.13130908; |
|
| 828 | - $sat->dps->fasx4 = 2.8843198; |
|
| 829 | - $sat->dps->fasx6 = 0.37448087; |
|
| 830 | - $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->omegao - $sat->dps->thgr; |
|
| 831 | - $bfact = $sat->deep_arg->xmdot + $xpidot - Predict::thdt; |
|
| 832 | - $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssg + $sat->dps->ssh; |
|
| 833 | - } /* End if( !(xnq < 0.0052359877) && (xnq > 0.0034906585) ) */ |
|
| 834 | - |
|
| 835 | - $sat->dps->xfact = $bfact - $sat->dps->xnq; |
|
| 836 | - |
|
| 837 | - /* Initialize integrator */ |
|
| 838 | - $sat->dps->xli = $sat->dps->xlamo; |
|
| 839 | - $sat->dps->xni = $sat->dps->xnq; |
|
| 840 | - $sat->dps->atime = 0; |
|
| 841 | - $sat->dps->stepp = 720; |
|
| 842 | - $sat->dps->stepn = -720; |
|
| 843 | - $sat->dps->step2 = 259200; |
|
| 844 | - /* End case self::dpinit: */ |
|
| 845 | - return; |
|
| 846 | - |
|
| 847 | - case self::dpsec: /* Entrance for deep space secular effects */ |
|
| 848 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; |
|
| 849 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; |
|
| 850 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; |
|
| 851 | - $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; |
|
| 852 | - $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; |
|
| 853 | - if ($sat->deep_arg->xinc < 0) { |
|
| 854 | - $sat->deep_arg->xinc = -$sat->deep_arg->xinc; |
|
| 855 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; |
|
| 856 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; |
|
| 857 | - } |
|
| 858 | - if(~$sat->flags & self::RESONANCE_FLAG ) { |
|
| 859 | - return; |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - do { |
|
| 863 | - if ( ($sat->dps->atime == 0) || |
|
| 864 | - (($sat->deep_arg->t >= 0) && ($sat->dps->atime < 0)) || |
|
| 865 | - (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0)) ) { |
|
| 866 | - /* Epoch restart */ |
|
| 867 | - if ($sat->deep_arg->t >= 0) { |
|
| 868 | - $delt = $sat->dps->stepp; |
|
| 869 | - } else { |
|
| 870 | - $delt = $sat->dps->stepn; |
|
| 871 | - } |
|
| 872 | - |
|
| 873 | - $sat->dps->atime = 0; |
|
| 874 | - $sat->dps->xni = $sat->dps->xnq; |
|
| 875 | - $sat->dps->xli = $sat->dps->xlamo; |
|
| 876 | - } else { |
|
| 877 | - if (abs($sat->deep_arg->t) >= abs($sat->dps->atime)) { |
|
| 878 | - if ($sat->deep_arg->t > 0) { |
|
| 879 | - $delt = $sat->dps->stepp; |
|
| 880 | - } else { |
|
| 881 | - $delt = $sat->dps->stepn; |
|
| 882 | - } |
|
| 883 | - } |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - do { |
|
| 887 | - if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { |
|
| 888 | - $sat->flags |= self::DO_LOOP_FLAG; |
|
| 889 | - $sat->flags &= ~self::EPOCH_RESTART_FLAG; |
|
| 890 | - } |
|
| 891 | - else { |
|
| 892 | - $ft = $sat->deep_arg->t - $sat->dps->atime; |
|
| 893 | - $sat->flags &= ~self::DO_LOOP_FLAG; |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - if (abs($sat->deep_arg->t) < abs($sat->dps->atime)) { |
|
| 897 | - if ($sat->deep_arg->t >= 0) { |
|
| 898 | - $delt = $sat->dps->stepn; |
|
| 899 | - } else { |
|
| 900 | - $delt = $sat->dps->stepp; |
|
| 901 | - } |
|
| 902 | - $sat->flags |= (self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG); |
|
| 903 | - } |
|
| 904 | - |
|
| 905 | - /* Dot terms calculated */ |
|
| 906 | - if ($sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 907 | - $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | - + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | - $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | - + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 911 | - } else { |
|
| 912 | - $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; |
|
| 913 | - $x2omi = $xomi + $xomi; |
|
| 914 | - $x2li = $sat->dps->xli + $sat->dps->xli; |
|
| 915 | - $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | - + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) |
|
| 917 | - + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | - + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | - + $sat->dps->d4410 * sin($x2omi + $x2li- Predict::g44) |
|
| 920 | - + $sat->dps->d4422 * sin($x2li- Predict::g44) |
|
| 921 | - + $sat->dps->d5220 * sin($xomi + $sat->dps->xli- Predict::g52) |
|
| 922 | - + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli- Predict::g52) |
|
| 923 | - + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) |
|
| 924 | - + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | - $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli- Predict::g22) |
|
| 926 | - + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) |
|
| 927 | - + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | - + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | - + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | - + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | - + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) |
|
| 932 | - + $sat->dps->d4422 * cos($x2li - Predict::g44) |
|
| 933 | - + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) |
|
| 934 | - + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); |
|
| 935 | - } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ |
|
| 936 | - |
|
| 937 | - $xldot = $sat->dps->xni + $sat->dps->xfact; |
|
| 938 | - $xnddt = $xnddt * $xldot; |
|
| 939 | - |
|
| 940 | - if ($sat->flags & self::DO_LOOP_FLAG) { |
|
| 941 | - $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; |
|
| 942 | - $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; |
|
| 943 | - $sat->dps->atime = $sat->dps->atime + $delt; |
|
| 944 | - } |
|
| 945 | - } while (($sat->flags & self::DO_LOOP_FLAG) && |
|
| 946 | - (~$sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 947 | - } |
|
| 948 | - while (($sat->flags & self::DO_LOOP_FLAG) && ($sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 949 | - |
|
| 950 | - $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; |
|
| 951 | - $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; |
|
| 952 | - $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; |
|
| 953 | - |
|
| 954 | - if (~$sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 955 | - $sat->deep_arg->xll = $xl + $temp + $temp; |
|
| 956 | - } else { |
|
| 957 | - $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; |
|
| 958 | - } |
|
| 959 | - |
|
| 960 | - return; |
|
| 961 | - /* End case dpsec: */ |
|
| 962 | - |
|
| 963 | - case self::dpper: /* Entrance for lunar-solar periodics */ |
|
| 964 | - $sinis = sin($sat->deep_arg->xinc); |
|
| 965 | - $cosis = cos($sat->deep_arg->xinc); |
|
| 966 | - if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { |
|
| 967 | - $sat->dps->savtsn = $sat->deep_arg->t; |
|
| 968 | - $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; |
|
| 969 | - $zf = $zm + 2 * Predict::zes * sin($zm); |
|
| 970 | - $sinzf = sin($zf); |
|
| 971 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 972 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 973 | - $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; |
|
| 974 | - $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; |
|
| 975 | - $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; |
|
| 976 | - $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; |
|
| 977 | - $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; |
|
| 978 | - $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; |
|
| 979 | - $zf = $zm + 2 * Predict::zel * sin($zm); |
|
| 980 | - $sinzf = sin($zf); |
|
| 981 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 982 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 983 | - $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; |
|
| 984 | - $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; |
|
| 985 | - $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; |
|
| 986 | - $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; |
|
| 987 | - $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; |
|
| 988 | - $sat->dps->pe = $ses + $sel; |
|
| 989 | - $sat->dps->pinc = $sis + $sil; |
|
| 990 | - $sat->dps->pl = $sls + $sll; |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - $pgh = $sat->dps->sghs + $sat->dps->sghl; |
|
| 994 | - $ph = $sat->dps->shs + $sat->dps->sh1; |
|
| 995 | - $sat->deep_arg->xinc = $sat->deep_arg->xinc + $sat->dps->pinc; |
|
| 996 | - $sat->deep_arg->em = $sat->deep_arg->em + $sat->dps->pe; |
|
| 997 | - |
|
| 998 | - if ($sat->dps->xqncl >= 0.2) { |
|
| 999 | - /* Apply periodics directly */ |
|
| 1000 | - $ph = $ph / $sat->deep_arg->sinio; |
|
| 1001 | - $pgh = $pgh - $sat->deep_arg->cosio * $ph; |
|
| 1002 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; |
|
| 1003 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; |
|
| 1004 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1005 | - } else { |
|
| 1006 | - /* Apply periodics with Lyddane modification */ |
|
| 1007 | - $sinok = sin($sat->deep_arg->xnode); |
|
| 1008 | - $cosok = cos($sat->deep_arg->xnode); |
|
| 1009 | - $alfdp = $sinis * $sinok; |
|
| 1010 | - $betdp = $sinis * $cosok; |
|
| 1011 | - $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; |
|
| 1012 | - $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; |
|
| 1013 | - $alfdp = $alfdp + $dalf; |
|
| 1014 | - $betdp = $betdp + $dbet; |
|
| 1015 | - $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); |
|
| 1016 | - $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; |
|
| 1017 | - $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; |
|
| 1018 | - $xls = $xls + $dls; |
|
| 1019 | - $xnoh = $sat->deep_arg->xnode; |
|
| 1020 | - $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); |
|
| 1021 | - |
|
| 1022 | - /* This is a patch to Lyddane modification */ |
|
| 1023 | - /* suggested by Rob Matson. */ |
|
| 1024 | - if(abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1025 | - if ($sat->deep_arg->xnode < $xnoh) { |
|
| 1026 | - $sat->deep_arg->xnode += Predict::twopi; |
|
| 1027 | - } else { |
|
| 1028 | - $sat->deep_arg->xnode -= Predict::twopi; |
|
| 1029 | - } |
|
| 1030 | - } |
|
| 1031 | - |
|
| 1032 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1033 | - $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * |
|
| 1034 | - $sat->deep_arg->xnode; |
|
| 1035 | - } /* End case dpper: */ |
|
| 1036 | - return; |
|
| 544 | + case self::dpinit : /* Entrance for deep space initialization */ |
|
| 545 | + $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); |
|
| 546 | + $eq = $sat->tle->eo; |
|
| 547 | + $sat->dps->xnq = $sat->deep_arg->xnodp; |
|
| 548 | + $aqnv = 1.0 / $sat->deep_arg->aodp; |
|
| 549 | + $sat->dps->xqncl = $sat->tle->xincl; |
|
| 550 | + $xmao = $sat->tle->xmo; |
|
| 551 | + $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; |
|
| 552 | + $sinq = sin($sat->tle->xnodeo); |
|
| 553 | + $cosq = cos($sat->tle->xnodeo); |
|
| 554 | + $sat->dps->omegaq = $sat->tle->omegao; |
|
| 555 | + $sat->dps->preep = 0; |
|
| 556 | + |
|
| 557 | + /* Initialize lunar solar terms */ |
|
| 558 | + $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 559 | + if ($day != $sat->dps->preep) { |
|
| 560 | + $sat->dps->preep = $day; |
|
| 561 | + $xnodce = 4.5236020 - 9.2422029E-4 * $day; |
|
| 562 | + $stem = sin($xnodce); |
|
| 563 | + $ctem = cos($xnodce); |
|
| 564 | + $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; |
|
| 565 | + $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); |
|
| 566 | + $sat->dps->zsinhl = 0.089683511 * $stem / $sat->dps->zsinil; |
|
| 567 | + $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); |
|
| 568 | + $c = 4.7199672 + 0.22997150 * $day; |
|
| 569 | + $gam = 5.8351514 + 0.0019443680 * $day; |
|
| 570 | + $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); |
|
| 571 | + $zx = 0.39785416 * $stem / $sat->dps->zsinil; |
|
| 572 | + $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; |
|
| 573 | + $zx = Predict_Math::AcTan($zx, $zy); |
|
| 574 | + $zx = $gam + $zx - $xnodce; |
|
| 575 | + $sat->dps->zcosgl = cos($zx); |
|
| 576 | + $sat->dps->zsingl = sin($zx); |
|
| 577 | + $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; |
|
| 578 | + $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); |
|
| 579 | + } /* End if(day != preep) */ |
|
| 580 | + |
|
| 581 | + /* Do solar terms */ |
|
| 582 | + $sat->dps->savtsn = 1E20; |
|
| 583 | + $zcosg = Predict::zcosgs; |
|
| 584 | + $zsing = Predict::zsings; |
|
| 585 | + $zcosi = Predict::zcosis; |
|
| 586 | + $zsini = Predict::zsinis; |
|
| 587 | + $zcosh = $cosq; |
|
| 588 | + $zsinh = $sinq; |
|
| 589 | + $cc = Predict::c1ss; |
|
| 590 | + $zn = Predict::zns; |
|
| 591 | + $ze = Predict::zes; |
|
| 592 | + $zmo = $sat->dps->zmos; |
|
| 593 | + $xnoi = 1.0 / $sat->dps->xnq; |
|
| 594 | + |
|
| 595 | + /* Loop breaks when Solar terms are done a second */ |
|
| 596 | + /* time, after Lunar terms are initialized */ |
|
| 597 | + for(;;) { |
|
| 598 | + /* Solar terms done again after Lunar terms are done */ |
|
| 599 | + $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; |
|
| 600 | + $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; |
|
| 601 | + $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; |
|
| 602 | + $a8 = $zsing * $zsini; |
|
| 603 | + $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; |
|
| 604 | + $a10 = $zcosg * $zsini; |
|
| 605 | + $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; |
|
| 606 | + $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; |
|
| 607 | + $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; |
|
| 608 | + $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; |
|
| 609 | + $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; |
|
| 610 | + $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; |
|
| 611 | + $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; |
|
| 612 | + $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; |
|
| 613 | + $x5 = $a5 * $sat->deep_arg->sing; |
|
| 614 | + $x6 = $a6 * $sat->deep_arg->sing; |
|
| 615 | + $x7 = $a5 * $sat->deep_arg->cosg; |
|
| 616 | + $x8 = $a6 * $sat->deep_arg->cosg; |
|
| 617 | + $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; |
|
| 618 | + $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; |
|
| 619 | + $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; |
|
| 620 | + $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; |
|
| 621 | + $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; |
|
| 622 | + $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; |
|
| 623 | + $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); |
|
| 624 | + $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * |
|
| 625 | + (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); |
|
| 626 | + $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); |
|
| 627 | + $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); |
|
| 628 | + $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * |
|
| 629 | + (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); |
|
| 630 | + $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); |
|
| 631 | + $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; |
|
| 632 | + $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; |
|
| 633 | + $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; |
|
| 634 | + $s3 = $cc * $xnoi; |
|
| 635 | + $s2 = -0.5 * $s3 / $sat->deep_arg->betao; |
|
| 636 | + $s4 = $s3 * $sat->deep_arg->betao; |
|
| 637 | + $s1 = -15 * $eq * $s4; |
|
| 638 | + $s5 = $x1 * $x3 + $x2 * $x4; |
|
| 639 | + $s6 = $x2 * $x3 + $x1 * $x4; |
|
| 640 | + $s7 = $x2 * $x4 - $x1 * $x3; |
|
| 641 | + $se = $s1 * $zn * $s5; |
|
| 642 | + $si = $s2 * $zn * ($z11 + $z13); |
|
| 643 | + $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); |
|
| 644 | + $sgh = $s4 * $zn * ($z31 + $z33 - 6); |
|
| 645 | + $sh = -$zn * $s2 * ($z21 + $z23); |
|
| 646 | + if ($sat->dps->xqncl < 5.2359877E-2) { |
|
| 647 | + $sh = 0; |
|
| 648 | + } |
|
| 649 | + $sat->dps->ee2 = 2 * $s1 * $s6; |
|
| 650 | + $sat->dps->e3 = 2 * $s1 * $s7; |
|
| 651 | + $sat->dps->xi2 = 2 * $s2 * $z12; |
|
| 652 | + $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); |
|
| 653 | + $sat->dps->xl2 = -2 * $s3 * $z2; |
|
| 654 | + $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); |
|
| 655 | + $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; |
|
| 656 | + $sat->dps->xgh2 = 2 * $s4 * $z32; |
|
| 657 | + $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); |
|
| 658 | + $sat->dps->xgh4 = -18 * $s4 * $ze; |
|
| 659 | + $sat->dps->xh2 = -2 * $s2 * $z22; |
|
| 660 | + $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); |
|
| 661 | + |
|
| 662 | + if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { |
|
| 663 | + break; |
|
| 664 | + } |
|
| 665 | + |
|
| 666 | + /* Do lunar terms */ |
|
| 667 | + $sat->dps->sse = $se; |
|
| 668 | + $sat->dps->ssi = $si; |
|
| 669 | + $sat->dps->ssl = $sl; |
|
| 670 | + $sat->dps->ssh = $sh / $sat->deep_arg->sinio; |
|
| 671 | + $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; |
|
| 672 | + $sat->dps->se2 = $sat->dps->ee2; |
|
| 673 | + $sat->dps->si2 = $sat->dps->xi2; |
|
| 674 | + $sat->dps->sl2 = $sat->dps->xl2; |
|
| 675 | + $sat->dps->sgh2 = $sat->dps->xgh2; |
|
| 676 | + $sat->dps->sh2 = $sat->dps->xh2; |
|
| 677 | + $sat->dps->se3 = $sat->dps->e3; |
|
| 678 | + $sat->dps->si3 = $sat->dps->xi3; |
|
| 679 | + $sat->dps->sl3 = $sat->dps->xl3; |
|
| 680 | + $sat->dps->sgh3 = $sat->dps->xgh3; |
|
| 681 | + $sat->dps->sh3 = $sat->dps->xh3; |
|
| 682 | + $sat->dps->sl4 = $sat->dps->xl4; |
|
| 683 | + $sat->dps->sgh4 = $sat->dps->xgh4; |
|
| 684 | + $zcosg = $sat->dps->zcosgl; |
|
| 685 | + $zsing = $sat->dps->zsingl; |
|
| 686 | + $zcosi = $sat->dps->zcosil; |
|
| 687 | + $zsini = $sat->dps->zsinil; |
|
| 688 | + $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; |
|
| 689 | + $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; |
|
| 690 | + $zn = Predict::znl; |
|
| 691 | + $cc = Predict::c1l; |
|
| 692 | + $ze = Predict::zel; |
|
| 693 | + $zmo = $sat->dps->zmol; |
|
| 694 | + $sat->flags |= self::LUNAR_TERMS_DONE_FLAG; |
|
| 695 | + } /* End of for(;;) */ |
|
| 696 | + |
|
| 697 | + $sat->dps->sse = $sat->dps->sse + $se; |
|
| 698 | + $sat->dps->ssi = $sat->dps->ssi + $si; |
|
| 699 | + $sat->dps->ssl = $sat->dps->ssl + $sl; |
|
| 700 | + $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; |
|
| 701 | + $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; |
|
| 702 | + |
|
| 703 | + /* Geopotential resonance initialization for 12 hour orbits */ |
|
| 704 | + $sat->flags &= ~self::RESONANCE_FLAG; |
|
| 705 | + $sat->flags &= ~self::SYNCHRONOUS_FLAG; |
|
| 706 | + |
|
| 707 | + if (!(($sat->dps->xnq < 0.0052359877) && ($sat->dps->xnq > 0.0034906585))) { |
|
| 708 | + if( ($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924) ) { |
|
| 709 | + return; |
|
| 710 | + } |
|
| 711 | + if ($eq < 0.5) { |
|
| 712 | + return; |
|
| 713 | + } |
|
| 714 | + $sat->flags |= self::RESONANCE_FLAG; |
|
| 715 | + $eoc = $eq * $sat->deep_arg->eosq; |
|
| 716 | + $g201 = -0.306 - ($eq - 0.64) * 0.440; |
|
| 717 | + if ($eq <= 0.65) { |
|
| 718 | + $g211 = 3.616 - 13.247 * $eq + 16.290 * $sat->deep_arg->eosq; |
|
| 719 | + $g310 = -19.302 + 117.390 * $eq - 228.419 * |
|
| 720 | + $sat->deep_arg->eosq + 156.591 * $eoc; |
|
| 721 | + $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * |
|
| 722 | + $sat->deep_arg->eosq + 146.5816 * $eoc; |
|
| 723 | + $g410 = -41.122 + 242.694 * $eq - 471.094 * |
|
| 724 | + $sat->deep_arg->eosq + 313.953 * $eoc; |
|
| 725 | + $g422 = -146.407 + 841.880 * $eq - 1629.014 * |
|
| 726 | + $sat->deep_arg->eosq + 1083.435 * $eoc; |
|
| 727 | + $g520 = -532.114 + 3017.977 * $eq - 5740 * |
|
| 728 | + $sat->deep_arg->eosq + 3708.276 * $eoc; |
|
| 729 | + } else { |
|
| 730 | + $g211 = -72.099 + 331.819 * $eq - 508.738 * |
|
| 731 | + $sat->deep_arg->eosq + 266.724 * $eoc; |
|
| 732 | + $g310 = -346.844 + 1582.851 * $eq - 2415.925 * |
|
| 733 | + $sat->deep_arg->eosq + 1246.113 * $eoc; |
|
| 734 | + $g322 = -342.585 + 1554.908 * $eq - 2366.899 * |
|
| 735 | + $sat->deep_arg->eosq + 1215.972 * $eoc; |
|
| 736 | + $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * |
|
| 737 | + $sat->deep_arg->eosq + 3651.957 * $eoc; |
|
| 738 | + $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * |
|
| 739 | + $sat->deep_arg->eosq+ 12422.52 * $eoc; |
|
| 740 | + if ($eq <= 0.715) { |
|
| 741 | + $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; |
|
| 742 | + } else { |
|
| 743 | + $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * |
|
| 744 | + $sat->deep_arg->eosq + 31324.56 * $eoc; |
|
| 745 | + } |
|
| 746 | + } /* End if (eq <= 0.65) */ |
|
| 747 | + |
|
| 748 | + if ($eq < 0.7) { |
|
| 749 | + $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * |
|
| 750 | + $sat->deep_arg->eosq + 5542.21 * $eoc; |
|
| 751 | + $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * |
|
| 752 | + $sat->deep_arg->eosq + 5337.524 * $eoc; |
|
| 753 | + $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
|
| 754 | + $sat->deep_arg->eosq + 5341.4 * $eoc; |
|
| 755 | + } |
|
| 756 | + else { |
|
| 757 | + $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
|
| 758 | + $sat->deep_arg->eosq + 109377.94 * $eoc; |
|
| 759 | + $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
|
| 760 | + $sat->deep_arg->eosq + 146349.42 * $eoc; |
|
| 761 | + $g532 = -40023.88 + 170470.89 * $eq - 242699.48* |
|
| 762 | + $sat->deep_arg->eosq + 115605.82 * $eoc; |
|
| 763 | + } /* End if (eq <= 0.7) */ |
|
| 764 | + |
|
| 765 | + $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; |
|
| 766 | + $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | + $f221 = 1.5 * $sini2; |
|
| 768 | + $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * |
|
| 769 | + $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 770 | + $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2* |
|
| 771 | + $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 772 | + $f441 = 35 * $sini2 * $f220; |
|
| 773 | + $f442 = 39.3750 * $sini2 * $sini2; |
|
| 774 | + $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * |
|
| 775 | + $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + |
|
| 776 | + 6 * $sat->deep_arg->theta2)); |
|
| 777 | + $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * |
|
| 778 | + $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | + * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); |
|
| 780 | + $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * |
|
| 781 | + $sat->deep_arg->cosio + $sat->deep_arg->theta2 * |
|
| 782 | + (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); |
|
| 783 | + $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + |
|
| 784 | + $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * |
|
| 785 | + $sat->deep_arg->theta2)); |
|
| 786 | + $xno2 = $sat->dps->xnq * $sat->dps->xnq; |
|
| 787 | + $ainv2 = $aqnv * $aqnv; |
|
| 788 | + $temp1 = 3 * $xno2 * $ainv2; |
|
| 789 | + $temp = $temp1 * Predict::root22; |
|
| 790 | + $sat->dps->d2201 = $temp * $f220 * $g201; |
|
| 791 | + $sat->dps->d2211 = $temp * $f221 * $g211; |
|
| 792 | + $temp1 = $temp1 * $aqnv; |
|
| 793 | + $temp = $temp1 * Predict::root32; |
|
| 794 | + $sat->dps->d3210 = $temp * $f321 * $g310; |
|
| 795 | + $sat->dps->d3222 = $temp * $f322 * $g322; |
|
| 796 | + $temp1 = $temp1 * $aqnv; |
|
| 797 | + $temp = 2 * $temp1 * Predict::root44; |
|
| 798 | + $sat->dps->d4410 = $temp * $f441 * $g410; |
|
| 799 | + $sat->dps->d4422 = $temp * $f442 * $g422; |
|
| 800 | + $temp1 = $temp1 * $aqnv; |
|
| 801 | + $temp = $temp1 * Predict::root52; |
|
| 802 | + $sat->dps->d5220 = $temp * $f522 * $g520; |
|
| 803 | + $sat->dps->d5232 = $temp * $f523 * $g532; |
|
| 804 | + $temp = 2 * $temp1 * Predict::root54; |
|
| 805 | + $sat->dps->d5421 = $temp * $f542 * $g521; |
|
| 806 | + $sat->dps->d5433 = $temp * $f543 * $g533; |
|
| 807 | + $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; |
|
| 808 | + $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + |
|
| 809 | + $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; |
|
| 810 | + $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssh + $sat->dps->ssh; |
|
| 811 | + } else { |
|
| 812 | + $sat->flags |= self::RESONANCE_FLAG; |
|
| 813 | + $sat->flags |= self::SYNCHRONOUS_FLAG; |
|
| 814 | + /* Synchronous resonance terms initialization */ |
|
| 815 | + $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); |
|
| 816 | + $g310 = 1 + 2 * $sat->deep_arg->eosq; |
|
| 817 | + $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); |
|
| 818 | + $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); |
|
| 819 | + $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * |
|
| 820 | + (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); |
|
| 821 | + $f330 = 1 + $sat->deep_arg->cosio; |
|
| 822 | + $f330 = 1.875 * $f330 * $f330 * $f330; |
|
| 823 | + $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; |
|
| 824 | + $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; |
|
| 825 | + $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; |
|
| 826 | + $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; |
|
| 827 | + $sat->dps->fasx2 = 0.13130908; |
|
| 828 | + $sat->dps->fasx4 = 2.8843198; |
|
| 829 | + $sat->dps->fasx6 = 0.37448087; |
|
| 830 | + $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->omegao - $sat->dps->thgr; |
|
| 831 | + $bfact = $sat->deep_arg->xmdot + $xpidot - Predict::thdt; |
|
| 832 | + $bfact = $bfact + $sat->dps->ssl + $sat->dps->ssg + $sat->dps->ssh; |
|
| 833 | + } /* End if( !(xnq < 0.0052359877) && (xnq > 0.0034906585) ) */ |
|
| 834 | + |
|
| 835 | + $sat->dps->xfact = $bfact - $sat->dps->xnq; |
|
| 836 | + |
|
| 837 | + /* Initialize integrator */ |
|
| 838 | + $sat->dps->xli = $sat->dps->xlamo; |
|
| 839 | + $sat->dps->xni = $sat->dps->xnq; |
|
| 840 | + $sat->dps->atime = 0; |
|
| 841 | + $sat->dps->stepp = 720; |
|
| 842 | + $sat->dps->stepn = -720; |
|
| 843 | + $sat->dps->step2 = 259200; |
|
| 844 | + /* End case self::dpinit: */ |
|
| 845 | + return; |
|
| 846 | + |
|
| 847 | + case self::dpsec: /* Entrance for deep space secular effects */ |
|
| 848 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; |
|
| 849 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; |
|
| 850 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; |
|
| 851 | + $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; |
|
| 852 | + $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; |
|
| 853 | + if ($sat->deep_arg->xinc < 0) { |
|
| 854 | + $sat->deep_arg->xinc = -$sat->deep_arg->xinc; |
|
| 855 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; |
|
| 856 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; |
|
| 857 | + } |
|
| 858 | + if(~$sat->flags & self::RESONANCE_FLAG ) { |
|
| 859 | + return; |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + do { |
|
| 863 | + if ( ($sat->dps->atime == 0) || |
|
| 864 | + (($sat->deep_arg->t >= 0) && ($sat->dps->atime < 0)) || |
|
| 865 | + (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0)) ) { |
|
| 866 | + /* Epoch restart */ |
|
| 867 | + if ($sat->deep_arg->t >= 0) { |
|
| 868 | + $delt = $sat->dps->stepp; |
|
| 869 | + } else { |
|
| 870 | + $delt = $sat->dps->stepn; |
|
| 871 | + } |
|
| 872 | + |
|
| 873 | + $sat->dps->atime = 0; |
|
| 874 | + $sat->dps->xni = $sat->dps->xnq; |
|
| 875 | + $sat->dps->xli = $sat->dps->xlamo; |
|
| 876 | + } else { |
|
| 877 | + if (abs($sat->deep_arg->t) >= abs($sat->dps->atime)) { |
|
| 878 | + if ($sat->deep_arg->t > 0) { |
|
| 879 | + $delt = $sat->dps->stepp; |
|
| 880 | + } else { |
|
| 881 | + $delt = $sat->dps->stepn; |
|
| 882 | + } |
|
| 883 | + } |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + do { |
|
| 887 | + if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { |
|
| 888 | + $sat->flags |= self::DO_LOOP_FLAG; |
|
| 889 | + $sat->flags &= ~self::EPOCH_RESTART_FLAG; |
|
| 890 | + } |
|
| 891 | + else { |
|
| 892 | + $ft = $sat->deep_arg->t - $sat->dps->atime; |
|
| 893 | + $sat->flags &= ~self::DO_LOOP_FLAG; |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + if (abs($sat->deep_arg->t) < abs($sat->dps->atime)) { |
|
| 897 | + if ($sat->deep_arg->t >= 0) { |
|
| 898 | + $delt = $sat->dps->stepn; |
|
| 899 | + } else { |
|
| 900 | + $delt = $sat->dps->stepp; |
|
| 901 | + } |
|
| 902 | + $sat->flags |= (self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG); |
|
| 903 | + } |
|
| 904 | + |
|
| 905 | + /* Dot terms calculated */ |
|
| 906 | + if ($sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 907 | + $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | + + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | + $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | + + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 911 | + } else { |
|
| 912 | + $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; |
|
| 913 | + $x2omi = $xomi + $xomi; |
|
| 914 | + $x2li = $sat->dps->xli + $sat->dps->xli; |
|
| 915 | + $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | + + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) |
|
| 917 | + + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | + + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | + + $sat->dps->d4410 * sin($x2omi + $x2li- Predict::g44) |
|
| 920 | + + $sat->dps->d4422 * sin($x2li- Predict::g44) |
|
| 921 | + + $sat->dps->d5220 * sin($xomi + $sat->dps->xli- Predict::g52) |
|
| 922 | + + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli- Predict::g52) |
|
| 923 | + + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) |
|
| 924 | + + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | + $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli- Predict::g22) |
|
| 926 | + + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) |
|
| 927 | + + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | + + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | + + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | + + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | + + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) |
|
| 932 | + + $sat->dps->d4422 * cos($x2li - Predict::g44) |
|
| 933 | + + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) |
|
| 934 | + + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); |
|
| 935 | + } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ |
|
| 936 | + |
|
| 937 | + $xldot = $sat->dps->xni + $sat->dps->xfact; |
|
| 938 | + $xnddt = $xnddt * $xldot; |
|
| 939 | + |
|
| 940 | + if ($sat->flags & self::DO_LOOP_FLAG) { |
|
| 941 | + $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; |
|
| 942 | + $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; |
|
| 943 | + $sat->dps->atime = $sat->dps->atime + $delt; |
|
| 944 | + } |
|
| 945 | + } while (($sat->flags & self::DO_LOOP_FLAG) && |
|
| 946 | + (~$sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 947 | + } |
|
| 948 | + while (($sat->flags & self::DO_LOOP_FLAG) && ($sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 949 | + |
|
| 950 | + $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; |
|
| 951 | + $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; |
|
| 952 | + $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; |
|
| 953 | + |
|
| 954 | + if (~$sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 955 | + $sat->deep_arg->xll = $xl + $temp + $temp; |
|
| 956 | + } else { |
|
| 957 | + $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; |
|
| 958 | + } |
|
| 959 | + |
|
| 960 | + return; |
|
| 961 | + /* End case dpsec: */ |
|
| 962 | + |
|
| 963 | + case self::dpper: /* Entrance for lunar-solar periodics */ |
|
| 964 | + $sinis = sin($sat->deep_arg->xinc); |
|
| 965 | + $cosis = cos($sat->deep_arg->xinc); |
|
| 966 | + if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { |
|
| 967 | + $sat->dps->savtsn = $sat->deep_arg->t; |
|
| 968 | + $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; |
|
| 969 | + $zf = $zm + 2 * Predict::zes * sin($zm); |
|
| 970 | + $sinzf = sin($zf); |
|
| 971 | + $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 972 | + $f3 = -0.5 * $sinzf * cos($zf); |
|
| 973 | + $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; |
|
| 974 | + $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; |
|
| 975 | + $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; |
|
| 976 | + $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; |
|
| 977 | + $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; |
|
| 978 | + $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; |
|
| 979 | + $zf = $zm + 2 * Predict::zel * sin($zm); |
|
| 980 | + $sinzf = sin($zf); |
|
| 981 | + $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 982 | + $f3 = -0.5 * $sinzf * cos($zf); |
|
| 983 | + $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; |
|
| 984 | + $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; |
|
| 985 | + $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; |
|
| 986 | + $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; |
|
| 987 | + $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; |
|
| 988 | + $sat->dps->pe = $ses + $sel; |
|
| 989 | + $sat->dps->pinc = $sis + $sil; |
|
| 990 | + $sat->dps->pl = $sls + $sll; |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + $pgh = $sat->dps->sghs + $sat->dps->sghl; |
|
| 994 | + $ph = $sat->dps->shs + $sat->dps->sh1; |
|
| 995 | + $sat->deep_arg->xinc = $sat->deep_arg->xinc + $sat->dps->pinc; |
|
| 996 | + $sat->deep_arg->em = $sat->deep_arg->em + $sat->dps->pe; |
|
| 997 | + |
|
| 998 | + if ($sat->dps->xqncl >= 0.2) { |
|
| 999 | + /* Apply periodics directly */ |
|
| 1000 | + $ph = $ph / $sat->deep_arg->sinio; |
|
| 1001 | + $pgh = $pgh - $sat->deep_arg->cosio * $ph; |
|
| 1002 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; |
|
| 1003 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; |
|
| 1004 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1005 | + } else { |
|
| 1006 | + /* Apply periodics with Lyddane modification */ |
|
| 1007 | + $sinok = sin($sat->deep_arg->xnode); |
|
| 1008 | + $cosok = cos($sat->deep_arg->xnode); |
|
| 1009 | + $alfdp = $sinis * $sinok; |
|
| 1010 | + $betdp = $sinis * $cosok; |
|
| 1011 | + $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; |
|
| 1012 | + $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; |
|
| 1013 | + $alfdp = $alfdp + $dalf; |
|
| 1014 | + $betdp = $betdp + $dbet; |
|
| 1015 | + $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); |
|
| 1016 | + $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; |
|
| 1017 | + $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; |
|
| 1018 | + $xls = $xls + $dls; |
|
| 1019 | + $xnoh = $sat->deep_arg->xnode; |
|
| 1020 | + $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); |
|
| 1021 | + |
|
| 1022 | + /* This is a patch to Lyddane modification */ |
|
| 1023 | + /* suggested by Rob Matson. */ |
|
| 1024 | + if(abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1025 | + if ($sat->deep_arg->xnode < $xnoh) { |
|
| 1026 | + $sat->deep_arg->xnode += Predict::twopi; |
|
| 1027 | + } else { |
|
| 1028 | + $sat->deep_arg->xnode -= Predict::twopi; |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 1031 | + |
|
| 1032 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
|
| 1033 | + $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * |
|
| 1034 | + $sat->deep_arg->xnode; |
|
| 1035 | + } /* End case dpper: */ |
|
| 1036 | + return; |
|
| 1037 | 1037 | |
| 1038 | 1038 | } /* End switch(ientry) */ |
| 1039 | 1039 | |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | /* orbit_type_t struct */ |
| 44 | 44 | const ORBIT_TYPE_UNKNOWN = 0; |
| 45 | - const ORBIT_TYPE_LEO = 1; /*!< Low Earth orbit, up to 1200 km. */ |
|
| 46 | - const ORBIT_TYPE_ICO = 2; /*!< Intermediate Circular Orbit, up to 1400 km. */ |
|
| 47 | - const ORBIT_TYPE_GEO = 3; /*!< Geostationary. */ |
|
| 48 | - const ORBIT_TYPE_GSO = 4; /*!< Geosynchronuous. */ |
|
| 45 | + const ORBIT_TYPE_LEO = 1; /*!< Low Earth orbit, up to 1200 km. */ |
|
| 46 | + const ORBIT_TYPE_ICO = 2; /*!< Intermediate Circular Orbit, up to 1400 km. */ |
|
| 47 | + const ORBIT_TYPE_GEO = 3; /*!< Geostationary. */ |
|
| 48 | + const ORBIT_TYPE_GSO = 4; /*!< Geosynchronuous. */ |
|
| 49 | 49 | const ORBIT_TYPE_MOLNIYA = 5; |
| 50 | 50 | const ORBIT_TYPE_TUNDRA = 6; |
| 51 | 51 | const ORBIT_TYPE_POLAR = 7; |
@@ -70,29 +70,29 @@ discard block |
||
| 70 | 70 | public function SGP4(Predict_Sat $sat, $tsince) |
| 71 | 71 | { |
| 72 | 72 | /* Initialization */ |
| 73 | - if (~$sat->flags & self::SGP4_INITIALIZED_FLAG) { |
|
| 73 | + if (~$sat->flags&self::SGP4_INITIALIZED_FLAG) { |
|
| 74 | 74 | $sat->flags |= self::SGP4_INITIALIZED_FLAG; |
| 75 | 75 | |
| 76 | 76 | /* Recover original mean motion (xnodp) and */ |
| 77 | 77 | /* semimajor axis (aodp) from input elements. */ |
| 78 | - $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 78 | + $a1 = pow(Predict::xke/$sat->tle->xno, Predict::tothrd); |
|
| 79 | 79 | $sat->sgps->cosio = cos($sat->tle->xincl); |
| 80 | - $theta2 = $sat->sgps->cosio * $sat->sgps->cosio; |
|
| 81 | - $sat->sgps->x3thm1 = 3 * $theta2 - 1.0; |
|
| 82 | - $eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 80 | + $theta2 = $sat->sgps->cosio*$sat->sgps->cosio; |
|
| 81 | + $sat->sgps->x3thm1 = 3*$theta2 - 1.0; |
|
| 82 | + $eosq = $sat->tle->eo*$sat->tle->eo; |
|
| 83 | 83 | $betao2 = 1 - $eosq; |
| 84 | 84 | $betao = sqrt($betao2); |
| 85 | - $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($a1 * $a1 * $betao * $betao2); |
|
| 86 | - $ao = $a1 * (1 - $del1 * (0.5 * Predict::tothrd + $del1 * (1 + 134.0 / 81.0 * $del1))); |
|
| 87 | - $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / ($ao * $ao * $betao * $betao2); |
|
| 88 | - $sat->sgps->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 89 | - $sat->sgps->aodp = $ao / (1.0 - $delo); |
|
| 85 | + $del1 = 1.5*Predict::ck2*$sat->sgps->x3thm1/($a1*$a1*$betao*$betao2); |
|
| 86 | + $ao = $a1*(1 - $del1*(0.5*Predict::tothrd + $del1*(1 + 134.0/81.0*$del1))); |
|
| 87 | + $delo = 1.5*Predict::ck2*$sat->sgps->x3thm1/($ao*$ao*$betao*$betao2); |
|
| 88 | + $sat->sgps->xnodp = $sat->tle->xno/(1.0 + $delo); |
|
| 89 | + $sat->sgps->aodp = $ao/(1.0 - $delo); |
|
| 90 | 90 | |
| 91 | 91 | /* For perigee less than 220 kilometers, the "simple" flag is set */ |
| 92 | 92 | /* and the equations are truncated to linear variation in sqrt a */ |
| 93 | 93 | /* and quadratic variation in mean anomaly. Also, the c3 term, */ |
| 94 | 94 | /* the delta omega term, and the delta m term are dropped. */ |
| 95 | - if (($sat->sgps->aodp * (1.0 - $sat->tle->eo) / Predict::ae) < (220.0 / Predict::xkmper + Predict::ae)) { |
|
| 95 | + if (($sat->sgps->aodp*(1.0 - $sat->tle->eo)/Predict::ae) < (220.0/Predict::xkmper + Predict::ae)) { |
|
| 96 | 96 | $sat->flags |= self::SIMPLE_FLAG; |
| 97 | 97 | } else { |
| 98 | 98 | $sat->flags &= ~self::SIMPLE_FLAG; |
@@ -102,121 +102,121 @@ discard block |
||
| 102 | 102 | /* values of s and qoms2t are altered. */ |
| 103 | 103 | $s4 = Predict::__s__; |
| 104 | 104 | $qoms24 = Predict::qoms2t; |
| 105 | - $perige = ($sat->sgps->aodp * (1 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 105 | + $perige = ($sat->sgps->aodp*(1 - $sat->tle->eo) - Predict::ae)*Predict::xkmper; |
|
| 106 | 106 | if ($perige < 156.0) { |
| 107 | 107 | if ($perige <= 98.0) { |
| 108 | 108 | $s4 = 20.0; |
| 109 | 109 | } else { |
| 110 | 110 | $s4 = $perige - 78.0; |
| 111 | 111 | } |
| 112 | - $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 113 | - $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 112 | + $qoms24 = pow((120.0 - $s4)*Predict::ae/Predict::xkmper, 4); |
|
| 113 | + $s4 = $s4/Predict::xkmper + Predict::ae; |
|
| 114 | 114 | }; /* FIXME FIXME: End of if(perige <= 98) NO WAY!!!! */ |
| 115 | 115 | |
| 116 | - $pinvsq = 1.0 / ($sat->sgps->aodp * $sat->sgps->aodp * $betao2 * $betao2); |
|
| 117 | - $tsi = 1.0 / ($sat->sgps->aodp - $s4); |
|
| 118 | - $sat->sgps->eta = $sat->sgps->aodp * $sat->tle->eo * $tsi; |
|
| 119 | - $etasq = $sat->sgps->eta * $sat->sgps->eta; |
|
| 120 | - $eeta = $sat->tle->eo * $sat->sgps->eta; |
|
| 116 | + $pinvsq = 1.0/($sat->sgps->aodp*$sat->sgps->aodp*$betao2*$betao2); |
|
| 117 | + $tsi = 1.0/($sat->sgps->aodp - $s4); |
|
| 118 | + $sat->sgps->eta = $sat->sgps->aodp*$sat->tle->eo*$tsi; |
|
| 119 | + $etasq = $sat->sgps->eta*$sat->sgps->eta; |
|
| 120 | + $eeta = $sat->tle->eo*$sat->sgps->eta; |
|
| 121 | 121 | $psisq = abs(1.0 - $etasq); |
| 122 | - $coef = $qoms24 * pow($tsi, 4); |
|
| 123 | - $coef1 = $coef / pow($psisq, 3.5); |
|
| 124 | - $c2 = $coef1 * $sat->sgps->xnodp * ($sat->sgps->aodp * |
|
| 125 | - (1.0 + 1.5 * $etasq + $eeta * (4.0 + $etasq)) + |
|
| 126 | - 0.75 * Predict::ck2 * $tsi / $psisq * $sat->sgps->x3thm1 * |
|
| 127 | - (8.0 + 3.0 * $etasq * (8 + $etasq))); |
|
| 128 | - $sat->sgps->c1 = $c2 * $sat->tle->bstar; |
|
| 122 | + $coef = $qoms24*pow($tsi, 4); |
|
| 123 | + $coef1 = $coef/pow($psisq, 3.5); |
|
| 124 | + $c2 = $coef1*$sat->sgps->xnodp*($sat->sgps->aodp* |
|
| 125 | + (1.0 + 1.5*$etasq + $eeta*(4.0 + $etasq)) + |
|
| 126 | + 0.75*Predict::ck2*$tsi/$psisq*$sat->sgps->x3thm1* |
|
| 127 | + (8.0 + 3.0*$etasq*(8 + $etasq))); |
|
| 128 | + $sat->sgps->c1 = $c2*$sat->tle->bstar; |
|
| 129 | 129 | $sat->sgps->sinio = sin($sat->tle->xincl); |
| 130 | - $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 131 | - $c3 = $coef * $tsi * $a3ovk2 * $sat->sgps->xnodp * Predict::ae * $sat->sgps->sinio / $sat->tle->eo; |
|
| 130 | + $a3ovk2 = -Predict::xj3/Predict::ck2*pow(Predict::ae, 3); |
|
| 131 | + $c3 = $coef*$tsi*$a3ovk2*$sat->sgps->xnodp*Predict::ae*$sat->sgps->sinio/$sat->tle->eo; |
|
| 132 | 132 | $sat->sgps->x1mth2 = 1.0 - $theta2; |
| 133 | - $sat->sgps->c4 = 2.0 * $sat->sgps->xnodp * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 134 | - ($sat->sgps->eta * (2.0 + 0.5 * $etasq) + |
|
| 135 | - $sat->tle->eo * (0.5 + 2.0 * $etasq) - |
|
| 136 | - 2.0 * Predict::ck2 * $tsi / ($sat->sgps->aodp * $psisq) * |
|
| 137 | - (-3.0 * $sat->sgps->x3thm1 * (1.0 - 2.0 * $eeta + $etasq * (1.5 - 0.5 * $eeta)) + |
|
| 138 | - 0.75 * $sat->sgps->x1mth2 * (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 139 | - cos(2.0 * $sat->tle->omegao))); |
|
| 140 | - $sat->sgps->c5 = 2.0 * $coef1 * $sat->sgps->aodp * $betao2 * |
|
| 141 | - (1.0 + 2.75 * ($etasq + $eeta) + $eeta * $etasq); |
|
| 142 | - $theta4 = $theta2 * $theta2; |
|
| 143 | - $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->sgps->xnodp; |
|
| 144 | - $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 145 | - $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->sgps->xnodp; |
|
| 146 | - $sat->sgps->xmdot = $sat->sgps->xnodp + 0.5 * $temp1 * $betao * $sat->sgps->x3thm1 + |
|
| 147 | - 0.0625 * $temp2 * $betao * (13.0 - 78.0 * $theta2 + 137.0 * $theta4); |
|
| 148 | - $x1m5th = 1.0 - 5.0 * $theta2; |
|
| 149 | - $sat->sgps->omgdot = -0.5 * $temp1 * $x1m5th + |
|
| 150 | - 0.0625 * $temp2 * (7.0 - 114.0 * $theta2 + 395.0 * $theta4) + |
|
| 151 | - $temp3 * (3.0 - 36.0 * $theta2 + 49.0 * $theta4); |
|
| 152 | - $xhdot1 = -$temp1 * $sat->sgps->cosio; |
|
| 153 | - $sat->sgps->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $theta2) + |
|
| 154 | - 2.0 * $temp3 * (3.0 - 7.0 * $theta2)) * $sat->sgps->cosio; |
|
| 155 | - $sat->sgps->omgcof = $sat->tle->bstar * $c3 * cos($sat->tle->omegao); |
|
| 156 | - $sat->sgps->xmcof = -Predict::tothrd * $coef * $sat->tle->bstar * Predict::ae / $eeta; |
|
| 157 | - $sat->sgps->xnodcf = 3.5 * $betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 158 | - $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 159 | - $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->sgps->sinio * |
|
| 160 | - (3.0 + 5.0 * $sat->sgps->cosio) / (1.0 + $sat->sgps->cosio); |
|
| 161 | - $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->sgps->sinio; |
|
| 162 | - $sat->sgps->delmo = pow(1.0 + $sat->sgps->eta * cos($sat->tle->xmo), 3); |
|
| 133 | + $sat->sgps->c4 = 2.0*$sat->sgps->xnodp*$coef1*$sat->sgps->aodp*$betao2* |
|
| 134 | + ($sat->sgps->eta*(2.0 + 0.5*$etasq) + |
|
| 135 | + $sat->tle->eo*(0.5 + 2.0*$etasq) - |
|
| 136 | + 2.0*Predict::ck2*$tsi/($sat->sgps->aodp*$psisq)* |
|
| 137 | + (-3.0*$sat->sgps->x3thm1*(1.0 - 2.0*$eeta + $etasq*(1.5 - 0.5*$eeta)) + |
|
| 138 | + 0.75*$sat->sgps->x1mth2*(2.0*$etasq - $eeta*(1.0 + $etasq))* |
|
| 139 | + cos(2.0*$sat->tle->omegao))); |
|
| 140 | + $sat->sgps->c5 = 2.0*$coef1*$sat->sgps->aodp*$betao2* |
|
| 141 | + (1.0 + 2.75*($etasq + $eeta) + $eeta*$etasq); |
|
| 142 | + $theta4 = $theta2*$theta2; |
|
| 143 | + $temp1 = 3.0*Predict::ck2*$pinvsq*$sat->sgps->xnodp; |
|
| 144 | + $temp2 = $temp1*Predict::ck2*$pinvsq; |
|
| 145 | + $temp3 = 1.25*Predict::ck4*$pinvsq*$pinvsq*$sat->sgps->xnodp; |
|
| 146 | + $sat->sgps->xmdot = $sat->sgps->xnodp + 0.5*$temp1*$betao*$sat->sgps->x3thm1 + |
|
| 147 | + 0.0625*$temp2*$betao*(13.0 - 78.0*$theta2 + 137.0*$theta4); |
|
| 148 | + $x1m5th = 1.0 - 5.0*$theta2; |
|
| 149 | + $sat->sgps->omgdot = -0.5*$temp1*$x1m5th + |
|
| 150 | + 0.0625*$temp2*(7.0 - 114.0*$theta2 + 395.0*$theta4) + |
|
| 151 | + $temp3*(3.0 - 36.0*$theta2 + 49.0*$theta4); |
|
| 152 | + $xhdot1 = -$temp1*$sat->sgps->cosio; |
|
| 153 | + $sat->sgps->xnodot = $xhdot1 + (0.5*$temp2*(4.0 - 19.0*$theta2) + |
|
| 154 | + 2.0*$temp3*(3.0 - 7.0*$theta2))*$sat->sgps->cosio; |
|
| 155 | + $sat->sgps->omgcof = $sat->tle->bstar*$c3*cos($sat->tle->omegao); |
|
| 156 | + $sat->sgps->xmcof = -Predict::tothrd*$coef*$sat->tle->bstar*Predict::ae/$eeta; |
|
| 157 | + $sat->sgps->xnodcf = 3.5*$betao2*$xhdot1*$sat->sgps->c1; |
|
| 158 | + $sat->sgps->t2cof = 1.5*$sat->sgps->c1; |
|
| 159 | + $sat->sgps->xlcof = 0.125*$a3ovk2*$sat->sgps->sinio* |
|
| 160 | + (3.0 + 5.0*$sat->sgps->cosio)/(1.0 + $sat->sgps->cosio); |
|
| 161 | + $sat->sgps->aycof = 0.25*$a3ovk2*$sat->sgps->sinio; |
|
| 162 | + $sat->sgps->delmo = pow(1.0 + $sat->sgps->eta*cos($sat->tle->xmo), 3); |
|
| 163 | 163 | $sat->sgps->sinmo = sin($sat->tle->xmo); |
| 164 | - $sat->sgps->x7thm1 = 7.0 * $theta2 - 1.0; |
|
| 165 | - if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 166 | - $c1sq = $sat->sgps->c1 * $sat->sgps->c1; |
|
| 167 | - $sat->sgps->d2 = 4.0 * $sat->sgps->aodp * $tsi * $c1sq; |
|
| 168 | - $temp = $sat->sgps->d2 * $tsi * $sat->sgps->c1 / 3.0; |
|
| 169 | - $sat->sgps->d3 = (17.0 * $sat->sgps->aodp + $s4) * $temp; |
|
| 170 | - $sat->sgps->d4 = 0.5 * $temp * $sat->sgps->aodp * $tsi * |
|
| 171 | - (221.0 * $sat->sgps->aodp + 31.0 * $s4) * $sat->sgps->c1; |
|
| 172 | - $sat->sgps->t3cof = $sat->sgps->d2 + 2.0 * $c1sq; |
|
| 173 | - $sat->sgps->t4cof = 0.25 * (3.0 * $sat->sgps->d3 + $sat->sgps->c1 * |
|
| 174 | - (12.0 * $sat->sgps->d2 + 10.0 * $c1sq)); |
|
| 175 | - $sat->sgps->t5cof = 0.2 * (3.0 * $sat->sgps->d4 + |
|
| 176 | - 12.0 * $sat->sgps->c1 * $sat->sgps->d3 + |
|
| 177 | - 6.0 * $sat->sgps->d2 * $sat->sgps->d2 + |
|
| 178 | - 15.0 * $c1sq * (2.0 * $sat->sgps->d2 + $c1sq)); |
|
| 164 | + $sat->sgps->x7thm1 = 7.0*$theta2 - 1.0; |
|
| 165 | + if (~$sat->flags&self::SIMPLE_FLAG) { |
|
| 166 | + $c1sq = $sat->sgps->c1*$sat->sgps->c1; |
|
| 167 | + $sat->sgps->d2 = 4.0*$sat->sgps->aodp*$tsi*$c1sq; |
|
| 168 | + $temp = $sat->sgps->d2*$tsi*$sat->sgps->c1/3.0; |
|
| 169 | + $sat->sgps->d3 = (17.0*$sat->sgps->aodp + $s4)*$temp; |
|
| 170 | + $sat->sgps->d4 = 0.5*$temp*$sat->sgps->aodp*$tsi* |
|
| 171 | + (221.0*$sat->sgps->aodp + 31.0*$s4)*$sat->sgps->c1; |
|
| 172 | + $sat->sgps->t3cof = $sat->sgps->d2 + 2.0*$c1sq; |
|
| 173 | + $sat->sgps->t4cof = 0.25*(3.0*$sat->sgps->d3 + $sat->sgps->c1* |
|
| 174 | + (12.0*$sat->sgps->d2 + 10.0*$c1sq)); |
|
| 175 | + $sat->sgps->t5cof = 0.2*(3.0*$sat->sgps->d4 + |
|
| 176 | + 12.0*$sat->sgps->c1*$sat->sgps->d3 + |
|
| 177 | + 6.0*$sat->sgps->d2*$sat->sgps->d2 + |
|
| 178 | + 15.0*$c1sq*(2.0*$sat->sgps->d2 + $c1sq)); |
|
| 179 | 179 | }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
| 180 | 180 | }; /* End of SGP4() initialization */ |
| 181 | 181 | |
| 182 | 182 | /* Update for secular gravity and atmospheric drag. */ |
| 183 | - $xmdf = $sat->tle->xmo + $sat->sgps->xmdot * $tsince; |
|
| 184 | - $omgadf = $sat->tle->omegao + $sat->sgps->omgdot * $tsince; |
|
| 185 | - $xnoddf = $sat->tle->xnodeo + $sat->sgps->xnodot * $tsince; |
|
| 183 | + $xmdf = $sat->tle->xmo + $sat->sgps->xmdot*$tsince; |
|
| 184 | + $omgadf = $sat->tle->omegao + $sat->sgps->omgdot*$tsince; |
|
| 185 | + $xnoddf = $sat->tle->xnodeo + $sat->sgps->xnodot*$tsince; |
|
| 186 | 186 | $omega = $omgadf; |
| 187 | 187 | $xmp = $xmdf; |
| 188 | - $tsq = $tsince * $tsince; |
|
| 189 | - $xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 190 | - $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 191 | - $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 192 | - $templ = $sat->sgps->t2cof * $tsq; |
|
| 193 | - if (~$sat->flags & self::SIMPLE_FLAG) { |
|
| 194 | - $delomg = $sat->sgps->omgcof * $tsince; |
|
| 195 | - $delm = $sat->sgps->xmcof * (pow(1 + $sat->sgps->eta * cos($xmdf), 3) - $sat->sgps->delmo); |
|
| 188 | + $tsq = $tsince*$tsince; |
|
| 189 | + $xnode = $xnoddf + $sat->sgps->xnodcf*$tsq; |
|
| 190 | + $tempa = 1.0 - $sat->sgps->c1*$tsince; |
|
| 191 | + $tempe = $sat->tle->bstar*$sat->sgps->c4*$tsince; |
|
| 192 | + $templ = $sat->sgps->t2cof*$tsq; |
|
| 193 | + if (~$sat->flags&self::SIMPLE_FLAG) { |
|
| 194 | + $delomg = $sat->sgps->omgcof*$tsince; |
|
| 195 | + $delm = $sat->sgps->xmcof*(pow(1 + $sat->sgps->eta*cos($xmdf), 3) - $sat->sgps->delmo); |
|
| 196 | 196 | $temp = $delomg + $delm; |
| 197 | 197 | $xmp = $xmdf + $temp; |
| 198 | 198 | $omega = $omgadf - $temp; |
| 199 | - $tcube = $tsq * $tsince; |
|
| 200 | - $tfour = $tsince * $tcube; |
|
| 201 | - $tempa = $tempa - $sat->sgps->d2 * $tsq - $sat->sgps->d3 * $tcube - $sat->sgps->d4 * $tfour; |
|
| 202 | - $tempe = $tempe + $sat->tle->bstar * $sat->sgps->c5 * (sin($xmp) - $sat->sgps->sinmo); |
|
| 203 | - $templ = $templ + $sat->sgps->t3cof * $tcube + $tfour * |
|
| 204 | - ($sat->sgps->t4cof + $tsince * $sat->sgps->t5cof); |
|
| 199 | + $tcube = $tsq*$tsince; |
|
| 200 | + $tfour = $tsince*$tcube; |
|
| 201 | + $tempa = $tempa - $sat->sgps->d2*$tsq - $sat->sgps->d3*$tcube - $sat->sgps->d4*$tfour; |
|
| 202 | + $tempe = $tempe + $sat->tle->bstar*$sat->sgps->c5*(sin($xmp) - $sat->sgps->sinmo); |
|
| 203 | + $templ = $templ + $sat->sgps->t3cof*$tcube + $tfour* |
|
| 204 | + ($sat->sgps->t4cof + $tsince*$sat->sgps->t5cof); |
|
| 205 | 205 | }; /* End of if (isFlagClear(SIMPLE_FLAG)) */ |
| 206 | 206 | |
| 207 | - $a = $sat->sgps->aodp * pow($tempa, 2); |
|
| 207 | + $a = $sat->sgps->aodp*pow($tempa, 2); |
|
| 208 | 208 | $e = $sat->tle->eo - $tempe; |
| 209 | - $xl = $xmp + $omega + $xnode + $sat->sgps->xnodp * $templ; |
|
| 210 | - $beta = sqrt(1.0 - ($e * $e)); |
|
| 211 | - $xn = Predict::xke / pow($a, 1.5); |
|
| 209 | + $xl = $xmp + $omega + $xnode + $sat->sgps->xnodp*$templ; |
|
| 210 | + $beta = sqrt(1.0 - ($e*$e)); |
|
| 211 | + $xn = Predict::xke/pow($a, 1.5); |
|
| 212 | 212 | |
| 213 | 213 | /* Long period periodics */ |
| 214 | - $axn = $e * cos($omega); |
|
| 215 | - $temp = 1.0 / ($a * $beta * $beta); |
|
| 216 | - $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 217 | - $aynl = $temp * $sat->sgps->aycof; |
|
| 214 | + $axn = $e*cos($omega); |
|
| 215 | + $temp = 1.0/($a*$beta*$beta); |
|
| 216 | + $xll = $temp*$sat->sgps->xlcof*$axn; |
|
| 217 | + $aynl = $temp*$sat->sgps->aycof; |
|
| 218 | 218 | $xlt = $xl + $xll; |
| 219 | - $ayn = $e * sin($omega) + $aynl; |
|
| 219 | + $ayn = $e*sin($omega) + $aynl; |
|
| 220 | 220 | |
| 221 | 221 | /* Solve Kepler's' Equation */ |
| 222 | 222 | $capu = Predict_Math::FMod2p($xlt - $xnode); |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | do { |
| 227 | 227 | $sinepw = sin($temp2); |
| 228 | 228 | $cosepw = cos($temp2); |
| 229 | - $temp3 = $axn * $sinepw; |
|
| 230 | - $temp4 = $ayn * $cosepw; |
|
| 231 | - $temp5 = $axn * $cosepw; |
|
| 232 | - $temp6 = $ayn * $sinepw; |
|
| 233 | - $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 229 | + $temp3 = $axn*$sinepw; |
|
| 230 | + $temp4 = $ayn*$cosepw; |
|
| 231 | + $temp5 = $axn*$cosepw; |
|
| 232 | + $temp6 = $ayn*$sinepw; |
|
| 233 | + $epw = ($capu - $temp4 + $temp3 - $temp2)/(1.0 - $temp5 - $temp6) + $temp2; |
|
| 234 | 234 | if (abs($epw - $temp2) <= Predict::e6a) { |
| 235 | 235 | break; |
| 236 | 236 | } |
@@ -240,33 +240,33 @@ discard block |
||
| 240 | 240 | /* Short period preliminary quantities */ |
| 241 | 241 | $ecose = $temp5 + $temp6; |
| 242 | 242 | $esine = $temp3 - $temp4; |
| 243 | - $elsq = $axn * $axn + $ayn * $ayn; |
|
| 243 | + $elsq = $axn*$axn + $ayn*$ayn; |
|
| 244 | 244 | $temp = 1.0 - $elsq; |
| 245 | - $pl = $a * $temp; |
|
| 246 | - $r = $a * (1.0 - $ecose); |
|
| 247 | - $temp1 = 1.0 / $r; |
|
| 248 | - $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 249 | - $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 250 | - $temp2 = $a * $temp1; |
|
| 245 | + $pl = $a*$temp; |
|
| 246 | + $r = $a*(1.0 - $ecose); |
|
| 247 | + $temp1 = 1.0/$r; |
|
| 248 | + $rdot = Predict::xke*sqrt($a)*$esine*$temp1; |
|
| 249 | + $rfdot = Predict::xke*sqrt($pl)*$temp1; |
|
| 250 | + $temp2 = $a*$temp1; |
|
| 251 | 251 | $betal = sqrt($temp); |
| 252 | - $temp3 = 1.0 / (1.0 + $betal); |
|
| 253 | - $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 254 | - $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 252 | + $temp3 = 1.0/(1.0 + $betal); |
|
| 253 | + $cosu = $temp2*($cosepw - $axn + $ayn*$esine*$temp3); |
|
| 254 | + $sinu = $temp2*($sinepw - $ayn - $axn*$esine*$temp3); |
|
| 255 | 255 | $u = Predict_Math::AcTan($sinu, $cosu); |
| 256 | - $sin2u = 2.0 * $sinu * $cosu; |
|
| 257 | - $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 258 | - $temp = 1.0 / $pl; |
|
| 259 | - $temp1 = Predict::ck2 * $temp; |
|
| 260 | - $temp2 = $temp1 * $temp; |
|
| 256 | + $sin2u = 2.0*$sinu*$cosu; |
|
| 257 | + $cos2u = 2.0*$cosu*$cosu - 1.0; |
|
| 258 | + $temp = 1.0/$pl; |
|
| 259 | + $temp1 = Predict::ck2*$temp; |
|
| 260 | + $temp2 = $temp1*$temp; |
|
| 261 | 261 | |
| 262 | 262 | /* Update for short periodics */ |
| 263 | - $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 264 | - 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 265 | - $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 266 | - $xnodek = $xnode + 1.5 * $temp2 * $sat->sgps->cosio * $sin2u; |
|
| 267 | - $xinck = $sat->tle->xincl + 1.5 * $temp2 * $sat->sgps->cosio * $sat->sgps->sinio * $cos2u; |
|
| 268 | - $rdotk = $rdot - $xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 269 | - $rfdotk = $rfdot + $xn * $temp1 * ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 263 | + $rk = $r*(1.0 - 1.5*$temp2*$betal*$sat->sgps->x3thm1) + |
|
| 264 | + 0.5*$temp1*$sat->sgps->x1mth2*$cos2u; |
|
| 265 | + $uk = $u - 0.25*$temp2*$sat->sgps->x7thm1*$sin2u; |
|
| 266 | + $xnodek = $xnode + 1.5*$temp2*$sat->sgps->cosio*$sin2u; |
|
| 267 | + $xinck = $sat->tle->xincl + 1.5*$temp2*$sat->sgps->cosio*$sat->sgps->sinio*$cos2u; |
|
| 268 | + $rdotk = $rdot - $xn*$temp1*$sat->sgps->x1mth2*$sin2u; |
|
| 269 | + $rfdotk = $rfdot + $xn*$temp1*($sat->sgps->x1mth2*$cos2u + 1.5*$sat->sgps->x3thm1); |
|
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | /* Orientation vectors */ |
@@ -276,22 +276,22 @@ discard block |
||
| 276 | 276 | $cosik = cos($xinck); |
| 277 | 277 | $sinnok = sin($xnodek); |
| 278 | 278 | $cosnok = cos($xnodek); |
| 279 | - $xmx = -$sinnok * $cosik; |
|
| 280 | - $xmy = $cosnok * $cosik; |
|
| 281 | - $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 282 | - $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 283 | - $uz = $sinik * $sinuk; |
|
| 284 | - $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 285 | - $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 286 | - $vz = $sinik * $cosuk; |
|
| 279 | + $xmx = -$sinnok*$cosik; |
|
| 280 | + $xmy = $cosnok*$cosik; |
|
| 281 | + $ux = $xmx*$sinuk + $cosnok*$cosuk; |
|
| 282 | + $uy = $xmy*$sinuk + $sinnok*$cosuk; |
|
| 283 | + $uz = $sinik*$sinuk; |
|
| 284 | + $vx = $xmx*$cosuk - $cosnok*$sinuk; |
|
| 285 | + $vy = $xmy*$cosuk - $sinnok*$sinuk; |
|
| 286 | + $vz = $sinik*$cosuk; |
|
| 287 | 287 | |
| 288 | 288 | /* Position and velocity */ |
| 289 | - $sat->pos->x = $rk * $ux; |
|
| 290 | - $sat->pos->y = $rk * $uy; |
|
| 291 | - $sat->pos->z = $rk * $uz; |
|
| 292 | - $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 293 | - $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 294 | - $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 289 | + $sat->pos->x = $rk*$ux; |
|
| 290 | + $sat->pos->y = $rk*$uy; |
|
| 291 | + $sat->pos->z = $rk*$uz; |
|
| 292 | + $sat->vel->x = $rdotk*$ux + $rfdotk*$vx; |
|
| 293 | + $sat->vel->y = $rdotk*$uy + $rfdotk*$vy; |
|
| 294 | + $sat->vel->z = $rdotk*$uz + $rfdotk*$vz; |
|
| 295 | 295 | |
| 296 | 296 | $sat->phase = $xlt - $xnode - $omgadf + Predict::twopi; |
| 297 | 297 | if ($sat->phase < 0) { |
@@ -315,106 +315,106 @@ discard block |
||
| 315 | 315 | public function SDP4(Predict_Sat $sat, $tsince) |
| 316 | 316 | { |
| 317 | 317 | /* Initialization */ |
| 318 | - if (~$sat->flags & self::SDP4_INITIALIZED_FLAG) { |
|
| 318 | + if (~$sat->flags&self::SDP4_INITIALIZED_FLAG) { |
|
| 319 | 319 | |
| 320 | 320 | $sat->flags |= self::SDP4_INITIALIZED_FLAG; |
| 321 | 321 | |
| 322 | 322 | /* Recover original mean motion (xnodp) and */ |
| 323 | 323 | /* semimajor axis (aodp) from input elements. */ |
| 324 | - $a1 = pow(Predict::xke / $sat->tle->xno, Predict::tothrd); |
|
| 324 | + $a1 = pow(Predict::xke/$sat->tle->xno, Predict::tothrd); |
|
| 325 | 325 | $sat->deep_arg->cosio = cos($sat->tle->xincl); |
| 326 | - $sat->deep_arg->theta2 = $sat->deep_arg->cosio * $sat->deep_arg->cosio; |
|
| 327 | - $sat->sgps->x3thm1 = 3.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 328 | - $sat->deep_arg->eosq = $sat->tle->eo * $sat->tle->eo; |
|
| 326 | + $sat->deep_arg->theta2 = $sat->deep_arg->cosio*$sat->deep_arg->cosio; |
|
| 327 | + $sat->sgps->x3thm1 = 3.0*$sat->deep_arg->theta2 - 1.0; |
|
| 328 | + $sat->deep_arg->eosq = $sat->tle->eo*$sat->tle->eo; |
|
| 329 | 329 | $sat->deep_arg->betao2 = 1.0 - $sat->deep_arg->eosq; |
| 330 | 330 | $sat->deep_arg->betao = sqrt($sat->deep_arg->betao2); |
| 331 | - $del1 = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 332 | - ($a1 * $a1 * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 333 | - $ao = $a1 * (1.0 - $del1 * (0.5 * Predict::tothrd + $del1 * (1.0 + 134.0 / 81.0 * $del1))); |
|
| 334 | - $delo = 1.5 * Predict::ck2 * $sat->sgps->x3thm1 / |
|
| 335 | - ($ao * $ao * $sat->deep_arg->betao * $sat->deep_arg->betao2); |
|
| 336 | - $sat->deep_arg->xnodp = $sat->tle->xno / (1.0 + $delo); |
|
| 337 | - $sat->deep_arg->aodp = $ao / (1.0 - $delo); |
|
| 331 | + $del1 = 1.5*Predict::ck2*$sat->sgps->x3thm1/ |
|
| 332 | + ($a1*$a1*$sat->deep_arg->betao*$sat->deep_arg->betao2); |
|
| 333 | + $ao = $a1*(1.0 - $del1*(0.5*Predict::tothrd + $del1*(1.0 + 134.0/81.0*$del1))); |
|
| 334 | + $delo = 1.5*Predict::ck2*$sat->sgps->x3thm1/ |
|
| 335 | + ($ao*$ao*$sat->deep_arg->betao*$sat->deep_arg->betao2); |
|
| 336 | + $sat->deep_arg->xnodp = $sat->tle->xno/(1.0 + $delo); |
|
| 337 | + $sat->deep_arg->aodp = $ao/(1.0 - $delo); |
|
| 338 | 338 | |
| 339 | 339 | /* For perigee below 156 km, the values */ |
| 340 | 340 | /* of s and qoms2t are altered. */ |
| 341 | 341 | $s4 = Predict::__s__; |
| 342 | 342 | $qoms24 = Predict::qoms2t; |
| 343 | - $perige = ($sat->deep_arg->aodp * (1.0 - $sat->tle->eo) - Predict::ae) * Predict::xkmper; |
|
| 343 | + $perige = ($sat->deep_arg->aodp*(1.0 - $sat->tle->eo) - Predict::ae)*Predict::xkmper; |
|
| 344 | 344 | if ($perige < 156.0) { |
| 345 | 345 | if ($perige <= 98.0) { |
| 346 | 346 | $s4 = 20.0; |
| 347 | 347 | } else { |
| 348 | 348 | $s4 = $perige - 78.0; |
| 349 | 349 | } |
| 350 | - $qoms24 = pow((120.0 - $s4) * Predict::ae / Predict::xkmper, 4); |
|
| 351 | - $s4 = $s4 / Predict::xkmper + Predict::ae; |
|
| 350 | + $qoms24 = pow((120.0 - $s4)*Predict::ae/Predict::xkmper, 4); |
|
| 351 | + $s4 = $s4/Predict::xkmper + Predict::ae; |
|
| 352 | 352 | } |
| 353 | - $pinvsq = 1.0 / ($sat->deep_arg->aodp * $sat->deep_arg->aodp * |
|
| 354 | - $sat->deep_arg->betao2 * $sat->deep_arg->betao2); |
|
| 353 | + $pinvsq = 1.0/($sat->deep_arg->aodp*$sat->deep_arg->aodp* |
|
| 354 | + $sat->deep_arg->betao2*$sat->deep_arg->betao2); |
|
| 355 | 355 | $sat->deep_arg->sing = sin($sat->tle->omegao); |
| 356 | 356 | $sat->deep_arg->cosg = cos($sat->tle->omegao); |
| 357 | - $tsi = 1.0 / ($sat->deep_arg->aodp - $s4); |
|
| 358 | - $eta = $sat->deep_arg->aodp * $sat->tle->eo * $tsi; |
|
| 359 | - $etasq = $eta * $eta; |
|
| 360 | - $eeta = $sat->tle->eo * $eta; |
|
| 357 | + $tsi = 1.0/($sat->deep_arg->aodp - $s4); |
|
| 358 | + $eta = $sat->deep_arg->aodp*$sat->tle->eo*$tsi; |
|
| 359 | + $etasq = $eta*$eta; |
|
| 360 | + $eeta = $sat->tle->eo*$eta; |
|
| 361 | 361 | $psisq = abs(1.0 - $etasq); |
| 362 | - $coef = $qoms24 * pow($tsi, 4); |
|
| 363 | - $coef1 = $coef / pow($psisq, 3.5); |
|
| 364 | - $c2 = $coef1 * $sat->deep_arg->xnodp * ($sat->deep_arg->aodp * |
|
| 365 | - (1.0 + 1.5 * $etasq + $eeta * |
|
| 366 | - (4.0 + $etasq)) + 0.75 * Predict::ck2 * $tsi / $psisq * |
|
| 367 | - $sat->sgps->x3thm1 * (8.0 + 3.0 * $etasq * |
|
| 362 | + $coef = $qoms24*pow($tsi, 4); |
|
| 363 | + $coef1 = $coef/pow($psisq, 3.5); |
|
| 364 | + $c2 = $coef1*$sat->deep_arg->xnodp*($sat->deep_arg->aodp* |
|
| 365 | + (1.0 + 1.5*$etasq + $eeta* |
|
| 366 | + (4.0 + $etasq)) + 0.75*Predict::ck2*$tsi/$psisq* |
|
| 367 | + $sat->sgps->x3thm1*(8.0 + 3.0*$etasq* |
|
| 368 | 368 | (8.0 + $etasq))); |
| 369 | - $sat->sgps->c1 = $sat->tle->bstar * $c2; |
|
| 369 | + $sat->sgps->c1 = $sat->tle->bstar*$c2; |
|
| 370 | 370 | $sat->deep_arg->sinio = sin($sat->tle->xincl); |
| 371 | - $a3ovk2 = -Predict::xj3 / Predict::ck2 * pow(Predict::ae, 3); |
|
| 371 | + $a3ovk2 = -Predict::xj3/Predict::ck2*pow(Predict::ae, 3); |
|
| 372 | 372 | $sat->sgps->x1mth2 = 1.0 - $sat->deep_arg->theta2; |
| 373 | - $sat->sgps->c4 = 2.0 * $sat->deep_arg->xnodp * $coef1 * |
|
| 374 | - $sat->deep_arg->aodp * $sat->deep_arg->betao2 * |
|
| 375 | - ($eta * (2.0 + 0.5 * $etasq) + $sat->tle->eo * |
|
| 376 | - (0.5 + 2.0 * $etasq) - 2.0 * Predict::ck2 * $tsi / |
|
| 377 | - ($sat->deep_arg->aodp * $psisq) * (-3.0 * $sat->sgps->x3thm1 * |
|
| 378 | - (1.0 - 2.0 * $eeta + $etasq * |
|
| 379 | - (1.5 - 0.5 * $eeta)) + |
|
| 380 | - 0.75 * $sat->sgps->x1mth2 * |
|
| 381 | - (2.0 * $etasq - $eeta * (1.0 + $etasq)) * |
|
| 382 | - cos(2.0 * $sat->tle->omegao))); |
|
| 383 | - $theta4 = $sat->deep_arg->theta2 * $sat->deep_arg->theta2; |
|
| 384 | - $temp1 = 3.0 * Predict::ck2 * $pinvsq * $sat->deep_arg->xnodp; |
|
| 385 | - $temp2 = $temp1 * Predict::ck2 * $pinvsq; |
|
| 386 | - $temp3 = 1.25 * Predict::ck4 * $pinvsq * $pinvsq * $sat->deep_arg->xnodp; |
|
| 387 | - $sat->deep_arg->xmdot = $sat->deep_arg->xnodp + 0.5 * $temp1 * $sat->deep_arg->betao * |
|
| 388 | - $sat->sgps->x3thm1 + 0.0625 * $temp2 * $sat->deep_arg->betao * |
|
| 389 | - (13.0 - 78.0 * $sat->deep_arg->theta2 + 137.0 * $theta4); |
|
| 390 | - $x1m5th = 1.0 - 5.0 * $sat->deep_arg->theta2; |
|
| 391 | - $sat->deep_arg->omgdot = -0.5 * $temp1 * $x1m5th + 0.0625 * $temp2 * |
|
| 392 | - (7.0 - 114.0 * $sat->deep_arg->theta2 + 395.0 * $theta4) + |
|
| 393 | - $temp3 * (3.0 - 36.0 * $sat->deep_arg->theta2 + 49.0 * $theta4); |
|
| 394 | - $xhdot1 = -$temp1 * $sat->deep_arg->cosio; |
|
| 395 | - $sat->deep_arg->xnodot = $xhdot1 + (0.5 * $temp2 * (4.0 - 19.0 * $sat->deep_arg->theta2) + |
|
| 396 | - 2.0 * $temp3 * (3.0 - 7.0 * $sat->deep_arg->theta2)) * |
|
| 373 | + $sat->sgps->c4 = 2.0*$sat->deep_arg->xnodp*$coef1* |
|
| 374 | + $sat->deep_arg->aodp*$sat->deep_arg->betao2* |
|
| 375 | + ($eta*(2.0 + 0.5*$etasq) + $sat->tle->eo* |
|
| 376 | + (0.5 + 2.0*$etasq) - 2.0*Predict::ck2*$tsi/ |
|
| 377 | + ($sat->deep_arg->aodp*$psisq)*(-3.0*$sat->sgps->x3thm1* |
|
| 378 | + (1.0 - 2.0*$eeta + $etasq* |
|
| 379 | + (1.5 - 0.5*$eeta)) + |
|
| 380 | + 0.75*$sat->sgps->x1mth2* |
|
| 381 | + (2.0*$etasq - $eeta*(1.0 + $etasq))* |
|
| 382 | + cos(2.0*$sat->tle->omegao))); |
|
| 383 | + $theta4 = $sat->deep_arg->theta2*$sat->deep_arg->theta2; |
|
| 384 | + $temp1 = 3.0*Predict::ck2*$pinvsq*$sat->deep_arg->xnodp; |
|
| 385 | + $temp2 = $temp1*Predict::ck2*$pinvsq; |
|
| 386 | + $temp3 = 1.25*Predict::ck4*$pinvsq*$pinvsq*$sat->deep_arg->xnodp; |
|
| 387 | + $sat->deep_arg->xmdot = $sat->deep_arg->xnodp + 0.5*$temp1*$sat->deep_arg->betao* |
|
| 388 | + $sat->sgps->x3thm1 + 0.0625*$temp2*$sat->deep_arg->betao* |
|
| 389 | + (13.0 - 78.0*$sat->deep_arg->theta2 + 137.0*$theta4); |
|
| 390 | + $x1m5th = 1.0 - 5.0*$sat->deep_arg->theta2; |
|
| 391 | + $sat->deep_arg->omgdot = -0.5*$temp1*$x1m5th + 0.0625*$temp2* |
|
| 392 | + (7.0 - 114.0*$sat->deep_arg->theta2 + 395.0*$theta4) + |
|
| 393 | + $temp3*(3.0 - 36.0*$sat->deep_arg->theta2 + 49.0*$theta4); |
|
| 394 | + $xhdot1 = -$temp1*$sat->deep_arg->cosio; |
|
| 395 | + $sat->deep_arg->xnodot = $xhdot1 + (0.5*$temp2*(4.0 - 19.0*$sat->deep_arg->theta2) + |
|
| 396 | + 2.0*$temp3*(3.0 - 7.0*$sat->deep_arg->theta2))* |
|
| 397 | 397 | $sat->deep_arg->cosio; |
| 398 | - $sat->sgps->xnodcf = 3.5 * $sat->deep_arg->betao2 * $xhdot1 * $sat->sgps->c1; |
|
| 399 | - $sat->sgps->t2cof = 1.5 * $sat->sgps->c1; |
|
| 400 | - $sat->sgps->xlcof = 0.125 * $a3ovk2 * $sat->deep_arg->sinio * |
|
| 401 | - (3.0 + 5.0 * $sat->deep_arg->cosio) / (1.0 + $sat->deep_arg->cosio); |
|
| 402 | - $sat->sgps->aycof = 0.25 * $a3ovk2 * $sat->deep_arg->sinio; |
|
| 403 | - $sat->sgps->x7thm1 = 7.0 * $sat->deep_arg->theta2 - 1.0; |
|
| 398 | + $sat->sgps->xnodcf = 3.5*$sat->deep_arg->betao2*$xhdot1*$sat->sgps->c1; |
|
| 399 | + $sat->sgps->t2cof = 1.5*$sat->sgps->c1; |
|
| 400 | + $sat->sgps->xlcof = 0.125*$a3ovk2*$sat->deep_arg->sinio* |
|
| 401 | + (3.0 + 5.0*$sat->deep_arg->cosio)/(1.0 + $sat->deep_arg->cosio); |
|
| 402 | + $sat->sgps->aycof = 0.25*$a3ovk2*$sat->deep_arg->sinio; |
|
| 403 | + $sat->sgps->x7thm1 = 7.0*$sat->deep_arg->theta2 - 1.0; |
|
| 404 | 404 | |
| 405 | 405 | /* initialize Deep() */ |
| 406 | 406 | $this->Deep(self::dpinit, $sat); |
| 407 | 407 | }; /*End of SDP4() initialization */ |
| 408 | 408 | |
| 409 | 409 | /* Update for secular gravity and atmospheric drag */ |
| 410 | - $xmdf = $sat->tle->xmo + $sat->deep_arg->xmdot * $tsince; |
|
| 411 | - $sat->deep_arg->omgadf = $sat->tle->omegao + $sat->deep_arg->omgdot * $tsince; |
|
| 412 | - $xnoddf = $sat->tle->xnodeo + $sat->deep_arg->xnodot * $tsince; |
|
| 413 | - $tsq = $tsince * $tsince; |
|
| 414 | - $sat->deep_arg->xnode = $xnoddf + $sat->sgps->xnodcf * $tsq; |
|
| 415 | - $tempa = 1.0 - $sat->sgps->c1 * $tsince; |
|
| 416 | - $tempe = $sat->tle->bstar * $sat->sgps->c4 * $tsince; |
|
| 417 | - $templ = $sat->sgps->t2cof * $tsq; |
|
| 410 | + $xmdf = $sat->tle->xmo + $sat->deep_arg->xmdot*$tsince; |
|
| 411 | + $sat->deep_arg->omgadf = $sat->tle->omegao + $sat->deep_arg->omgdot*$tsince; |
|
| 412 | + $xnoddf = $sat->tle->xnodeo + $sat->deep_arg->xnodot*$tsince; |
|
| 413 | + $tsq = $tsince*$tsince; |
|
| 414 | + $sat->deep_arg->xnode = $xnoddf + $sat->sgps->xnodcf*$tsq; |
|
| 415 | + $tempa = 1.0 - $sat->sgps->c1*$tsince; |
|
| 416 | + $tempe = $sat->tle->bstar*$sat->sgps->c4*$tsince; |
|
| 417 | + $templ = $sat->sgps->t2cof*$tsq; |
|
| 418 | 418 | $sat->deep_arg->xn = $sat->deep_arg->xnodp; |
| 419 | 419 | |
| 420 | 420 | /* Update for deep-space secular effects */ |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | $this->Deep(self::dpsec, $sat); |
| 425 | 425 | |
| 426 | 426 | $xmdf = $sat->deep_arg->xll; |
| 427 | - $a = pow(Predict::xke / $sat->deep_arg->xn, Predict::tothrd) * $tempa * $tempa; |
|
| 427 | + $a = pow(Predict::xke/$sat->deep_arg->xn, Predict::tothrd)*$tempa*$tempa; |
|
| 428 | 428 | $sat->deep_arg->em = $sat->deep_arg->em - $tempe; |
| 429 | - $xmam = $xmdf + $sat->deep_arg->xnodp * $templ; |
|
| 429 | + $xmam = $xmdf + $sat->deep_arg->xnodp*$templ; |
|
| 430 | 430 | |
| 431 | 431 | /* Update for deep-space periodic effects */ |
| 432 | 432 | $sat->deep_arg->xll = $xmam; |
@@ -435,30 +435,30 @@ discard block |
||
| 435 | 435 | |
| 436 | 436 | $xmam = $sat->deep_arg->xll; |
| 437 | 437 | $xl = $xmam + $sat->deep_arg->omgadf + $sat->deep_arg->xnode; |
| 438 | - $beta = sqrt(1.0 - $sat->deep_arg->em * $sat->deep_arg->em); |
|
| 439 | - $sat->deep_arg->xn = Predict::xke / pow($a, 1.5); |
|
| 438 | + $beta = sqrt(1.0 - $sat->deep_arg->em*$sat->deep_arg->em); |
|
| 439 | + $sat->deep_arg->xn = Predict::xke/pow($a, 1.5); |
|
| 440 | 440 | |
| 441 | 441 | /* Long period periodics */ |
| 442 | - $axn = $sat->deep_arg->em * cos($sat->deep_arg->omgadf); |
|
| 443 | - $temp = 1.0 / ($a * $beta * $beta); |
|
| 444 | - $xll = $temp * $sat->sgps->xlcof * $axn; |
|
| 445 | - $aynl = $temp * $sat->sgps->aycof; |
|
| 442 | + $axn = $sat->deep_arg->em*cos($sat->deep_arg->omgadf); |
|
| 443 | + $temp = 1.0/($a*$beta*$beta); |
|
| 444 | + $xll = $temp*$sat->sgps->xlcof*$axn; |
|
| 445 | + $aynl = $temp*$sat->sgps->aycof; |
|
| 446 | 446 | $xlt = $xl + $xll; |
| 447 | - $ayn = $sat->deep_arg->em * sin($sat->deep_arg->omgadf) + $aynl; |
|
| 447 | + $ayn = $sat->deep_arg->em*sin($sat->deep_arg->omgadf) + $aynl; |
|
| 448 | 448 | |
| 449 | 449 | /* Solve Kepler's Equation */ |
| 450 | - $capu = Predict_Math::FMod2p ($xlt - $sat->deep_arg->xnode); |
|
| 450 | + $capu = Predict_Math::FMod2p($xlt - $sat->deep_arg->xnode); |
|
| 451 | 451 | $temp2 = $capu; |
| 452 | 452 | |
| 453 | 453 | $i = 0; |
| 454 | 454 | do { |
| 455 | 455 | $sinepw = sin($temp2); |
| 456 | 456 | $cosepw = cos($temp2); |
| 457 | - $temp3 = $axn * $sinepw; |
|
| 458 | - $temp4 = $ayn * $cosepw; |
|
| 459 | - $temp5 = $axn * $cosepw; |
|
| 460 | - $temp6 = $ayn * $sinepw; |
|
| 461 | - $epw = ($capu - $temp4 + $temp3 - $temp2) / (1.0 - $temp5 - $temp6) + $temp2; |
|
| 457 | + $temp3 = $axn*$sinepw; |
|
| 458 | + $temp4 = $ayn*$cosepw; |
|
| 459 | + $temp5 = $axn*$cosepw; |
|
| 460 | + $temp6 = $ayn*$sinepw; |
|
| 461 | + $epw = ($capu - $temp4 + $temp3 - $temp2)/(1.0 - $temp5 - $temp6) + $temp2; |
|
| 462 | 462 | if (abs($epw - $temp2) <= Predict::e6a) { |
| 463 | 463 | break; |
| 464 | 464 | } |
@@ -468,35 +468,35 @@ discard block |
||
| 468 | 468 | /* Short period preliminary quantities */ |
| 469 | 469 | $ecose = $temp5 + $temp6; |
| 470 | 470 | $esine = $temp3 - $temp4; |
| 471 | - $elsq = $axn * $axn + $ayn * $ayn; |
|
| 471 | + $elsq = $axn*$axn + $ayn*$ayn; |
|
| 472 | 472 | $temp = 1.0 - $elsq; |
| 473 | - $pl = $a * $temp; |
|
| 474 | - $r = $a * (1.0 - $ecose); |
|
| 475 | - $temp1 = 1.0 / $r; |
|
| 476 | - $rdot = Predict::xke * sqrt($a) * $esine * $temp1; |
|
| 477 | - $rfdot = Predict::xke * sqrt($pl) * $temp1; |
|
| 478 | - $temp2 = $a * $temp1; |
|
| 473 | + $pl = $a*$temp; |
|
| 474 | + $r = $a*(1.0 - $ecose); |
|
| 475 | + $temp1 = 1.0/$r; |
|
| 476 | + $rdot = Predict::xke*sqrt($a)*$esine*$temp1; |
|
| 477 | + $rfdot = Predict::xke*sqrt($pl)*$temp1; |
|
| 478 | + $temp2 = $a*$temp1; |
|
| 479 | 479 | $betal = sqrt($temp); |
| 480 | - $temp3 = 1.0 / (1.0 + $betal); |
|
| 481 | - $cosu = $temp2 * ($cosepw - $axn + $ayn * $esine * $temp3); |
|
| 482 | - $sinu = $temp2 * ($sinepw - $ayn - $axn * $esine * $temp3); |
|
| 480 | + $temp3 = 1.0/(1.0 + $betal); |
|
| 481 | + $cosu = $temp2*($cosepw - $axn + $ayn*$esine*$temp3); |
|
| 482 | + $sinu = $temp2*($sinepw - $ayn - $axn*$esine*$temp3); |
|
| 483 | 483 | $u = Predict_Math::AcTan($sinu, $cosu); |
| 484 | - $sin2u = 2.0 * $sinu * $cosu; |
|
| 485 | - $cos2u = 2.0 * $cosu * $cosu - 1.0; |
|
| 486 | - $temp = 1.0 / $pl; |
|
| 487 | - $temp1 = Predict::ck2 * $temp; |
|
| 488 | - $temp2 = $temp1 * $temp; |
|
| 484 | + $sin2u = 2.0*$sinu*$cosu; |
|
| 485 | + $cos2u = 2.0*$cosu*$cosu - 1.0; |
|
| 486 | + $temp = 1.0/$pl; |
|
| 487 | + $temp1 = Predict::ck2*$temp; |
|
| 488 | + $temp2 = $temp1*$temp; |
|
| 489 | 489 | |
| 490 | 490 | /* Update for short periodics */ |
| 491 | - $rk = $r * (1.0 - 1.5 * $temp2 * $betal * $sat->sgps->x3thm1) + |
|
| 492 | - 0.5 * $temp1 * $sat->sgps->x1mth2 * $cos2u; |
|
| 493 | - $uk = $u - 0.25 * $temp2 * $sat->sgps->x7thm1 * $sin2u; |
|
| 494 | - $xnodek = $sat->deep_arg->xnode + 1.5 * $temp2 * $sat->deep_arg->cosio * $sin2u; |
|
| 495 | - $xinck = $sat->deep_arg->xinc + 1.5 * $temp2 * |
|
| 496 | - $sat->deep_arg->cosio * $sat->deep_arg->sinio * $cos2u; |
|
| 497 | - $rdotk = $rdot - $sat->deep_arg->xn * $temp1 * $sat->sgps->x1mth2 * $sin2u; |
|
| 498 | - $rfdotk = $rfdot + $sat->deep_arg->xn * $temp1 * |
|
| 499 | - ($sat->sgps->x1mth2 * $cos2u + 1.5 * $sat->sgps->x3thm1); |
|
| 491 | + $rk = $r*(1.0 - 1.5*$temp2*$betal*$sat->sgps->x3thm1) + |
|
| 492 | + 0.5*$temp1*$sat->sgps->x1mth2*$cos2u; |
|
| 493 | + $uk = $u - 0.25*$temp2*$sat->sgps->x7thm1*$sin2u; |
|
| 494 | + $xnodek = $sat->deep_arg->xnode + 1.5*$temp2*$sat->deep_arg->cosio*$sin2u; |
|
| 495 | + $xinck = $sat->deep_arg->xinc + 1.5*$temp2* |
|
| 496 | + $sat->deep_arg->cosio*$sat->deep_arg->sinio*$cos2u; |
|
| 497 | + $rdotk = $rdot - $sat->deep_arg->xn*$temp1*$sat->sgps->x1mth2*$sin2u; |
|
| 498 | + $rfdotk = $rfdot + $sat->deep_arg->xn*$temp1* |
|
| 499 | + ($sat->sgps->x1mth2*$cos2u + 1.5*$sat->sgps->x3thm1); |
|
| 500 | 500 | |
| 501 | 501 | /* Orientation vectors */ |
| 502 | 502 | $sinuk = sin($uk); |
@@ -505,29 +505,29 @@ discard block |
||
| 505 | 505 | $cosik = cos($xinck); |
| 506 | 506 | $sinnok = sin($xnodek); |
| 507 | 507 | $cosnok = cos($xnodek); |
| 508 | - $xmx = -$sinnok * $cosik; |
|
| 509 | - $xmy = $cosnok * $cosik; |
|
| 510 | - $ux = $xmx * $sinuk + $cosnok * $cosuk; |
|
| 511 | - $uy = $xmy * $sinuk + $sinnok * $cosuk; |
|
| 512 | - $uz = $sinik * $sinuk; |
|
| 513 | - $vx = $xmx * $cosuk - $cosnok * $sinuk; |
|
| 514 | - $vy = $xmy * $cosuk - $sinnok * $sinuk; |
|
| 515 | - $vz = $sinik * $cosuk; |
|
| 508 | + $xmx = -$sinnok*$cosik; |
|
| 509 | + $xmy = $cosnok*$cosik; |
|
| 510 | + $ux = $xmx*$sinuk + $cosnok*$cosuk; |
|
| 511 | + $uy = $xmy*$sinuk + $sinnok*$cosuk; |
|
| 512 | + $uz = $sinik*$sinuk; |
|
| 513 | + $vx = $xmx*$cosuk - $cosnok*$sinuk; |
|
| 514 | + $vy = $xmy*$cosuk - $sinnok*$sinuk; |
|
| 515 | + $vz = $sinik*$cosuk; |
|
| 516 | 516 | |
| 517 | 517 | /* Position and velocity */ |
| 518 | - $sat->pos->x = $rk * $ux; |
|
| 519 | - $sat->pos->y = $rk * $uy; |
|
| 520 | - $sat->pos->z = $rk * $uz; |
|
| 521 | - $sat->vel->x = $rdotk * $ux + $rfdotk * $vx; |
|
| 522 | - $sat->vel->y = $rdotk * $uy + $rfdotk * $vy; |
|
| 523 | - $sat->vel->z = $rdotk * $uz + $rfdotk * $vz; |
|
| 518 | + $sat->pos->x = $rk*$ux; |
|
| 519 | + $sat->pos->y = $rk*$uy; |
|
| 520 | + $sat->pos->z = $rk*$uz; |
|
| 521 | + $sat->vel->x = $rdotk*$ux + $rfdotk*$vx; |
|
| 522 | + $sat->vel->y = $rdotk*$uy + $rfdotk*$vy; |
|
| 523 | + $sat->vel->z = $rdotk*$uz + $rfdotk*$vz; |
|
| 524 | 524 | |
| 525 | 525 | /* Phase in rads */ |
| 526 | 526 | $sat->phase = $xlt - $sat->deep_arg->xnode - $sat->deep_arg->omgadf + Predict::twopi; |
| 527 | 527 | if ($sat->phase < 0.0) { |
| 528 | 528 | $sat->phase += Predict::twopi; |
| 529 | 529 | } |
| 530 | - $sat->phase = Predict_Math::FMod2p ($sat->phase); |
|
| 530 | + $sat->phase = Predict_Math::FMod2p($sat->phase); |
|
| 531 | 531 | |
| 532 | 532 | $sat->tle->omegao1 = $sat->deep_arg->omgadf; |
| 533 | 533 | $sat->tle->xincl1 = $sat->deep_arg->xinc; |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | $sat->dps->thgr = Predict_Time::ThetaG($sat->tle->epoch, $sat->deep_arg); |
| 546 | 546 | $eq = $sat->tle->eo; |
| 547 | 547 | $sat->dps->xnq = $sat->deep_arg->xnodp; |
| 548 | - $aqnv = 1.0 / $sat->deep_arg->aodp; |
|
| 548 | + $aqnv = 1.0/$sat->deep_arg->aodp; |
|
| 549 | 549 | $sat->dps->xqncl = $sat->tle->xincl; |
| 550 | 550 | $xmao = $sat->tle->xmo; |
| 551 | 551 | $xpidot = $sat->deep_arg->omgdot + $sat->deep_arg->xnodot; |
@@ -555,26 +555,26 @@ discard block |
||
| 555 | 555 | $sat->dps->preep = 0; |
| 556 | 556 | |
| 557 | 557 | /* Initialize lunar solar terms */ |
| 558 | - $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 558 | + $day = $sat->deep_arg->ds50 + 18261.5; /* Days since 1900 Jan 0.5 */ |
|
| 559 | 559 | if ($day != $sat->dps->preep) { |
| 560 | 560 | $sat->dps->preep = $day; |
| 561 | - $xnodce = 4.5236020 - 9.2422029E-4 * $day; |
|
| 561 | + $xnodce = 4.5236020 - 9.2422029E-4*$day; |
|
| 562 | 562 | $stem = sin($xnodce); |
| 563 | 563 | $ctem = cos($xnodce); |
| 564 | - $sat->dps->zcosil = 0.91375164 - 0.03568096 * $ctem; |
|
| 565 | - $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil * $sat->dps->zcosil); |
|
| 566 | - $sat->dps->zsinhl = 0.089683511 * $stem / $sat->dps->zsinil; |
|
| 567 | - $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl * $sat->dps->zsinhl); |
|
| 568 | - $c = 4.7199672 + 0.22997150 * $day; |
|
| 569 | - $gam = 5.8351514 + 0.0019443680 * $day; |
|
| 564 | + $sat->dps->zcosil = 0.91375164 - 0.03568096*$ctem; |
|
| 565 | + $sat->dps->zsinil = sqrt(1.0 - $sat->dps->zcosil*$sat->dps->zcosil); |
|
| 566 | + $sat->dps->zsinhl = 0.089683511*$stem/$sat->dps->zsinil; |
|
| 567 | + $sat->dps->zcoshl = sqrt(1.0 - $sat->dps->zsinhl*$sat->dps->zsinhl); |
|
| 568 | + $c = 4.7199672 + 0.22997150*$day; |
|
| 569 | + $gam = 5.8351514 + 0.0019443680*$day; |
|
| 570 | 570 | $sat->dps->zmol = Predict_Math::FMod2p($c - $gam); |
| 571 | - $zx = 0.39785416 * $stem / $sat->dps->zsinil; |
|
| 572 | - $zy = $sat->dps->zcoshl * $ctem + 0.91744867 * $sat->dps->zsinhl * $stem; |
|
| 571 | + $zx = 0.39785416*$stem/$sat->dps->zsinil; |
|
| 572 | + $zy = $sat->dps->zcoshl*$ctem + 0.91744867*$sat->dps->zsinhl*$stem; |
|
| 573 | 573 | $zx = Predict_Math::AcTan($zx, $zy); |
| 574 | 574 | $zx = $gam + $zx - $xnodce; |
| 575 | 575 | $sat->dps->zcosgl = cos($zx); |
| 576 | 576 | $sat->dps->zsingl = sin($zx); |
| 577 | - $sat->dps->zmos = 6.2565837 + 0.017201977 * $day; |
|
| 577 | + $sat->dps->zmos = 6.2565837 + 0.017201977*$day; |
|
| 578 | 578 | $sat->dps->zmos = Predict_Math::FMod2p($sat->dps->zmos); |
| 579 | 579 | } /* End if(day != preep) */ |
| 580 | 580 | |
@@ -590,76 +590,76 @@ discard block |
||
| 590 | 590 | $zn = Predict::zns; |
| 591 | 591 | $ze = Predict::zes; |
| 592 | 592 | $zmo = $sat->dps->zmos; |
| 593 | - $xnoi = 1.0 / $sat->dps->xnq; |
|
| 593 | + $xnoi = 1.0/$sat->dps->xnq; |
|
| 594 | 594 | |
| 595 | 595 | /* Loop breaks when Solar terms are done a second */ |
| 596 | 596 | /* time, after Lunar terms are initialized */ |
| 597 | - for(;;) { |
|
| 597 | + for (;;) { |
|
| 598 | 598 | /* Solar terms done again after Lunar terms are done */ |
| 599 | - $a1 = $zcosg * $zcosh + $zsing * $zcosi * $zsinh; |
|
| 600 | - $a3 = -$zsing * $zcosh + $zcosg * $zcosi * $zsinh; |
|
| 601 | - $a7 = -$zcosg * $zsinh + $zsing * $zcosi * $zcosh; |
|
| 602 | - $a8 = $zsing * $zsini; |
|
| 603 | - $a9 = $zsing * $zsinh + $zcosg * $zcosi * $zcosh; |
|
| 604 | - $a10 = $zcosg * $zsini; |
|
| 605 | - $a2 = $sat->deep_arg->cosio * $a7 + $sat->deep_arg->sinio * $a8; |
|
| 606 | - $a4 = $sat->deep_arg->cosio * $a9 + $sat->deep_arg->sinio * $a10; |
|
| 607 | - $a5 = -$sat->deep_arg->sinio * $a7 + $sat->deep_arg->cosio * $a8; |
|
| 608 | - $a6 = -$sat->deep_arg->sinio * $a9 + $sat->deep_arg->cosio * $a10; |
|
| 609 | - $x1 = $a1 * $sat->deep_arg->cosg + $a2 * $sat->deep_arg->sing; |
|
| 610 | - $x2 = $a3 * $sat->deep_arg->cosg + $a4 * $sat->deep_arg->sing; |
|
| 611 | - $x3 = -$a1 * $sat->deep_arg->sing + $a2 * $sat->deep_arg->cosg; |
|
| 612 | - $x4 = -$a3 * $sat->deep_arg->sing + $a4 * $sat->deep_arg->cosg; |
|
| 613 | - $x5 = $a5 * $sat->deep_arg->sing; |
|
| 614 | - $x6 = $a6 * $sat->deep_arg->sing; |
|
| 615 | - $x7 = $a5 * $sat->deep_arg->cosg; |
|
| 616 | - $x8 = $a6 * $sat->deep_arg->cosg; |
|
| 617 | - $z31 = 12 * $x1 * $x1 - 3 * $x3 * $x3; |
|
| 618 | - $z32 = 24 * $x1 * $x2 - 6 * $x3 * $x4; |
|
| 619 | - $z33 = 12 * $x2 * $x2 - 3 * $x4 * $x4; |
|
| 620 | - $z1 = 3 * ($a1 * $a1 + $a2 * $a2) + $z31 * $sat->deep_arg->eosq; |
|
| 621 | - $z2 = 6 * ($a1 * $a3 + $a2 * $a4) + $z32 * $sat->deep_arg->eosq; |
|
| 622 | - $z3 = 3 * ($a3 * $a3 + $a4 * $a4) + $z33 * $sat->deep_arg->eosq; |
|
| 623 | - $z11 = -6 * $a1 * $a5 + $sat->deep_arg->eosq * (-24 * $x1 * $x7 - 6 * $x3 * $x5); |
|
| 624 | - $z12 = -6 * ($a1 * $a6 + $a3 * $a5) + $sat->deep_arg->eosq * |
|
| 625 | - (-24 * ($x2 * $x7 + $x1 * $x8) - 6 * ($x3 * $x6 + $x4 * $x5)); |
|
| 626 | - $z13 = -6 * $a3 * $a6 + $sat->deep_arg->eosq * (-24 * $x2 * $x8 - 6 * $x4 * $x6); |
|
| 627 | - $z21 = 6 * $a2 * $a5 + $sat->deep_arg->eosq * (24 * $x1 * $x5 - 6 * $x3 * $x7); |
|
| 628 | - $z22 = 6 * ($a4 * $a5 + $a2 * $a6) + $sat->deep_arg->eosq * |
|
| 629 | - (24 * ($x2 * $x5 + $x1 * $x6) - 6 * ($x4 * $x7 + $x3 * $x8)); |
|
| 630 | - $z23 = 6 * $a4 * $a6 + $sat->deep_arg->eosq * (24 * $x2 * $x6 - 6 * $x4 * $x8); |
|
| 631 | - $z1 = $z1 + $z1 + $sat->deep_arg->betao2 * $z31; |
|
| 632 | - $z2 = $z2 + $z2 + $sat->deep_arg->betao2 * $z32; |
|
| 633 | - $z3 = $z3 + $z3 + $sat->deep_arg->betao2 * $z33; |
|
| 634 | - $s3 = $cc * $xnoi; |
|
| 635 | - $s2 = -0.5 * $s3 / $sat->deep_arg->betao; |
|
| 636 | - $s4 = $s3 * $sat->deep_arg->betao; |
|
| 637 | - $s1 = -15 * $eq * $s4; |
|
| 638 | - $s5 = $x1 * $x3 + $x2 * $x4; |
|
| 639 | - $s6 = $x2 * $x3 + $x1 * $x4; |
|
| 640 | - $s7 = $x2 * $x4 - $x1 * $x3; |
|
| 641 | - $se = $s1 * $zn * $s5; |
|
| 642 | - $si = $s2 * $zn * ($z11 + $z13); |
|
| 643 | - $sl = -$zn * $s3 * ($z1 + $z3 - 14 - 6 * $sat->deep_arg->eosq); |
|
| 644 | - $sgh = $s4 * $zn * ($z31 + $z33 - 6); |
|
| 645 | - $sh = -$zn * $s2 * ($z21 + $z23); |
|
| 599 | + $a1 = $zcosg*$zcosh + $zsing*$zcosi*$zsinh; |
|
| 600 | + $a3 = -$zsing*$zcosh + $zcosg*$zcosi*$zsinh; |
|
| 601 | + $a7 = -$zcosg*$zsinh + $zsing*$zcosi*$zcosh; |
|
| 602 | + $a8 = $zsing*$zsini; |
|
| 603 | + $a9 = $zsing*$zsinh + $zcosg*$zcosi*$zcosh; |
|
| 604 | + $a10 = $zcosg*$zsini; |
|
| 605 | + $a2 = $sat->deep_arg->cosio*$a7 + $sat->deep_arg->sinio*$a8; |
|
| 606 | + $a4 = $sat->deep_arg->cosio*$a9 + $sat->deep_arg->sinio*$a10; |
|
| 607 | + $a5 = -$sat->deep_arg->sinio*$a7 + $sat->deep_arg->cosio*$a8; |
|
| 608 | + $a6 = -$sat->deep_arg->sinio*$a9 + $sat->deep_arg->cosio*$a10; |
|
| 609 | + $x1 = $a1*$sat->deep_arg->cosg + $a2*$sat->deep_arg->sing; |
|
| 610 | + $x2 = $a3*$sat->deep_arg->cosg + $a4*$sat->deep_arg->sing; |
|
| 611 | + $x3 = -$a1*$sat->deep_arg->sing + $a2*$sat->deep_arg->cosg; |
|
| 612 | + $x4 = -$a3*$sat->deep_arg->sing + $a4*$sat->deep_arg->cosg; |
|
| 613 | + $x5 = $a5*$sat->deep_arg->sing; |
|
| 614 | + $x6 = $a6*$sat->deep_arg->sing; |
|
| 615 | + $x7 = $a5*$sat->deep_arg->cosg; |
|
| 616 | + $x8 = $a6*$sat->deep_arg->cosg; |
|
| 617 | + $z31 = 12*$x1*$x1 - 3*$x3*$x3; |
|
| 618 | + $z32 = 24*$x1*$x2 - 6*$x3*$x4; |
|
| 619 | + $z33 = 12*$x2*$x2 - 3*$x4*$x4; |
|
| 620 | + $z1 = 3*($a1*$a1 + $a2*$a2) + $z31*$sat->deep_arg->eosq; |
|
| 621 | + $z2 = 6*($a1*$a3 + $a2*$a4) + $z32*$sat->deep_arg->eosq; |
|
| 622 | + $z3 = 3*($a3*$a3 + $a4*$a4) + $z33*$sat->deep_arg->eosq; |
|
| 623 | + $z11 = -6*$a1*$a5 + $sat->deep_arg->eosq*(-24*$x1*$x7 - 6*$x3*$x5); |
|
| 624 | + $z12 = -6*($a1*$a6 + $a3*$a5) + $sat->deep_arg->eosq* |
|
| 625 | + (-24*($x2*$x7 + $x1*$x8) - 6*($x3*$x6 + $x4*$x5)); |
|
| 626 | + $z13 = -6*$a3*$a6 + $sat->deep_arg->eosq*(-24*$x2*$x8 - 6*$x4*$x6); |
|
| 627 | + $z21 = 6*$a2*$a5 + $sat->deep_arg->eosq*(24*$x1*$x5 - 6*$x3*$x7); |
|
| 628 | + $z22 = 6*($a4*$a5 + $a2*$a6) + $sat->deep_arg->eosq* |
|
| 629 | + (24*($x2*$x5 + $x1*$x6) - 6*($x4*$x7 + $x3*$x8)); |
|
| 630 | + $z23 = 6*$a4*$a6 + $sat->deep_arg->eosq*(24*$x2*$x6 - 6*$x4*$x8); |
|
| 631 | + $z1 = $z1 + $z1 + $sat->deep_arg->betao2*$z31; |
|
| 632 | + $z2 = $z2 + $z2 + $sat->deep_arg->betao2*$z32; |
|
| 633 | + $z3 = $z3 + $z3 + $sat->deep_arg->betao2*$z33; |
|
| 634 | + $s3 = $cc*$xnoi; |
|
| 635 | + $s2 = -0.5*$s3/$sat->deep_arg->betao; |
|
| 636 | + $s4 = $s3*$sat->deep_arg->betao; |
|
| 637 | + $s1 = -15*$eq*$s4; |
|
| 638 | + $s5 = $x1*$x3 + $x2*$x4; |
|
| 639 | + $s6 = $x2*$x3 + $x1*$x4; |
|
| 640 | + $s7 = $x2*$x4 - $x1*$x3; |
|
| 641 | + $se = $s1*$zn*$s5; |
|
| 642 | + $si = $s2*$zn*($z11 + $z13); |
|
| 643 | + $sl = -$zn*$s3*($z1 + $z3 - 14 - 6*$sat->deep_arg->eosq); |
|
| 644 | + $sgh = $s4*$zn*($z31 + $z33 - 6); |
|
| 645 | + $sh = -$zn*$s2*($z21 + $z23); |
|
| 646 | 646 | if ($sat->dps->xqncl < 5.2359877E-2) { |
| 647 | 647 | $sh = 0; |
| 648 | 648 | } |
| 649 | - $sat->dps->ee2 = 2 * $s1 * $s6; |
|
| 650 | - $sat->dps->e3 = 2 * $s1 * $s7; |
|
| 651 | - $sat->dps->xi2 = 2 * $s2 * $z12; |
|
| 652 | - $sat->dps->xi3 = 2 * $s2 * ($z13 - $z11); |
|
| 653 | - $sat->dps->xl2 = -2 * $s3 * $z2; |
|
| 654 | - $sat->dps->xl3 = -2 * $s3 * ($z3 - $z1); |
|
| 655 | - $sat->dps->xl4 = -2 * $s3 * (-21 - 9 * $sat->deep_arg->eosq) * $ze; |
|
| 656 | - $sat->dps->xgh2 = 2 * $s4 * $z32; |
|
| 657 | - $sat->dps->xgh3 = 2 * $s4 * ($z33 - $z31); |
|
| 658 | - $sat->dps->xgh4 = -18 * $s4 * $ze; |
|
| 659 | - $sat->dps->xh2 = -2 * $s2 * $z22; |
|
| 660 | - $sat->dps->xh3 = -2 * $s2 * ($z23 - $z21); |
|
| 661 | - |
|
| 662 | - if ($sat->flags & self::LUNAR_TERMS_DONE_FLAG) { |
|
| 649 | + $sat->dps->ee2 = 2*$s1*$s6; |
|
| 650 | + $sat->dps->e3 = 2*$s1*$s7; |
|
| 651 | + $sat->dps->xi2 = 2*$s2*$z12; |
|
| 652 | + $sat->dps->xi3 = 2*$s2*($z13 - $z11); |
|
| 653 | + $sat->dps->xl2 = -2*$s3*$z2; |
|
| 654 | + $sat->dps->xl3 = -2*$s3*($z3 - $z1); |
|
| 655 | + $sat->dps->xl4 = -2*$s3*(-21 - 9*$sat->deep_arg->eosq)*$ze; |
|
| 656 | + $sat->dps->xgh2 = 2*$s4*$z32; |
|
| 657 | + $sat->dps->xgh3 = 2*$s4*($z33 - $z31); |
|
| 658 | + $sat->dps->xgh4 = -18*$s4*$ze; |
|
| 659 | + $sat->dps->xh2 = -2*$s2*$z22; |
|
| 660 | + $sat->dps->xh3 = -2*$s2*($z23 - $z21); |
|
| 661 | + |
|
| 662 | + if ($sat->flags&self::LUNAR_TERMS_DONE_FLAG) { |
|
| 663 | 663 | break; |
| 664 | 664 | } |
| 665 | 665 | |
@@ -667,8 +667,8 @@ discard block |
||
| 667 | 667 | $sat->dps->sse = $se; |
| 668 | 668 | $sat->dps->ssi = $si; |
| 669 | 669 | $sat->dps->ssl = $sl; |
| 670 | - $sat->dps->ssh = $sh / $sat->deep_arg->sinio; |
|
| 671 | - $sat->dps->ssg = $sgh - $sat->deep_arg->cosio * $sat->dps->ssh; |
|
| 670 | + $sat->dps->ssh = $sh/$sat->deep_arg->sinio; |
|
| 671 | + $sat->dps->ssg = $sgh - $sat->deep_arg->cosio*$sat->dps->ssh; |
|
| 672 | 672 | $sat->dps->se2 = $sat->dps->ee2; |
| 673 | 673 | $sat->dps->si2 = $sat->dps->xi2; |
| 674 | 674 | $sat->dps->sl2 = $sat->dps->xl2; |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | $zsing = $sat->dps->zsingl; |
| 686 | 686 | $zcosi = $sat->dps->zcosil; |
| 687 | 687 | $zsini = $sat->dps->zsinil; |
| 688 | - $zcosh = $sat->dps->zcoshl * $cosq + $sat->dps->zsinhl * $sinq; |
|
| 689 | - $zsinh = $sinq * $sat->dps->zcoshl - $cosq * $sat->dps->zsinhl; |
|
| 688 | + $zcosh = $sat->dps->zcoshl*$cosq + $sat->dps->zsinhl*$sinq; |
|
| 689 | + $zsinh = $sinq*$sat->dps->zcoshl - $cosq*$sat->dps->zsinhl; |
|
| 690 | 690 | $zn = Predict::znl; |
| 691 | 691 | $cc = Predict::c1l; |
| 692 | 692 | $ze = Predict::zel; |
@@ -697,113 +697,113 @@ discard block |
||
| 697 | 697 | $sat->dps->sse = $sat->dps->sse + $se; |
| 698 | 698 | $sat->dps->ssi = $sat->dps->ssi + $si; |
| 699 | 699 | $sat->dps->ssl = $sat->dps->ssl + $sl; |
| 700 | - $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio / $sat->deep_arg->sinio * $sh; |
|
| 701 | - $sat->dps->ssh = $sat->dps->ssh + $sh / $sat->deep_arg->sinio; |
|
| 700 | + $sat->dps->ssg = $sat->dps->ssg + $sgh - $sat->deep_arg->cosio/$sat->deep_arg->sinio*$sh; |
|
| 701 | + $sat->dps->ssh = $sat->dps->ssh + $sh/$sat->deep_arg->sinio; |
|
| 702 | 702 | |
| 703 | 703 | /* Geopotential resonance initialization for 12 hour orbits */ |
| 704 | 704 | $sat->flags &= ~self::RESONANCE_FLAG; |
| 705 | 705 | $sat->flags &= ~self::SYNCHRONOUS_FLAG; |
| 706 | 706 | |
| 707 | 707 | if (!(($sat->dps->xnq < 0.0052359877) && ($sat->dps->xnq > 0.0034906585))) { |
| 708 | - if( ($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924) ) { |
|
| 708 | + if (($sat->dps->xnq < 0.00826) || ($sat->dps->xnq > 0.00924)) { |
|
| 709 | 709 | return; |
| 710 | 710 | } |
| 711 | 711 | if ($eq < 0.5) { |
| 712 | 712 | return; |
| 713 | 713 | } |
| 714 | 714 | $sat->flags |= self::RESONANCE_FLAG; |
| 715 | - $eoc = $eq * $sat->deep_arg->eosq; |
|
| 716 | - $g201 = -0.306 - ($eq - 0.64) * 0.440; |
|
| 715 | + $eoc = $eq*$sat->deep_arg->eosq; |
|
| 716 | + $g201 = -0.306 - ($eq - 0.64)*0.440; |
|
| 717 | 717 | if ($eq <= 0.65) { |
| 718 | - $g211 = 3.616 - 13.247 * $eq + 16.290 * $sat->deep_arg->eosq; |
|
| 719 | - $g310 = -19.302 + 117.390 * $eq - 228.419 * |
|
| 720 | - $sat->deep_arg->eosq + 156.591 * $eoc; |
|
| 721 | - $g322 = -18.9068 + 109.7927 * $eq - 214.6334 * |
|
| 722 | - $sat->deep_arg->eosq + 146.5816 * $eoc; |
|
| 723 | - $g410 = -41.122 + 242.694 * $eq - 471.094 * |
|
| 724 | - $sat->deep_arg->eosq + 313.953 * $eoc; |
|
| 725 | - $g422 = -146.407 + 841.880 * $eq - 1629.014 * |
|
| 726 | - $sat->deep_arg->eosq + 1083.435 * $eoc; |
|
| 727 | - $g520 = -532.114 + 3017.977 * $eq - 5740 * |
|
| 728 | - $sat->deep_arg->eosq + 3708.276 * $eoc; |
|
| 718 | + $g211 = 3.616 - 13.247*$eq + 16.290*$sat->deep_arg->eosq; |
|
| 719 | + $g310 = -19.302 + 117.390*$eq - 228.419* |
|
| 720 | + $sat->deep_arg->eosq + 156.591*$eoc; |
|
| 721 | + $g322 = -18.9068 + 109.7927*$eq - 214.6334* |
|
| 722 | + $sat->deep_arg->eosq + 146.5816*$eoc; |
|
| 723 | + $g410 = -41.122 + 242.694*$eq - 471.094* |
|
| 724 | + $sat->deep_arg->eosq + 313.953*$eoc; |
|
| 725 | + $g422 = -146.407 + 841.880*$eq - 1629.014* |
|
| 726 | + $sat->deep_arg->eosq + 1083.435*$eoc; |
|
| 727 | + $g520 = -532.114 + 3017.977*$eq - 5740* |
|
| 728 | + $sat->deep_arg->eosq + 3708.276*$eoc; |
|
| 729 | 729 | } else { |
| 730 | - $g211 = -72.099 + 331.819 * $eq - 508.738 * |
|
| 731 | - $sat->deep_arg->eosq + 266.724 * $eoc; |
|
| 732 | - $g310 = -346.844 + 1582.851 * $eq - 2415.925 * |
|
| 733 | - $sat->deep_arg->eosq + 1246.113 * $eoc; |
|
| 734 | - $g322 = -342.585 + 1554.908 * $eq - 2366.899 * |
|
| 735 | - $sat->deep_arg->eosq + 1215.972 * $eoc; |
|
| 736 | - $g410 = -1052.797 + 4758.686 * $eq - 7193.992 * |
|
| 737 | - $sat->deep_arg->eosq + 3651.957 * $eoc; |
|
| 738 | - $g422 = -3581.69 + 16178.11 * $eq - 24462.77 * |
|
| 739 | - $sat->deep_arg->eosq+ 12422.52 * $eoc; |
|
| 730 | + $g211 = -72.099 + 331.819*$eq - 508.738* |
|
| 731 | + $sat->deep_arg->eosq + 266.724*$eoc; |
|
| 732 | + $g310 = -346.844 + 1582.851*$eq - 2415.925* |
|
| 733 | + $sat->deep_arg->eosq + 1246.113*$eoc; |
|
| 734 | + $g322 = -342.585 + 1554.908*$eq - 2366.899* |
|
| 735 | + $sat->deep_arg->eosq + 1215.972*$eoc; |
|
| 736 | + $g410 = -1052.797 + 4758.686*$eq - 7193.992* |
|
| 737 | + $sat->deep_arg->eosq + 3651.957*$eoc; |
|
| 738 | + $g422 = -3581.69 + 16178.11*$eq - 24462.77* |
|
| 739 | + $sat->deep_arg->eosq + 12422.52*$eoc; |
|
| 740 | 740 | if ($eq <= 0.715) { |
| 741 | - $g520 = 1464.74 - 4664.75 * $eq + 3763.64 * $sat->deep_arg->eosq; |
|
| 741 | + $g520 = 1464.74 - 4664.75*$eq + 3763.64*$sat->deep_arg->eosq; |
|
| 742 | 742 | } else { |
| 743 | - $g520 = -5149.66 + 29936.92 * $eq - 54087.36 * |
|
| 744 | - $sat->deep_arg->eosq + 31324.56 * $eoc; |
|
| 743 | + $g520 = -5149.66 + 29936.92*$eq - 54087.36* |
|
| 744 | + $sat->deep_arg->eosq + 31324.56*$eoc; |
|
| 745 | 745 | } |
| 746 | 746 | } /* End if (eq <= 0.65) */ |
| 747 | 747 | |
| 748 | 748 | if ($eq < 0.7) { |
| 749 | - $g533 = -919.2277 + 4988.61 * $eq - 9064.77 * |
|
| 750 | - $sat->deep_arg->eosq + 5542.21 * $eoc; |
|
| 751 | - $g521 = -822.71072 + 4568.6173 * $eq - 8491.4146 * |
|
| 752 | - $sat->deep_arg->eosq + 5337.524 * $eoc; |
|
| 753 | - $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
|
| 754 | - $sat->deep_arg->eosq + 5341.4 * $eoc; |
|
| 749 | + $g533 = -919.2277 + 4988.61*$eq - 9064.77* |
|
| 750 | + $sat->deep_arg->eosq + 5542.21*$eoc; |
|
| 751 | + $g521 = -822.71072 + 4568.6173*$eq - 8491.4146* |
|
| 752 | + $sat->deep_arg->eosq + 5337.524*$eoc; |
|
| 753 | + $g532 = -853.666 + 4690.25*$eq - 8624.77* |
|
| 754 | + $sat->deep_arg->eosq + 5341.4*$eoc; |
|
| 755 | 755 | } |
| 756 | 756 | else { |
| 757 | - $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
|
| 758 | - $sat->deep_arg->eosq + 109377.94 * $eoc; |
|
| 759 | - $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
|
| 760 | - $sat->deep_arg->eosq + 146349.42 * $eoc; |
|
| 761 | - $g532 = -40023.88 + 170470.89 * $eq - 242699.48* |
|
| 762 | - $sat->deep_arg->eosq + 115605.82 * $eoc; |
|
| 757 | + $g533 = -37995.78 + 161616.52*$eq - 229838.2* |
|
| 758 | + $sat->deep_arg->eosq + 109377.94*$eoc; |
|
| 759 | + $g521 = -51752.104 + 218913.95*$eq - 309468.16* |
|
| 760 | + $sat->deep_arg->eosq + 146349.42*$eoc; |
|
| 761 | + $g532 = -40023.88 + 170470.89*$eq - 242699.48* |
|
| 762 | + $sat->deep_arg->eosq + 115605.82*$eoc; |
|
| 763 | 763 | } /* End if (eq <= 0.7) */ |
| 764 | 764 | |
| 765 | - $sini2 = $sat->deep_arg->sinio * $sat->deep_arg->sinio; |
|
| 766 | - $f220 = 0.75 * (1 + 2 * $sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | - $f221 = 1.5 * $sini2; |
|
| 768 | - $f321 = 1.875 * $sat->deep_arg->sinio * (1 - 2 * |
|
| 769 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 770 | - $f322 = -1.875 * $sat->deep_arg->sinio * (1 + 2* |
|
| 771 | - $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2); |
|
| 772 | - $f441 = 35 * $sini2 * $f220; |
|
| 773 | - $f442 = 39.3750 * $sini2 * $sini2; |
|
| 774 | - $f522 = 9.84375 * $sat->deep_arg->sinio * ($sini2 * (1 - 2 * $sat->deep_arg->cosio - 5 * |
|
| 775 | - $sat->deep_arg->theta2) + 0.33333333 * (-2 + 4 * $sat->deep_arg->cosio + |
|
| 776 | - 6 * $sat->deep_arg->theta2)); |
|
| 777 | - $f523 = $sat->deep_arg->sinio * (4.92187512 * $sini2 * (-2 - 4 * |
|
| 778 | - $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | - * (1 + 2 * $sat->deep_arg->cosio - 3 * $sat->deep_arg->theta2)); |
|
| 780 | - $f542 = 29.53125 * $sat->deep_arg->sinio * (2 - 8 * |
|
| 781 | - $sat->deep_arg->cosio + $sat->deep_arg->theta2 * |
|
| 782 | - (-12 + 8 * $sat->deep_arg->cosio + 10 * $sat->deep_arg->theta2)); |
|
| 783 | - $f543 = 29.53125 * $sat->deep_arg->sinio * (-2 - 8 * $sat->deep_arg->cosio + |
|
| 784 | - $sat->deep_arg->theta2 * (12 + 8 * $sat->deep_arg->cosio - 10 * |
|
| 765 | + $sini2 = $sat->deep_arg->sinio*$sat->deep_arg->sinio; |
|
| 766 | + $f220 = 0.75*(1 + 2*$sat->deep_arg->cosio + $sat->deep_arg->theta2); |
|
| 767 | + $f221 = 1.5*$sini2; |
|
| 768 | + $f321 = 1.875*$sat->deep_arg->sinio*(1 - 2* |
|
| 769 | + $sat->deep_arg->cosio - 3*$sat->deep_arg->theta2); |
|
| 770 | + $f322 = -1.875*$sat->deep_arg->sinio*(1 + 2* |
|
| 771 | + $sat->deep_arg->cosio - 3*$sat->deep_arg->theta2); |
|
| 772 | + $f441 = 35*$sini2*$f220; |
|
| 773 | + $f442 = 39.3750*$sini2*$sini2; |
|
| 774 | + $f522 = 9.84375*$sat->deep_arg->sinio*($sini2*(1 - 2*$sat->deep_arg->cosio - 5* |
|
| 775 | + $sat->deep_arg->theta2) + 0.33333333*(-2 + 4*$sat->deep_arg->cosio + |
|
| 776 | + 6*$sat->deep_arg->theta2)); |
|
| 777 | + $f523 = $sat->deep_arg->sinio*(4.92187512*$sini2*(-2 - 4* |
|
| 778 | + $sat->deep_arg->cosio + 10*$sat->deep_arg->theta2) + 6.56250012 |
|
| 779 | + * (1 + 2*$sat->deep_arg->cosio - 3*$sat->deep_arg->theta2)); |
|
| 780 | + $f542 = 29.53125*$sat->deep_arg->sinio*(2 - 8* |
|
| 781 | + $sat->deep_arg->cosio + $sat->deep_arg->theta2* |
|
| 782 | + (-12 + 8*$sat->deep_arg->cosio + 10*$sat->deep_arg->theta2)); |
|
| 783 | + $f543 = 29.53125*$sat->deep_arg->sinio*(-2 - 8*$sat->deep_arg->cosio + |
|
| 784 | + $sat->deep_arg->theta2*(12 + 8*$sat->deep_arg->cosio - 10* |
|
| 785 | 785 | $sat->deep_arg->theta2)); |
| 786 | - $xno2 = $sat->dps->xnq * $sat->dps->xnq; |
|
| 787 | - $ainv2 = $aqnv * $aqnv; |
|
| 788 | - $temp1 = 3 * $xno2 * $ainv2; |
|
| 789 | - $temp = $temp1 * Predict::root22; |
|
| 790 | - $sat->dps->d2201 = $temp * $f220 * $g201; |
|
| 791 | - $sat->dps->d2211 = $temp * $f221 * $g211; |
|
| 792 | - $temp1 = $temp1 * $aqnv; |
|
| 793 | - $temp = $temp1 * Predict::root32; |
|
| 794 | - $sat->dps->d3210 = $temp * $f321 * $g310; |
|
| 795 | - $sat->dps->d3222 = $temp * $f322 * $g322; |
|
| 796 | - $temp1 = $temp1 * $aqnv; |
|
| 797 | - $temp = 2 * $temp1 * Predict::root44; |
|
| 798 | - $sat->dps->d4410 = $temp * $f441 * $g410; |
|
| 799 | - $sat->dps->d4422 = $temp * $f442 * $g422; |
|
| 800 | - $temp1 = $temp1 * $aqnv; |
|
| 801 | - $temp = $temp1 * Predict::root52; |
|
| 802 | - $sat->dps->d5220 = $temp * $f522 * $g520; |
|
| 803 | - $sat->dps->d5232 = $temp * $f523 * $g532; |
|
| 804 | - $temp = 2 * $temp1 * Predict::root54; |
|
| 805 | - $sat->dps->d5421 = $temp * $f542 * $g521; |
|
| 806 | - $sat->dps->d5433 = $temp * $f543 * $g533; |
|
| 786 | + $xno2 = $sat->dps->xnq*$sat->dps->xnq; |
|
| 787 | + $ainv2 = $aqnv*$aqnv; |
|
| 788 | + $temp1 = 3*$xno2*$ainv2; |
|
| 789 | + $temp = $temp1*Predict::root22; |
|
| 790 | + $sat->dps->d2201 = $temp*$f220*$g201; |
|
| 791 | + $sat->dps->d2211 = $temp*$f221*$g211; |
|
| 792 | + $temp1 = $temp1*$aqnv; |
|
| 793 | + $temp = $temp1*Predict::root32; |
|
| 794 | + $sat->dps->d3210 = $temp*$f321*$g310; |
|
| 795 | + $sat->dps->d3222 = $temp*$f322*$g322; |
|
| 796 | + $temp1 = $temp1*$aqnv; |
|
| 797 | + $temp = 2*$temp1*Predict::root44; |
|
| 798 | + $sat->dps->d4410 = $temp*$f441*$g410; |
|
| 799 | + $sat->dps->d4422 = $temp*$f442*$g422; |
|
| 800 | + $temp1 = $temp1*$aqnv; |
|
| 801 | + $temp = $temp1*Predict::root52; |
|
| 802 | + $sat->dps->d5220 = $temp*$f522*$g520; |
|
| 803 | + $sat->dps->d5232 = $temp*$f523*$g532; |
|
| 804 | + $temp = 2*$temp1*Predict::root54; |
|
| 805 | + $sat->dps->d5421 = $temp*$f542*$g521; |
|
| 806 | + $sat->dps->d5433 = $temp*$f543*$g533; |
|
| 807 | 807 | $sat->dps->xlamo = $xmao + $sat->tle->xnodeo + $sat->tle->xnodeo - $sat->dps->thgr - $sat->dps->thgr; |
| 808 | 808 | $bfact = $sat->deep_arg->xmdot + $sat->deep_arg->xnodot + |
| 809 | 809 | $sat->deep_arg->xnodot - Predict::thdt - Predict::thdt; |
@@ -812,18 +812,18 @@ discard block |
||
| 812 | 812 | $sat->flags |= self::RESONANCE_FLAG; |
| 813 | 813 | $sat->flags |= self::SYNCHRONOUS_FLAG; |
| 814 | 814 | /* Synchronous resonance terms initialization */ |
| 815 | - $g200 = 1 + $sat->deep_arg->eosq * (-2.5 + 0.8125 * $sat->deep_arg->eosq); |
|
| 816 | - $g310 = 1 + 2 * $sat->deep_arg->eosq; |
|
| 817 | - $g300 = 1 + $sat->deep_arg->eosq * (-6 + 6.60937 * $sat->deep_arg->eosq); |
|
| 818 | - $f220 = 0.75 * (1 + $sat->deep_arg->cosio) * (1 + $sat->deep_arg->cosio); |
|
| 819 | - $f311 = 0.9375 * $sat->deep_arg->sinio * $sat->deep_arg->sinio * |
|
| 820 | - (1 + 3 * $sat->deep_arg->cosio) - 0.75 * (1 + $sat->deep_arg->cosio); |
|
| 815 | + $g200 = 1 + $sat->deep_arg->eosq*(-2.5 + 0.8125*$sat->deep_arg->eosq); |
|
| 816 | + $g310 = 1 + 2*$sat->deep_arg->eosq; |
|
| 817 | + $g300 = 1 + $sat->deep_arg->eosq*(-6 + 6.60937*$sat->deep_arg->eosq); |
|
| 818 | + $f220 = 0.75*(1 + $sat->deep_arg->cosio)*(1 + $sat->deep_arg->cosio); |
|
| 819 | + $f311 = 0.9375*$sat->deep_arg->sinio*$sat->deep_arg->sinio* |
|
| 820 | + (1 + 3*$sat->deep_arg->cosio) - 0.75*(1 + $sat->deep_arg->cosio); |
|
| 821 | 821 | $f330 = 1 + $sat->deep_arg->cosio; |
| 822 | - $f330 = 1.875 * $f330 * $f330 * $f330; |
|
| 823 | - $sat->dps->del1 = 3 * $sat->dps->xnq * $sat->dps->xnq * $aqnv * $aqnv; |
|
| 824 | - $sat->dps->del2 = 2 * $sat->dps->del1 * $f220 * $g200 * Predict::q22; |
|
| 825 | - $sat->dps->del3 = 3 * $sat->dps->del1 * $f330 * $g300 * Predict::q33 * $aqnv; |
|
| 826 | - $sat->dps->del1 = $sat->dps->del1 * $f311 * $g310 * Predict::q31 * $aqnv; |
|
| 822 | + $f330 = 1.875*$f330*$f330*$f330; |
|
| 823 | + $sat->dps->del1 = 3*$sat->dps->xnq*$sat->dps->xnq*$aqnv*$aqnv; |
|
| 824 | + $sat->dps->del2 = 2*$sat->dps->del1*$f220*$g200*Predict::q22; |
|
| 825 | + $sat->dps->del3 = 3*$sat->dps->del1*$f330*$g300*Predict::q33*$aqnv; |
|
| 826 | + $sat->dps->del1 = $sat->dps->del1*$f311*$g310*Predict::q31*$aqnv; |
|
| 827 | 827 | $sat->dps->fasx2 = 0.13130908; |
| 828 | 828 | $sat->dps->fasx4 = 2.8843198; |
| 829 | 829 | $sat->dps->fasx6 = 0.37448087; |
@@ -845,24 +845,24 @@ discard block |
||
| 845 | 845 | return; |
| 846 | 846 | |
| 847 | 847 | case self::dpsec: /* Entrance for deep space secular effects */ |
| 848 | - $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl * $sat->deep_arg->t; |
|
| 849 | - $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg * $sat->deep_arg->t; |
|
| 850 | - $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh * $sat->deep_arg->t; |
|
| 851 | - $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse * $sat->deep_arg->t; |
|
| 852 | - $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi * $sat->deep_arg->t; |
|
| 848 | + $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->ssl*$sat->deep_arg->t; |
|
| 849 | + $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $sat->dps->ssg*$sat->deep_arg->t; |
|
| 850 | + $sat->deep_arg->xnode = $sat->deep_arg->xnode + $sat->dps->ssh*$sat->deep_arg->t; |
|
| 851 | + $sat->deep_arg->em = $sat->tle->eo + $sat->dps->sse*$sat->deep_arg->t; |
|
| 852 | + $sat->deep_arg->xinc = $sat->tle->xincl + $sat->dps->ssi*$sat->deep_arg->t; |
|
| 853 | 853 | if ($sat->deep_arg->xinc < 0) { |
| 854 | 854 | $sat->deep_arg->xinc = -$sat->deep_arg->xinc; |
| 855 | 855 | $sat->deep_arg->xnode = $sat->deep_arg->xnode + Predict::pi; |
| 856 | 856 | $sat->deep_arg->omgadf = $sat->deep_arg->omgadf - Predict::pi; |
| 857 | 857 | } |
| 858 | - if(~$sat->flags & self::RESONANCE_FLAG ) { |
|
| 858 | + if (~$sat->flags&self::RESONANCE_FLAG) { |
|
| 859 | 859 | return; |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | do { |
| 863 | - if ( ($sat->dps->atime == 0) || |
|
| 863 | + if (($sat->dps->atime == 0) || |
|
| 864 | 864 | (($sat->deep_arg->t >= 0) && ($sat->dps->atime < 0)) || |
| 865 | - (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0)) ) { |
|
| 865 | + (($sat->deep_arg->t < 0) && ($sat->dps->atime >= 0))) { |
|
| 866 | 866 | /* Epoch restart */ |
| 867 | 867 | if ($sat->deep_arg->t >= 0) { |
| 868 | 868 | $delt = $sat->dps->stepp; |
@@ -899,59 +899,59 @@ discard block |
||
| 899 | 899 | } else { |
| 900 | 900 | $delt = $sat->dps->stepp; |
| 901 | 901 | } |
| 902 | - $sat->flags |= (self::DO_LOOP_FLAG | self::EPOCH_RESTART_FLAG); |
|
| 902 | + $sat->flags |= (self::DO_LOOP_FLAG|self::EPOCH_RESTART_FLAG); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | /* Dot terms calculated */ |
| 906 | - if ($sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 907 | - $xndot = $sat->dps->del1 * sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2 * sin(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | - + $sat->dps->del3 * sin(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | - $xnddt = $sat->dps->del1 * cos($sat->dps->xli - $sat->dps->fasx2) + 2 * $sat->dps->del2 * cos(2 * ($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | - + 3 * $sat->dps->del3 * cos(3 * ($sat->dps->xli - $sat->dps->fasx6)); |
|
| 906 | + if ($sat->flags&self::SYNCHRONOUS_FLAG) { |
|
| 907 | + $xndot = $sat->dps->del1*sin($sat->dps->xli - $sat->dps->fasx2) + $sat->dps->del2*sin(2*($sat->dps->xli - $sat->dps->fasx4)) |
|
| 908 | + + $sat->dps->del3*sin(3*($sat->dps->xli - $sat->dps->fasx6)); |
|
| 909 | + $xnddt = $sat->dps->del1*cos($sat->dps->xli - $sat->dps->fasx2) + 2*$sat->dps->del2*cos(2*($sat->dps->xli - $sat->dps->fasx4)) |
|
| 910 | + + 3*$sat->dps->del3*cos(3*($sat->dps->xli - $sat->dps->fasx6)); |
|
| 911 | 911 | } else { |
| 912 | - $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot * $sat->dps->atime; |
|
| 912 | + $xomi = $sat->dps->omegaq + $sat->deep_arg->omgdot*$sat->dps->atime; |
|
| 913 | 913 | $x2omi = $xomi + $xomi; |
| 914 | 914 | $x2li = $sat->dps->xli + $sat->dps->xli; |
| 915 | - $xndot = $sat->dps->d2201 * sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | - + $sat->dps->d2211 * sin($sat->dps->xli - Predict::g22) |
|
| 917 | - + $sat->dps->d3210 * sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | - + $sat->dps->d3222 * sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | - + $sat->dps->d4410 * sin($x2omi + $x2li- Predict::g44) |
|
| 920 | - + $sat->dps->d4422 * sin($x2li- Predict::g44) |
|
| 921 | - + $sat->dps->d5220 * sin($xomi + $sat->dps->xli- Predict::g52) |
|
| 922 | - + $sat->dps->d5232 * sin(-$xomi + $sat->dps->xli- Predict::g52) |
|
| 923 | - + $sat->dps->d5421 * sin($xomi + $x2li - Predict::g54) |
|
| 924 | - + $sat->dps->d5433 * sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | - $xnddt = $sat->dps->d2201 * cos($x2omi + $sat->dps->xli- Predict::g22) |
|
| 926 | - + $sat->dps->d2211 * cos($sat->dps->xli - Predict::g22) |
|
| 927 | - + $sat->dps->d3210 * cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | - + $sat->dps->d3222 * cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | - + $sat->dps->d5220 * cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | - + $sat->dps->d5232 * cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | - + 2 * ($sat->dps->d4410 * cos($x2omi + $x2li - Predict::g44) |
|
| 932 | - + $sat->dps->d4422 * cos($x2li - Predict::g44) |
|
| 933 | - + $sat->dps->d5421 * cos($xomi + $x2li - Predict::g54) |
|
| 934 | - + $sat->dps->d5433 * cos(-$xomi + $x2li - Predict::g54)); |
|
| 915 | + $xndot = $sat->dps->d2201*sin($x2omi + $sat->dps->xli - Predict::g22) |
|
| 916 | + + $sat->dps->d2211*sin($sat->dps->xli - Predict::g22) |
|
| 917 | + + $sat->dps->d3210*sin($xomi + $sat->dps->xli - Predict::g32) |
|
| 918 | + + $sat->dps->d3222*sin(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 919 | + + $sat->dps->d4410*sin($x2omi + $x2li - Predict::g44) |
|
| 920 | + + $sat->dps->d4422*sin($x2li - Predict::g44) |
|
| 921 | + + $sat->dps->d5220*sin($xomi + $sat->dps->xli - Predict::g52) |
|
| 922 | + + $sat->dps->d5232*sin(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 923 | + + $sat->dps->d5421*sin($xomi + $x2li - Predict::g54) |
|
| 924 | + + $sat->dps->d5433*sin(-$xomi + $x2li - Predict::g54); |
|
| 925 | + $xnddt = $sat->dps->d2201*cos($x2omi + $sat->dps->xli - Predict::g22) |
|
| 926 | + + $sat->dps->d2211*cos($sat->dps->xli - Predict::g22) |
|
| 927 | + + $sat->dps->d3210*cos($xomi + $sat->dps->xli - Predict::g32) |
|
| 928 | + + $sat->dps->d3222*cos(-$xomi + $sat->dps->xli - Predict::g32) |
|
| 929 | + + $sat->dps->d5220*cos($xomi + $sat->dps->xli - Predict::g52) |
|
| 930 | + + $sat->dps->d5232*cos(-$xomi + $sat->dps->xli - Predict::g52) |
|
| 931 | + + 2*($sat->dps->d4410*cos($x2omi + $x2li - Predict::g44) |
|
| 932 | + + $sat->dps->d4422*cos($x2li - Predict::g44) |
|
| 933 | + + $sat->dps->d5421*cos($xomi + $x2li - Predict::g54) |
|
| 934 | + + $sat->dps->d5433*cos(-$xomi + $x2li - Predict::g54)); |
|
| 935 | 935 | } /* End of if (isFlagSet(SYNCHRONOUS_FLAG)) */ |
| 936 | 936 | |
| 937 | 937 | $xldot = $sat->dps->xni + $sat->dps->xfact; |
| 938 | - $xnddt = $xnddt * $xldot; |
|
| 938 | + $xnddt = $xnddt*$xldot; |
|
| 939 | 939 | |
| 940 | - if ($sat->flags & self::DO_LOOP_FLAG) { |
|
| 941 | - $sat->dps->xli = $sat->dps->xli + $xldot * $delt + $xndot * $sat->dps->step2; |
|
| 942 | - $sat->dps->xni = $sat->dps->xni + $xndot * $delt + $xnddt * $sat->dps->step2; |
|
| 940 | + if ($sat->flags&self::DO_LOOP_FLAG) { |
|
| 941 | + $sat->dps->xli = $sat->dps->xli + $xldot*$delt + $xndot*$sat->dps->step2; |
|
| 942 | + $sat->dps->xni = $sat->dps->xni + $xndot*$delt + $xnddt*$sat->dps->step2; |
|
| 943 | 943 | $sat->dps->atime = $sat->dps->atime + $delt; |
| 944 | 944 | } |
| 945 | - } while (($sat->flags & self::DO_LOOP_FLAG) && |
|
| 946 | - (~$sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 945 | + } while (($sat->flags&self::DO_LOOP_FLAG) && |
|
| 946 | + (~$sat->flags&self::EPOCH_RESTART_FLAG)); |
|
| 947 | 947 | } |
| 948 | - while (($sat->flags & self::DO_LOOP_FLAG) && ($sat->flags & self::EPOCH_RESTART_FLAG)); |
|
| 948 | + while (($sat->flags&self::DO_LOOP_FLAG) && ($sat->flags&self::EPOCH_RESTART_FLAG)); |
|
| 949 | 949 | |
| 950 | - $sat->deep_arg->xn = $sat->dps->xni + $xndot * $ft + $xnddt * $ft * $ft * 0.5; |
|
| 951 | - $xl = $sat->dps->xli + $xldot * $ft + $xndot * $ft * $ft * 0.5; |
|
| 952 | - $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t * Predict::thdt; |
|
| 950 | + $sat->deep_arg->xn = $sat->dps->xni + $xndot*$ft + $xnddt*$ft*$ft*0.5; |
|
| 951 | + $xl = $sat->dps->xli + $xldot*$ft + $xndot*$ft*$ft*0.5; |
|
| 952 | + $temp = -$sat->deep_arg->xnode + $sat->dps->thgr + $sat->deep_arg->t*Predict::thdt; |
|
| 953 | 953 | |
| 954 | - if (~$sat->flags & self::SYNCHRONOUS_FLAG) { |
|
| 954 | + if (~$sat->flags&self::SYNCHRONOUS_FLAG) { |
|
| 955 | 955 | $sat->deep_arg->xll = $xl + $temp + $temp; |
| 956 | 956 | } else { |
| 957 | 957 | $sat->deep_arg->xll = $xl - $sat->deep_arg->omgadf + $temp; |
@@ -965,26 +965,26 @@ discard block |
||
| 965 | 965 | $cosis = cos($sat->deep_arg->xinc); |
| 966 | 966 | if (abs($sat->dps->savtsn - $sat->deep_arg->t) >= 30) { |
| 967 | 967 | $sat->dps->savtsn = $sat->deep_arg->t; |
| 968 | - $zm = $sat->dps->zmos + Predict::zns * $sat->deep_arg->t; |
|
| 969 | - $zf = $zm + 2 * Predict::zes * sin($zm); |
|
| 968 | + $zm = $sat->dps->zmos + Predict::zns*$sat->deep_arg->t; |
|
| 969 | + $zf = $zm + 2*Predict::zes*sin($zm); |
|
| 970 | 970 | $sinzf = sin($zf); |
| 971 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 972 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 973 | - $ses = $sat->dps->se2 * $f2 + $sat->dps->se3 * $f3; |
|
| 974 | - $sis = $sat->dps->si2 * $f2 + $sat->dps->si3 * $f3; |
|
| 975 | - $sls = $sat->dps->sl2 * $f2 + $sat->dps->sl3 * $f3 + $sat->dps->sl4 * $sinzf; |
|
| 976 | - $sat->dps->sghs = $sat->dps->sgh2 * $f2 + $sat->dps->sgh3 * $f3 + $sat->dps->sgh4 * $sinzf; |
|
| 977 | - $sat->dps->shs = $sat->dps->sh2 * $f2 + $sat->dps->sh3 * $f3; |
|
| 978 | - $zm = $sat->dps->zmol + Predict::znl * $sat->deep_arg->t; |
|
| 979 | - $zf = $zm + 2 * Predict::zel * sin($zm); |
|
| 971 | + $f2 = 0.5*$sinzf*$sinzf - 0.25; |
|
| 972 | + $f3 = -0.5*$sinzf*cos($zf); |
|
| 973 | + $ses = $sat->dps->se2*$f2 + $sat->dps->se3*$f3; |
|
| 974 | + $sis = $sat->dps->si2*$f2 + $sat->dps->si3*$f3; |
|
| 975 | + $sls = $sat->dps->sl2*$f2 + $sat->dps->sl3*$f3 + $sat->dps->sl4*$sinzf; |
|
| 976 | + $sat->dps->sghs = $sat->dps->sgh2*$f2 + $sat->dps->sgh3*$f3 + $sat->dps->sgh4*$sinzf; |
|
| 977 | + $sat->dps->shs = $sat->dps->sh2*$f2 + $sat->dps->sh3*$f3; |
|
| 978 | + $zm = $sat->dps->zmol + Predict::znl*$sat->deep_arg->t; |
|
| 979 | + $zf = $zm + 2*Predict::zel*sin($zm); |
|
| 980 | 980 | $sinzf = sin($zf); |
| 981 | - $f2 = 0.5 * $sinzf * $sinzf - 0.25; |
|
| 982 | - $f3 = -0.5 * $sinzf * cos($zf); |
|
| 983 | - $sel = $sat->dps->ee2 * $f2 + $sat->dps->e3 * $f3; |
|
| 984 | - $sil = $sat->dps->xi2 * $f2 + $sat->dps->xi3 * $f3; |
|
| 985 | - $sll = $sat->dps->xl2 * $f2 + $sat->dps->xl3 * $f3 + $sat->dps->xl4 * $sinzf; |
|
| 986 | - $sat->dps->sghl = $sat->dps->xgh2 * $f2 + $sat->dps->xgh3 * $f3 + $sat->dps->xgh4 * $sinzf; |
|
| 987 | - $sat->dps->sh1 = $sat->dps->xh2 * $f2 + $sat->dps->xh3 * $f3; |
|
| 981 | + $f2 = 0.5*$sinzf*$sinzf - 0.25; |
|
| 982 | + $f3 = -0.5*$sinzf*cos($zf); |
|
| 983 | + $sel = $sat->dps->ee2*$f2 + $sat->dps->e3*$f3; |
|
| 984 | + $sil = $sat->dps->xi2*$f2 + $sat->dps->xi3*$f3; |
|
| 985 | + $sll = $sat->dps->xl2*$f2 + $sat->dps->xl3*$f3 + $sat->dps->xl4*$sinzf; |
|
| 986 | + $sat->dps->sghl = $sat->dps->xgh2*$f2 + $sat->dps->xgh3*$f3 + $sat->dps->xgh4*$sinzf; |
|
| 987 | + $sat->dps->sh1 = $sat->dps->xh2*$f2 + $sat->dps->xh3*$f3; |
|
| 988 | 988 | $sat->dps->pe = $ses + $sel; |
| 989 | 989 | $sat->dps->pinc = $sis + $sil; |
| 990 | 990 | $sat->dps->pl = $sls + $sll; |
@@ -997,8 +997,8 @@ discard block |
||
| 997 | 997 | |
| 998 | 998 | if ($sat->dps->xqncl >= 0.2) { |
| 999 | 999 | /* Apply periodics directly */ |
| 1000 | - $ph = $ph / $sat->deep_arg->sinio; |
|
| 1001 | - $pgh = $pgh - $sat->deep_arg->cosio * $ph; |
|
| 1000 | + $ph = $ph/$sat->deep_arg->sinio; |
|
| 1001 | + $pgh = $pgh - $sat->deep_arg->cosio*$ph; |
|
| 1002 | 1002 | $sat->deep_arg->omgadf = $sat->deep_arg->omgadf + $pgh; |
| 1003 | 1003 | $sat->deep_arg->xnode = $sat->deep_arg->xnode + $ph; |
| 1004 | 1004 | $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
@@ -1006,22 +1006,22 @@ discard block |
||
| 1006 | 1006 | /* Apply periodics with Lyddane modification */ |
| 1007 | 1007 | $sinok = sin($sat->deep_arg->xnode); |
| 1008 | 1008 | $cosok = cos($sat->deep_arg->xnode); |
| 1009 | - $alfdp = $sinis * $sinok; |
|
| 1010 | - $betdp = $sinis * $cosok; |
|
| 1011 | - $dalf = $ph * $cosok + $sat->dps->pinc * $cosis * $sinok; |
|
| 1012 | - $dbet = -$ph * $sinok + $sat->dps->pinc * $cosis * $cosok; |
|
| 1009 | + $alfdp = $sinis*$sinok; |
|
| 1010 | + $betdp = $sinis*$cosok; |
|
| 1011 | + $dalf = $ph*$cosok + $sat->dps->pinc*$cosis*$sinok; |
|
| 1012 | + $dbet = -$ph*$sinok + $sat->dps->pinc*$cosis*$cosok; |
|
| 1013 | 1013 | $alfdp = $alfdp + $dalf; |
| 1014 | 1014 | $betdp = $betdp + $dbet; |
| 1015 | 1015 | $sat->deep_arg->xnode = Predict_Math::FMod2p($sat->deep_arg->xnode); |
| 1016 | - $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis * $sat->deep_arg->xnode; |
|
| 1017 | - $dls = $sat->dps->pl + $pgh - $sat->dps->pinc * $sat->deep_arg->xnode * $sinis; |
|
| 1016 | + $xls = $sat->deep_arg->xll + $sat->deep_arg->omgadf + $cosis*$sat->deep_arg->xnode; |
|
| 1017 | + $dls = $sat->dps->pl + $pgh - $sat->dps->pinc*$sat->deep_arg->xnode*$sinis; |
|
| 1018 | 1018 | $xls = $xls + $dls; |
| 1019 | 1019 | $xnoh = $sat->deep_arg->xnode; |
| 1020 | 1020 | $sat->deep_arg->xnode = Predict_Math::AcTan($alfdp, $betdp); |
| 1021 | 1021 | |
| 1022 | 1022 | /* This is a patch to Lyddane modification */ |
| 1023 | 1023 | /* suggested by Rob Matson. */ |
| 1024 | - if(abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1024 | + if (abs($xnoh - $sat->deep_arg->xnode) > Predict::pi) { |
|
| 1025 | 1025 | if ($sat->deep_arg->xnode < $xnoh) { |
| 1026 | 1026 | $sat->deep_arg->xnode += Predict::twopi; |
| 1027 | 1027 | } else { |
@@ -1030,7 +1030,7 @@ discard block |
||
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | $sat->deep_arg->xll = $sat->deep_arg->xll + $sat->dps->pl; |
| 1033 | - $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc) * |
|
| 1033 | + $sat->deep_arg->omgadf = $xls - $sat->deep_arg->xll - cos($sat->deep_arg->xinc)* |
|
| 1034 | 1034 | $sat->deep_arg->xnode; |
| 1035 | 1035 | } /* End case dpper: */ |
| 1036 | 1036 | return; |
@@ -752,8 +752,7 @@ discard block |
||
| 752 | 752 | $sat->deep_arg->eosq + 5337.524 * $eoc; |
| 753 | 753 | $g532 = -853.666 + 4690.25 * $eq - 8624.77 * |
| 754 | 754 | $sat->deep_arg->eosq + 5341.4 * $eoc; |
| 755 | - } |
|
| 756 | - else { |
|
| 755 | + } else { |
|
| 757 | 756 | $g533 = -37995.78 + 161616.52 * $eq - 229838.2* |
| 758 | 757 | $sat->deep_arg->eosq + 109377.94 * $eoc; |
| 759 | 758 | $g521 = -51752.104 + 218913.95 * $eq - 309468.16* |
@@ -887,8 +886,7 @@ discard block |
||
| 887 | 886 | if (abs($sat->deep_arg->t - $sat->dps->atime) >= $sat->dps->stepp) { |
| 888 | 887 | $sat->flags |= self::DO_LOOP_FLAG; |
| 889 | 888 | $sat->flags &= ~self::EPOCH_RESTART_FLAG; |
| 890 | - } |
|
| 891 | - else { |
|
| 889 | + } else { |
|
| 892 | 890 | $ft = $sat->deep_arg->t - $sat->dps->atime; |
| 893 | 891 | $sat->flags &= ~self::DO_LOOP_FLAG; |
| 894 | 892 | } |
@@ -51,6 +51,10 @@ |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /* Calculates stellite's eclipse status and depth */ |
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param double $depth |
|
| 57 | + */ |
|
| 54 | 58 | public static function Sat_Eclipsed(Predict_Vector $pos, Predict_Vector $sol, &$depth) |
| 55 | 59 | { |
| 56 | 60 | $Rho = new Predict_Vector(); |
@@ -24,91 +24,91 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | class Predict_Solar |
| 26 | 26 | { |
| 27 | - /* Calculates solar position vector */ |
|
| 28 | - public static function Calculate_Solar_Position($time, Predict_Vector $solar_vector) |
|
| 29 | - { |
|
| 30 | - $mjd = $time - 2415020.0; |
|
| 31 | - $year = 1900 + $mjd / 365.25; |
|
| 32 | - $T = ($mjd + Predict_Time::Delta_ET($year) / Predict::secday) / 36525.0; |
|
| 33 | - $M = Predict_Math::Radians(Predict_Math::Modulus(358.47583 + Predict_Math::Modulus(35999.04975 * $T, 360.0) |
|
| 34 | - - (0.000150 + 0.0000033 * $T) * ($T * $T), 360.0)); |
|
| 35 | - $L = Predict_Math::Radians(Predict_Math::Modulus(279.69668 + Predict_Math::Modulus(36000.76892 * $T, 360.0) |
|
| 36 | - + 0.0003025 * ($T * $T), 360.0)); |
|
| 37 | - $e = 0.01675104 - (0.0000418 + 0.000000126 * $T) * $T; |
|
| 38 | - $C = Predict_Math::Radians((1.919460 - (0.004789 + 0.000014 * $T) * $T) * sin($M) |
|
| 39 | - + (0.020094 - 0.000100 * $T) * sin(2 * $M) + 0.000293 * sin(3 * $M)); |
|
| 40 | - $O = Predict_Math::Radians(Predict_Math::Modulus(259.18 - 1934.142 * $T, 360.0)); |
|
| 41 | - $Lsa = Predict_Math::Modulus($L + $C - Predict_Math::Radians(0.00569 - 0.00479 * sin($O)), Predict::twopi); |
|
| 42 | - $nu = Predict_Math::Modulus($M + $C, Predict::twopi); |
|
| 43 | - $R = 1.0000002 * (1 - ($e * $e)) / (1 + $e * cos($nu)); |
|
| 44 | - $eps = Predict_Math::Radians(23.452294 - (0.0130125 + (0.00000164 - 0.000000503 * $T) * $T) * $T + 0.00256 * cos($O)); |
|
| 45 | - $R = Predict::AU * $R; |
|
| 27 | + /* Calculates solar position vector */ |
|
| 28 | + public static function Calculate_Solar_Position($time, Predict_Vector $solar_vector) |
|
| 29 | + { |
|
| 30 | + $mjd = $time - 2415020.0; |
|
| 31 | + $year = 1900 + $mjd / 365.25; |
|
| 32 | + $T = ($mjd + Predict_Time::Delta_ET($year) / Predict::secday) / 36525.0; |
|
| 33 | + $M = Predict_Math::Radians(Predict_Math::Modulus(358.47583 + Predict_Math::Modulus(35999.04975 * $T, 360.0) |
|
| 34 | + - (0.000150 + 0.0000033 * $T) * ($T * $T), 360.0)); |
|
| 35 | + $L = Predict_Math::Radians(Predict_Math::Modulus(279.69668 + Predict_Math::Modulus(36000.76892 * $T, 360.0) |
|
| 36 | + + 0.0003025 * ($T * $T), 360.0)); |
|
| 37 | + $e = 0.01675104 - (0.0000418 + 0.000000126 * $T) * $T; |
|
| 38 | + $C = Predict_Math::Radians((1.919460 - (0.004789 + 0.000014 * $T) * $T) * sin($M) |
|
| 39 | + + (0.020094 - 0.000100 * $T) * sin(2 * $M) + 0.000293 * sin(3 * $M)); |
|
| 40 | + $O = Predict_Math::Radians(Predict_Math::Modulus(259.18 - 1934.142 * $T, 360.0)); |
|
| 41 | + $Lsa = Predict_Math::Modulus($L + $C - Predict_Math::Radians(0.00569 - 0.00479 * sin($O)), Predict::twopi); |
|
| 42 | + $nu = Predict_Math::Modulus($M + $C, Predict::twopi); |
|
| 43 | + $R = 1.0000002 * (1 - ($e * $e)) / (1 + $e * cos($nu)); |
|
| 44 | + $eps = Predict_Math::Radians(23.452294 - (0.0130125 + (0.00000164 - 0.000000503 * $T) * $T) * $T + 0.00256 * cos($O)); |
|
| 45 | + $R = Predict::AU * $R; |
|
| 46 | 46 | |
| 47 | - $solar_vector->x = $R * cos($Lsa); |
|
| 48 | - $solar_vector->y = $R * sin($Lsa) * cos($eps); |
|
| 49 | - $solar_vector->z = $R * sin($Lsa) * sin($eps); |
|
| 50 | - $solar_vector->w = $R; |
|
| 51 | - } |
|
| 47 | + $solar_vector->x = $R * cos($Lsa); |
|
| 48 | + $solar_vector->y = $R * sin($Lsa) * cos($eps); |
|
| 49 | + $solar_vector->z = $R * sin($Lsa) * sin($eps); |
|
| 50 | + $solar_vector->w = $R; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /* Calculates stellite's eclipse status and depth */ |
|
| 54 | - public static function Sat_Eclipsed(Predict_Vector $pos, Predict_Vector $sol, &$depth) |
|
| 55 | - { |
|
| 56 | - $Rho = new Predict_Vector(); |
|
| 57 | - $earth = new Predict_Vector(); |
|
| 53 | + /* Calculates stellite's eclipse status and depth */ |
|
| 54 | + public static function Sat_Eclipsed(Predict_Vector $pos, Predict_Vector $sol, &$depth) |
|
| 55 | + { |
|
| 56 | + $Rho = new Predict_Vector(); |
|
| 57 | + $earth = new Predict_Vector(); |
|
| 58 | 58 | |
| 59 | - /* Determine partial eclipse */ |
|
| 60 | - $sd_earth = Predict_Math::ArcSin(Predict::xkmper / $pos->w); |
|
| 61 | - Predict_Math::Vec_Sub($sol, $pos, $Rho); |
|
| 62 | - $sd_sun = Predict_Math::ArcSin(Predict::__sr__ / $Rho->w); |
|
| 63 | - Predict_Math::Scalar_Multiply(-1, $pos, $earth); |
|
| 64 | - $delta = Predict_Math::Angle($sol, $earth); |
|
| 65 | - $depth = $sd_earth - $sd_sun - $delta; |
|
| 59 | + /* Determine partial eclipse */ |
|
| 60 | + $sd_earth = Predict_Math::ArcSin(Predict::xkmper / $pos->w); |
|
| 61 | + Predict_Math::Vec_Sub($sol, $pos, $Rho); |
|
| 62 | + $sd_sun = Predict_Math::ArcSin(Predict::__sr__ / $Rho->w); |
|
| 63 | + Predict_Math::Scalar_Multiply(-1, $pos, $earth); |
|
| 64 | + $delta = Predict_Math::Angle($sol, $earth); |
|
| 65 | + $depth = $sd_earth - $sd_sun - $delta; |
|
| 66 | 66 | |
| 67 | - if ($sd_earth < $sd_sun) { |
|
| 68 | - return 0; |
|
| 69 | - } else if ($depth >= 0) { |
|
| 70 | - return 1; |
|
| 71 | - } else { |
|
| 72 | - return 0; |
|
| 73 | - } |
|
| 74 | - } |
|
| 67 | + if ($sd_earth < $sd_sun) { |
|
| 68 | + return 0; |
|
| 69 | + } else if ($depth >= 0) { |
|
| 70 | + return 1; |
|
| 71 | + } else { |
|
| 72 | + return 0; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Finds the current location of the sun based on the observer location |
|
| 78 | - * |
|
| 79 | - * @param Predict_QTH $qth The observer location |
|
| 80 | - * @param int $daynum The daynum or null to use the current daynum |
|
| 81 | - * |
|
| 82 | - * @return Predict_ObsSet |
|
| 83 | - */ |
|
| 84 | - public static function FindSun(Predict_QTH $qth, $daynum = null) |
|
| 85 | - { |
|
| 86 | - if ($daynum === null) { |
|
| 87 | - $daynum = Predict_Time::get_current_daynum(); |
|
| 88 | - } |
|
| 76 | + /** |
|
| 77 | + * Finds the current location of the sun based on the observer location |
|
| 78 | + * |
|
| 79 | + * @param Predict_QTH $qth The observer location |
|
| 80 | + * @param int $daynum The daynum or null to use the current daynum |
|
| 81 | + * |
|
| 82 | + * @return Predict_ObsSet |
|
| 83 | + */ |
|
| 84 | + public static function FindSun(Predict_QTH $qth, $daynum = null) |
|
| 85 | + { |
|
| 86 | + if ($daynum === null) { |
|
| 87 | + $daynum = Predict_Time::get_current_daynum(); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - $obs_geodetic = new Predict_Geodetic(); |
|
| 91 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 92 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 93 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 94 | - $obs_geodetic->theta = 0; |
|
| 90 | + $obs_geodetic = new Predict_Geodetic(); |
|
| 91 | + $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 92 | + $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 93 | + $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 94 | + $obs_geodetic->theta = 0; |
|
| 95 | 95 | |
| 96 | - $solar_vector = new Predict_Vector(); |
|
| 97 | - $zero_vector = new Predict_Vector(); |
|
| 98 | - $solar_set = new Predict_ObsSet(); |
|
| 96 | + $solar_vector = new Predict_Vector(); |
|
| 97 | + $zero_vector = new Predict_Vector(); |
|
| 98 | + $solar_set = new Predict_ObsSet(); |
|
| 99 | 99 | |
| 100 | - self::Calculate_Solar_Position($daynum, $solar_vector); |
|
| 101 | - Predict_SGPObs::Calculate_Obs( |
|
| 102 | - $daynum, |
|
| 103 | - $solar_vector, |
|
| 104 | - $zero_vector, |
|
| 105 | - $obs_geodetic, |
|
| 106 | - $solar_set |
|
| 107 | - ); |
|
| 100 | + self::Calculate_Solar_Position($daynum, $solar_vector); |
|
| 101 | + Predict_SGPObs::Calculate_Obs( |
|
| 102 | + $daynum, |
|
| 103 | + $solar_vector, |
|
| 104 | + $zero_vector, |
|
| 105 | + $obs_geodetic, |
|
| 106 | + $solar_set |
|
| 107 | + ); |
|
| 108 | 108 | |
| 109 | - $solar_set->az = Predict_Math::Degrees($solar_set->az); |
|
| 110 | - $solar_set->el = Predict_Math::Degrees($solar_set->el); |
|
| 109 | + $solar_set->az = Predict_Math::Degrees($solar_set->az); |
|
| 110 | + $solar_set->el = Predict_Math::Degrees($solar_set->el); |
|
| 111 | 111 | |
| 112 | - return $solar_set; |
|
| 113 | - } |
|
| 112 | + return $solar_set; |
|
| 113 | + } |
|
| 114 | 114 | } |
@@ -28,25 +28,25 @@ discard block |
||
| 28 | 28 | public static function Calculate_Solar_Position($time, Predict_Vector $solar_vector) |
| 29 | 29 | { |
| 30 | 30 | $mjd = $time - 2415020.0; |
| 31 | - $year = 1900 + $mjd / 365.25; |
|
| 32 | - $T = ($mjd + Predict_Time::Delta_ET($year) / Predict::secday) / 36525.0; |
|
| 33 | - $M = Predict_Math::Radians(Predict_Math::Modulus(358.47583 + Predict_Math::Modulus(35999.04975 * $T, 360.0) |
|
| 34 | - - (0.000150 + 0.0000033 * $T) * ($T * $T), 360.0)); |
|
| 35 | - $L = Predict_Math::Radians(Predict_Math::Modulus(279.69668 + Predict_Math::Modulus(36000.76892 * $T, 360.0) |
|
| 36 | - + 0.0003025 * ($T * $T), 360.0)); |
|
| 37 | - $e = 0.01675104 - (0.0000418 + 0.000000126 * $T) * $T; |
|
| 38 | - $C = Predict_Math::Radians((1.919460 - (0.004789 + 0.000014 * $T) * $T) * sin($M) |
|
| 39 | - + (0.020094 - 0.000100 * $T) * sin(2 * $M) + 0.000293 * sin(3 * $M)); |
|
| 40 | - $O = Predict_Math::Radians(Predict_Math::Modulus(259.18 - 1934.142 * $T, 360.0)); |
|
| 41 | - $Lsa = Predict_Math::Modulus($L + $C - Predict_Math::Radians(0.00569 - 0.00479 * sin($O)), Predict::twopi); |
|
| 31 | + $year = 1900 + $mjd/365.25; |
|
| 32 | + $T = ($mjd + Predict_Time::Delta_ET($year)/Predict::secday)/36525.0; |
|
| 33 | + $M = Predict_Math::Radians(Predict_Math::Modulus(358.47583 + Predict_Math::Modulus(35999.04975*$T, 360.0) |
|
| 34 | + - (0.000150 + 0.0000033*$T)*($T*$T), 360.0)); |
|
| 35 | + $L = Predict_Math::Radians(Predict_Math::Modulus(279.69668 + Predict_Math::Modulus(36000.76892*$T, 360.0) |
|
| 36 | + + 0.0003025*($T*$T), 360.0)); |
|
| 37 | + $e = 0.01675104 - (0.0000418 + 0.000000126*$T)*$T; |
|
| 38 | + $C = Predict_Math::Radians((1.919460 - (0.004789 + 0.000014*$T)*$T)*sin($M) |
|
| 39 | + + (0.020094 - 0.000100*$T)*sin(2*$M) + 0.000293*sin(3*$M)); |
|
| 40 | + $O = Predict_Math::Radians(Predict_Math::Modulus(259.18 - 1934.142*$T, 360.0)); |
|
| 41 | + $Lsa = Predict_Math::Modulus($L + $C - Predict_Math::Radians(0.00569 - 0.00479*sin($O)), Predict::twopi); |
|
| 42 | 42 | $nu = Predict_Math::Modulus($M + $C, Predict::twopi); |
| 43 | - $R = 1.0000002 * (1 - ($e * $e)) / (1 + $e * cos($nu)); |
|
| 44 | - $eps = Predict_Math::Radians(23.452294 - (0.0130125 + (0.00000164 - 0.000000503 * $T) * $T) * $T + 0.00256 * cos($O)); |
|
| 45 | - $R = Predict::AU * $R; |
|
| 43 | + $R = 1.0000002*(1 - ($e*$e))/(1 + $e*cos($nu)); |
|
| 44 | + $eps = Predict_Math::Radians(23.452294 - (0.0130125 + (0.00000164 - 0.000000503*$T)*$T)*$T + 0.00256*cos($O)); |
|
| 45 | + $R = Predict::AU*$R; |
|
| 46 | 46 | |
| 47 | - $solar_vector->x = $R * cos($Lsa); |
|
| 48 | - $solar_vector->y = $R * sin($Lsa) * cos($eps); |
|
| 49 | - $solar_vector->z = $R * sin($Lsa) * sin($eps); |
|
| 47 | + $solar_vector->x = $R*cos($Lsa); |
|
| 48 | + $solar_vector->y = $R*sin($Lsa)*cos($eps); |
|
| 49 | + $solar_vector->z = $R*sin($Lsa)*sin($eps); |
|
| 50 | 50 | $solar_vector->w = $R; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | $earth = new Predict_Vector(); |
| 58 | 58 | |
| 59 | 59 | /* Determine partial eclipse */ |
| 60 | - $sd_earth = Predict_Math::ArcSin(Predict::xkmper / $pos->w); |
|
| 60 | + $sd_earth = Predict_Math::ArcSin(Predict::xkmper/$pos->w); |
|
| 61 | 61 | Predict_Math::Vec_Sub($sol, $pos, $Rho); |
| 62 | - $sd_sun = Predict_Math::ArcSin(Predict::__sr__ / $Rho->w); |
|
| 62 | + $sd_sun = Predict_Math::ArcSin(Predict::__sr__/$Rho->w); |
|
| 63 | 63 | Predict_Math::Scalar_Multiply(-1, $pos, $earth); |
| 64 | 64 | $delta = Predict_Math::Angle($sol, $earth); |
| 65 | 65 | $depth = $sd_earth - $sd_sun - $delta; |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $obs_geodetic = new Predict_Geodetic(); |
| 91 | - $obs_geodetic->lon = $qth->lon * Predict::de2ra; |
|
| 92 | - $obs_geodetic->lat = $qth->lat * Predict::de2ra; |
|
| 93 | - $obs_geodetic->alt = $qth->alt / 1000.0; |
|
| 91 | + $obs_geodetic->lon = $qth->lon*Predict::de2ra; |
|
| 92 | + $obs_geodetic->lat = $qth->lat*Predict::de2ra; |
|
| 93 | + $obs_geodetic->alt = $qth->alt/1000.0; |
|
| 94 | 94 | $obs_geodetic->theta = 0; |
| 95 | 95 | |
| 96 | 96 | $solar_vector = new Predict_Vector(); |
@@ -36,6 +36,10 @@ discard block |
||
| 36 | 36 | /* the year 1999 assuming that two-digit years in the range 00-56 */ |
| 37 | 37 | /* correspond to 2000-2056. Until the two-line element set format */ |
| 38 | 38 | /* is changed, it is only valid for dates through 2056 December 31. */ |
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param double $epoch |
|
| 42 | + */ |
|
| 39 | 43 | public static function Julian_Date_of_Epoch($epoch) |
| 40 | 44 | { |
| 41 | 45 | $year = 0; |
@@ -54,6 +58,11 @@ discard block |
||
| 54 | 58 | } |
| 55 | 59 | |
| 56 | 60 | /* Equivalent to the C modf function */ |
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @param double $x |
|
| 64 | + * @param integer $ipart |
|
| 65 | + */ |
|
| 57 | 66 | public static function modf($x, &$ipart) { |
| 58 | 67 | $ipart = (int)$x; |
| 59 | 68 | return $x - $ipart; |
@@ -63,6 +72,10 @@ discard block |
||
| 63 | 72 | /* of Day 0.0 of {year}. This function is used to calculate the */ |
| 64 | 73 | /* Julian Date of any date by using Julian_Date_of_Year, DOY, */ |
| 65 | 74 | /* and Fraction_of_Day. */ |
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @param integer $year |
|
| 78 | + */ |
|
| 66 | 79 | public static function Julian_Date_of_Year($year) |
| 67 | 80 | { |
| 68 | 81 | /* Astronomical Formulae for Calculators, Jean Meeus, */ |
@@ -85,6 +98,10 @@ discard block |
||
| 85 | 98 | /* 1999, as described above. The function ThetaG_JD provides the */ |
| 86 | 99 | /* same calculation except that it is based on an input in the */ |
| 87 | 100 | /* form of a Julian Date. */ |
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param double $epoch |
|
| 104 | + */ |
|
| 88 | 105 | public static function ThetaG($epoch, Predict_DeepArg $deep_arg) |
| 89 | 106 | { |
| 90 | 107 | /* Reference: The 1992 Astronomical Almanac, page B6. */ |
@@ -157,6 +174,10 @@ discard block |
||
| 157 | 174 | /* (approximately the same as UTC) and ET (now referred to as TDT).*/ |
| 158 | 175 | /* This function is based on a least squares fit of data from 1950 */ |
| 159 | 176 | /* to 1991 and will need to be updated periodically. */ |
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @param double $year |
|
| 180 | + */ |
|
| 160 | 181 | public static function Delta_ET($year) |
| 161 | 182 | { |
| 162 | 183 | /* Values determined using data from 1950-1991 in the 1990 |
@@ -204,7 +225,7 @@ discard block |
||
| 204 | 225 | * |
| 205 | 226 | * @param Predict_TLE $tle The TLE object |
| 206 | 227 | * |
| 207 | - * @return int |
|
| 228 | + * @return double |
|
| 208 | 229 | */ |
| 209 | 230 | public static function getEpochTimeStamp(Predict_TLE $tle) |
| 210 | 231 | { |
@@ -30,194 +30,194 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | class Predict_Time |
| 32 | 32 | { |
| 33 | - /* The function Julian_Date_of_Epoch returns the Julian Date of */ |
|
| 34 | - /* an epoch specified in the format used in the NORAD two-line */ |
|
| 35 | - /* element sets. It has been modified to support dates beyond */ |
|
| 36 | - /* the year 1999 assuming that two-digit years in the range 00-56 */ |
|
| 37 | - /* correspond to 2000-2056. Until the two-line element set format */ |
|
| 38 | - /* is changed, it is only valid for dates through 2056 December 31. */ |
|
| 39 | - public static function Julian_Date_of_Epoch($epoch) |
|
| 40 | - { |
|
| 41 | - $year = 0; |
|
| 42 | - |
|
| 43 | - /* Modification to support Y2K */ |
|
| 44 | - /* Valid 1957 through 2056 */ |
|
| 45 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 46 | - if ($year < 57) { |
|
| 47 | - $year = $year + 2000; |
|
| 48 | - } else { |
|
| 49 | - $year = $year + 1900; |
|
| 50 | - } |
|
| 51 | - /* End modification */ |
|
| 52 | - |
|
| 53 | - return self::Julian_Date_of_Year($year) + $day; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /* Equivalent to the C modf function */ |
|
| 57 | - public static function modf($x, &$ipart) { |
|
| 58 | - $ipart = (int)$x; |
|
| 59 | - return $x - $ipart; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - /* The function Julian_Date_of_Year calculates the Julian Date */ |
|
| 63 | - /* of Day 0.0 of {year}. This function is used to calculate the */ |
|
| 64 | - /* Julian Date of any date by using Julian_Date_of_Year, DOY, */ |
|
| 65 | - /* and Fraction_of_Day. */ |
|
| 66 | - public static function Julian_Date_of_Year($year) |
|
| 67 | - { |
|
| 68 | - /* Astronomical Formulae for Calculators, Jean Meeus, */ |
|
| 69 | - /* pages 23-25. Calculate Julian Date of 0.0 Jan year */ |
|
| 70 | - $year = $year - 1; |
|
| 71 | - $i = (int) ($year / 100); |
|
| 72 | - $A = $i; |
|
| 73 | - $i = (int) ($A / 4); |
|
| 74 | - $B = (int) (2 - $A + $i); |
|
| 75 | - $i = (int) (365.25 * $year); |
|
| 76 | - $i += (int) (30.6001 * 14); |
|
| 77 | - $jdoy = $i + 1720994.5 + $B; |
|
| 78 | - |
|
| 79 | - return $jdoy; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /* The function ThetaG calculates the Greenwich Mean Sidereal Time */ |
|
| 83 | - /* for an epoch specified in the format used in the NORAD two-line */ |
|
| 84 | - /* element sets. It has now been adapted for dates beyond the year */ |
|
| 85 | - /* 1999, as described above. The function ThetaG_JD provides the */ |
|
| 86 | - /* same calculation except that it is based on an input in the */ |
|
| 87 | - /* form of a Julian Date. */ |
|
| 88 | - public static function ThetaG($epoch, Predict_DeepArg $deep_arg) |
|
| 89 | - { |
|
| 90 | - /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
| 91 | - // double year,day,UT,jd,TU,GMST,_ThetaG; |
|
| 92 | - |
|
| 93 | - /* Modification to support Y2K */ |
|
| 94 | - /* Valid 1957 through 2056 */ |
|
| 95 | - $year = 0; |
|
| 96 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 97 | - |
|
| 98 | - if ($year < 57) { |
|
| 99 | - $year += 2000; |
|
| 100 | - } else { |
|
| 101 | - $year += 1900; |
|
| 102 | - } |
|
| 103 | - /* End modification */ |
|
| 104 | - |
|
| 105 | - $UT = fmod($day, $day); |
|
| 106 | - $jd = self::Julian_Date_of_Year($year) + $day; |
|
| 107 | - $TU = ($jd - 2451545.0) / 36525; |
|
| 108 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 109 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 110 | - $deep_arg->ds50 = $jd - 2433281.5 + $UT; |
|
| 111 | - |
|
| 112 | - return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /* See the ThetaG doc block above */ |
|
| 116 | - public static function ThetaG_JD($jd) |
|
| 117 | - { |
|
| 118 | - /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
| 119 | - $UT = Predict_Math::Frac($jd + 0.5); |
|
| 120 | - $jd = $jd - $UT; |
|
| 121 | - $TU = ($jd - 2451545.0) / 36525; |
|
| 122 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 123 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 124 | - |
|
| 125 | - return Predict::twopi * $GMST / Predict::secday; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * Read the system clock and return the current Julian day. From phpPredict |
|
| 130 | - * |
|
| 131 | - * @return float |
|
| 132 | - */ |
|
| 133 | - public static function get_current_daynum() { |
|
| 134 | - // Gets the current decimal day number from microtime |
|
| 135 | - |
|
| 136 | - list($usec, $sec) = explode(' ', microtime()); |
|
| 137 | - return self::unix2daynum($sec, $usec); |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Converts a standard unix timestamp and optional |
|
| 142 | - * milliseconds to a daynum |
|
| 143 | - * |
|
| 144 | - * @param int $sec Seconds from the unix epoch |
|
| 145 | - * @param int $usec Optional milliseconds |
|
| 146 | - * |
|
| 147 | - * @return float |
|
| 148 | - */ |
|
| 149 | - public static function unix2daynum($sec, $usec = 0) |
|
| 150 | - { |
|
| 151 | - $time = ((($sec + $usec) / 86400.0) - 3651.0); |
|
| 152 | - return $time + 2444238.5; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - /* The function Delta_ET has been added to allow calculations on */ |
|
| 156 | - /* the position of the sun. It provides the difference between UT */ |
|
| 157 | - /* (approximately the same as UTC) and ET (now referred to as TDT).*/ |
|
| 158 | - /* This function is based on a least squares fit of data from 1950 */ |
|
| 159 | - /* to 1991 and will need to be updated periodically. */ |
|
| 160 | - public static function Delta_ET($year) |
|
| 161 | - { |
|
| 162 | - /* Values determined using data from 1950-1991 in the 1990 |
|
| 33 | + /* The function Julian_Date_of_Epoch returns the Julian Date of */ |
|
| 34 | + /* an epoch specified in the format used in the NORAD two-line */ |
|
| 35 | + /* element sets. It has been modified to support dates beyond */ |
|
| 36 | + /* the year 1999 assuming that two-digit years in the range 00-56 */ |
|
| 37 | + /* correspond to 2000-2056. Until the two-line element set format */ |
|
| 38 | + /* is changed, it is only valid for dates through 2056 December 31. */ |
|
| 39 | + public static function Julian_Date_of_Epoch($epoch) |
|
| 40 | + { |
|
| 41 | + $year = 0; |
|
| 42 | + |
|
| 43 | + /* Modification to support Y2K */ |
|
| 44 | + /* Valid 1957 through 2056 */ |
|
| 45 | + $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 46 | + if ($year < 57) { |
|
| 47 | + $year = $year + 2000; |
|
| 48 | + } else { |
|
| 49 | + $year = $year + 1900; |
|
| 50 | + } |
|
| 51 | + /* End modification */ |
|
| 52 | + |
|
| 53 | + return self::Julian_Date_of_Year($year) + $day; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /* Equivalent to the C modf function */ |
|
| 57 | + public static function modf($x, &$ipart) { |
|
| 58 | + $ipart = (int)$x; |
|
| 59 | + return $x - $ipart; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + /* The function Julian_Date_of_Year calculates the Julian Date */ |
|
| 63 | + /* of Day 0.0 of {year}. This function is used to calculate the */ |
|
| 64 | + /* Julian Date of any date by using Julian_Date_of_Year, DOY, */ |
|
| 65 | + /* and Fraction_of_Day. */ |
|
| 66 | + public static function Julian_Date_of_Year($year) |
|
| 67 | + { |
|
| 68 | + /* Astronomical Formulae for Calculators, Jean Meeus, */ |
|
| 69 | + /* pages 23-25. Calculate Julian Date of 0.0 Jan year */ |
|
| 70 | + $year = $year - 1; |
|
| 71 | + $i = (int) ($year / 100); |
|
| 72 | + $A = $i; |
|
| 73 | + $i = (int) ($A / 4); |
|
| 74 | + $B = (int) (2 - $A + $i); |
|
| 75 | + $i = (int) (365.25 * $year); |
|
| 76 | + $i += (int) (30.6001 * 14); |
|
| 77 | + $jdoy = $i + 1720994.5 + $B; |
|
| 78 | + |
|
| 79 | + return $jdoy; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /* The function ThetaG calculates the Greenwich Mean Sidereal Time */ |
|
| 83 | + /* for an epoch specified in the format used in the NORAD two-line */ |
|
| 84 | + /* element sets. It has now been adapted for dates beyond the year */ |
|
| 85 | + /* 1999, as described above. The function ThetaG_JD provides the */ |
|
| 86 | + /* same calculation except that it is based on an input in the */ |
|
| 87 | + /* form of a Julian Date. */ |
|
| 88 | + public static function ThetaG($epoch, Predict_DeepArg $deep_arg) |
|
| 89 | + { |
|
| 90 | + /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
| 91 | + // double year,day,UT,jd,TU,GMST,_ThetaG; |
|
| 92 | + |
|
| 93 | + /* Modification to support Y2K */ |
|
| 94 | + /* Valid 1957 through 2056 */ |
|
| 95 | + $year = 0; |
|
| 96 | + $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 97 | + |
|
| 98 | + if ($year < 57) { |
|
| 99 | + $year += 2000; |
|
| 100 | + } else { |
|
| 101 | + $year += 1900; |
|
| 102 | + } |
|
| 103 | + /* End modification */ |
|
| 104 | + |
|
| 105 | + $UT = fmod($day, $day); |
|
| 106 | + $jd = self::Julian_Date_of_Year($year) + $day; |
|
| 107 | + $TU = ($jd - 2451545.0) / 36525; |
|
| 108 | + $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 109 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 110 | + $deep_arg->ds50 = $jd - 2433281.5 + $UT; |
|
| 111 | + |
|
| 112 | + return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /* See the ThetaG doc block above */ |
|
| 116 | + public static function ThetaG_JD($jd) |
|
| 117 | + { |
|
| 118 | + /* Reference: The 1992 Astronomical Almanac, page B6. */ |
|
| 119 | + $UT = Predict_Math::Frac($jd + 0.5); |
|
| 120 | + $jd = $jd - $UT; |
|
| 121 | + $TU = ($jd - 2451545.0) / 36525; |
|
| 122 | + $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 123 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 124 | + |
|
| 125 | + return Predict::twopi * $GMST / Predict::secday; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * Read the system clock and return the current Julian day. From phpPredict |
|
| 130 | + * |
|
| 131 | + * @return float |
|
| 132 | + */ |
|
| 133 | + public static function get_current_daynum() { |
|
| 134 | + // Gets the current decimal day number from microtime |
|
| 135 | + |
|
| 136 | + list($usec, $sec) = explode(' ', microtime()); |
|
| 137 | + return self::unix2daynum($sec, $usec); |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Converts a standard unix timestamp and optional |
|
| 142 | + * milliseconds to a daynum |
|
| 143 | + * |
|
| 144 | + * @param int $sec Seconds from the unix epoch |
|
| 145 | + * @param int $usec Optional milliseconds |
|
| 146 | + * |
|
| 147 | + * @return float |
|
| 148 | + */ |
|
| 149 | + public static function unix2daynum($sec, $usec = 0) |
|
| 150 | + { |
|
| 151 | + $time = ((($sec + $usec) / 86400.0) - 3651.0); |
|
| 152 | + return $time + 2444238.5; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /* The function Delta_ET has been added to allow calculations on */ |
|
| 156 | + /* the position of the sun. It provides the difference between UT */ |
|
| 157 | + /* (approximately the same as UTC) and ET (now referred to as TDT).*/ |
|
| 158 | + /* This function is based on a least squares fit of data from 1950 */ |
|
| 159 | + /* to 1991 and will need to be updated periodically. */ |
|
| 160 | + public static function Delta_ET($year) |
|
| 161 | + { |
|
| 162 | + /* Values determined using data from 1950-1991 in the 1990 |
|
| 163 | 163 | Astronomical Almanac. See DELTA_ET.WQ1 for details. */ |
| 164 | 164 | |
| 165 | - $delta_et = 26.465 + 0.747622 * ($year - 1950) + |
|
| 166 | - 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); |
|
| 167 | - |
|
| 168 | - return $delta_et; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Converts a daynum to a unix timestamp. From phpPredict. |
|
| 173 | - * |
|
| 174 | - * @param float $dn Julian Daynum |
|
| 175 | - * |
|
| 176 | - * @return float |
|
| 177 | - */ |
|
| 178 | - public static function daynum2unix($dn) { |
|
| 179 | - // Converts a daynum to a UNIX timestamp |
|
| 180 | - |
|
| 181 | - return (86400.0 * ($dn - 2444238.5 + 3651.0)); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Converts a daynum to a readable time format. |
|
| 186 | - * |
|
| 187 | - * @param float $dn The julian date |
|
| 188 | - * @param string $zone The zone string, defaults to America/Los_Angeles |
|
| 189 | - * @param string $format The date() function's format string. Defaults to m-d-Y H:i:s |
|
| 190 | - * |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 193 | - public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') |
|
| 194 | - { |
|
| 195 | - $unix = self::daynum2unix($dn); |
|
| 196 | - $date = new DateTime("@" . round($unix)); |
|
| 197 | - $dateTimezone = new DateTimezone($zone); |
|
| 198 | - $date->setTimezone($dateTimezone); |
|
| 199 | - return $date->format($format); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Returns the unix timestamp of a TLE's epoch |
|
| 204 | - * |
|
| 205 | - * @param Predict_TLE $tle The TLE object |
|
| 206 | - * |
|
| 207 | - * @return int |
|
| 208 | - */ |
|
| 209 | - public static function getEpochTimeStamp(Predict_TLE $tle) |
|
| 210 | - { |
|
| 211 | - $year = $tle->epoch_year; |
|
| 212 | - $day = $tle->epoch_day; |
|
| 213 | - $sec = round(86400 * $tle->epoch_fod); |
|
| 214 | - |
|
| 215 | - $zone = new DateTimeZone('GMT'); |
|
| 216 | - $date = new DateTime(); |
|
| 217 | - $date->setTimezone($zone); |
|
| 218 | - $date->setDate($year, 1, 1); |
|
| 219 | - $date->setTime(0, 0, 0); |
|
| 220 | - |
|
| 221 | - return $date->format('U') + (86400 * $day) + $sec - 86400; |
|
| 222 | - } |
|
| 165 | + $delta_et = 26.465 + 0.747622 * ($year - 1950) + |
|
| 166 | + 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); |
|
| 167 | + |
|
| 168 | + return $delta_et; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Converts a daynum to a unix timestamp. From phpPredict. |
|
| 173 | + * |
|
| 174 | + * @param float $dn Julian Daynum |
|
| 175 | + * |
|
| 176 | + * @return float |
|
| 177 | + */ |
|
| 178 | + public static function daynum2unix($dn) { |
|
| 179 | + // Converts a daynum to a UNIX timestamp |
|
| 180 | + |
|
| 181 | + return (86400.0 * ($dn - 2444238.5 + 3651.0)); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Converts a daynum to a readable time format. |
|
| 186 | + * |
|
| 187 | + * @param float $dn The julian date |
|
| 188 | + * @param string $zone The zone string, defaults to America/Los_Angeles |
|
| 189 | + * @param string $format The date() function's format string. Defaults to m-d-Y H:i:s |
|
| 190 | + * |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | + public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') |
|
| 194 | + { |
|
| 195 | + $unix = self::daynum2unix($dn); |
|
| 196 | + $date = new DateTime("@" . round($unix)); |
|
| 197 | + $dateTimezone = new DateTimezone($zone); |
|
| 198 | + $date->setTimezone($dateTimezone); |
|
| 199 | + return $date->format($format); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Returns the unix timestamp of a TLE's epoch |
|
| 204 | + * |
|
| 205 | + * @param Predict_TLE $tle The TLE object |
|
| 206 | + * |
|
| 207 | + * @return int |
|
| 208 | + */ |
|
| 209 | + public static function getEpochTimeStamp(Predict_TLE $tle) |
|
| 210 | + { |
|
| 211 | + $year = $tle->epoch_year; |
|
| 212 | + $day = $tle->epoch_day; |
|
| 213 | + $sec = round(86400 * $tle->epoch_fod); |
|
| 214 | + |
|
| 215 | + $zone = new DateTimeZone('GMT'); |
|
| 216 | + $date = new DateTime(); |
|
| 217 | + $date->setTimezone($zone); |
|
| 218 | + $date->setDate($year, 1, 1); |
|
| 219 | + $date->setTime(0, 0, 0); |
|
| 220 | + |
|
| 221 | + return $date->format('U') + (86400 * $day) + $sec - 86400; |
|
| 222 | + } |
|
| 223 | 223 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | /* Modification to support Y2K */ |
| 44 | 44 | /* Valid 1957 through 2056 */ |
| 45 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 45 | + $day = self::modf($epoch*1E-3, $year)*1E3; |
|
| 46 | 46 | if ($year < 57) { |
| 47 | 47 | $year = $year + 2000; |
| 48 | 48 | } else { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | /* Equivalent to the C modf function */ |
| 57 | 57 | public static function modf($x, &$ipart) { |
| 58 | - $ipart = (int)$x; |
|
| 58 | + $ipart = (int) $x; |
|
| 59 | 59 | return $x - $ipart; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | /* Astronomical Formulae for Calculators, Jean Meeus, */ |
| 69 | 69 | /* pages 23-25. Calculate Julian Date of 0.0 Jan year */ |
| 70 | 70 | $year = $year - 1; |
| 71 | - $i = (int) ($year / 100); |
|
| 71 | + $i = (int) ($year/100); |
|
| 72 | 72 | $A = $i; |
| 73 | - $i = (int) ($A / 4); |
|
| 73 | + $i = (int) ($A/4); |
|
| 74 | 74 | $B = (int) (2 - $A + $i); |
| 75 | - $i = (int) (365.25 * $year); |
|
| 76 | - $i += (int) (30.6001 * 14); |
|
| 75 | + $i = (int) (365.25*$year); |
|
| 76 | + $i += (int) (30.6001*14); |
|
| 77 | 77 | $jdoy = $i + 1720994.5 + $B; |
| 78 | 78 | |
| 79 | 79 | return $jdoy; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /* Modification to support Y2K */ |
| 94 | 94 | /* Valid 1957 through 2056 */ |
| 95 | 95 | $year = 0; |
| 96 | - $day = self::modf($epoch * 1E-3, $year) * 1E3; |
|
| 96 | + $day = self::modf($epoch*1E-3, $year)*1E3; |
|
| 97 | 97 | |
| 98 | 98 | if ($year < 57) { |
| 99 | 99 | $year += 2000; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | $UT = fmod($day, $day); |
| 106 | 106 | $jd = self::Julian_Date_of_Year($year) + $day; |
| 107 | - $TU = ($jd - 2451545.0) / 36525; |
|
| 108 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 109 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 107 | + $TU = ($jd - 2451545.0)/36525; |
|
| 108 | + $GMST = 24110.54841 + $TU*(8640184.812866 + $TU*(0.093104 - $TU*6.2E-6)); |
|
| 109 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday*Predict::omega_E*$UT, Predict::secday); |
|
| 110 | 110 | $deep_arg->ds50 = $jd - 2433281.5 + $UT; |
| 111 | 111 | |
| 112 | - return Predict_Math::FMod2p(6.3003880987 * $deep_arg->ds50 + 1.72944494); |
|
| 112 | + return Predict_Math::FMod2p(6.3003880987*$deep_arg->ds50 + 1.72944494); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /* See the ThetaG doc block above */ |
@@ -118,11 +118,11 @@ discard block |
||
| 118 | 118 | /* Reference: The 1992 Astronomical Almanac, page B6. */ |
| 119 | 119 | $UT = Predict_Math::Frac($jd + 0.5); |
| 120 | 120 | $jd = $jd - $UT; |
| 121 | - $TU = ($jd - 2451545.0) / 36525; |
|
| 122 | - $GMST = 24110.54841 + $TU * (8640184.812866 + $TU * (0.093104 - $TU * 6.2E-6)); |
|
| 123 | - $GMST = Predict_Math::Modulus($GMST + Predict::secday * Predict::omega_E * $UT, Predict::secday); |
|
| 121 | + $TU = ($jd - 2451545.0)/36525; |
|
| 122 | + $GMST = 24110.54841 + $TU*(8640184.812866 + $TU*(0.093104 - $TU*6.2E-6)); |
|
| 123 | + $GMST = Predict_Math::Modulus($GMST + Predict::secday*Predict::omega_E*$UT, Predict::secday); |
|
| 124 | 124 | |
| 125 | - return Predict::twopi * $GMST / Predict::secday; |
|
| 125 | + return Predict::twopi*$GMST/Predict::secday; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | public static function unix2daynum($sec, $usec = 0) |
| 150 | 150 | { |
| 151 | - $time = ((($sec + $usec) / 86400.0) - 3651.0); |
|
| 151 | + $time = ((($sec + $usec)/86400.0) - 3651.0); |
|
| 152 | 152 | return $time + 2444238.5; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,8 +162,8 @@ discard block |
||
| 162 | 162 | /* Values determined using data from 1950-1991 in the 1990 |
| 163 | 163 | Astronomical Almanac. See DELTA_ET.WQ1 for details. */ |
| 164 | 164 | |
| 165 | - $delta_et = 26.465 + 0.747622 * ($year - 1950) + |
|
| 166 | - 1.886913 * sin(Predict::twopi * ($year - 1975) / 33); |
|
| 165 | + $delta_et = 26.465 + 0.747622*($year - 1950) + |
|
| 166 | + 1.886913*sin(Predict::twopi*($year - 1975)/33); |
|
| 167 | 167 | |
| 168 | 168 | return $delta_et; |
| 169 | 169 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | public static function daynum2unix($dn) { |
| 179 | 179 | // Converts a daynum to a UNIX timestamp |
| 180 | 180 | |
| 181 | - return (86400.0 * ($dn - 2444238.5 + 3651.0)); |
|
| 181 | + return (86400.0*($dn - 2444238.5 + 3651.0)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | public static function daynum2readable($dn, $zone = 'America/Los_Angeles', $format = 'm-d-Y H:i:s') |
| 194 | 194 | { |
| 195 | 195 | $unix = self::daynum2unix($dn); |
| 196 | - $date = new DateTime("@" . round($unix)); |
|
| 196 | + $date = new DateTime("@".round($unix)); |
|
| 197 | 197 | $dateTimezone = new DateTimezone($zone); |
| 198 | 198 | $date->setTimezone($dateTimezone); |
| 199 | 199 | return $date->format($format); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | { |
| 211 | 211 | $year = $tle->epoch_year; |
| 212 | 212 | $day = $tle->epoch_day; |
| 213 | - $sec = round(86400 * $tle->epoch_fod); |
|
| 213 | + $sec = round(86400*$tle->epoch_fod); |
|
| 214 | 214 | |
| 215 | 215 | $zone = new DateTimeZone('GMT'); |
| 216 | 216 | $date = new DateTime(); |
@@ -218,6 +218,6 @@ discard block |
||
| 218 | 218 | $date->setDate($year, 1, 1); |
| 219 | 219 | $date->setTime(0, 0, 0); |
| 220 | 220 | |
| 221 | - return $date->format('U') + (86400 * $day) + $sec - 86400; |
|
| 221 | + return $date->format('U') + (86400*$day) + $sec - 86400; |
|
| 222 | 222 | } |
| 223 | 223 | } |
@@ -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 | } |