2019-09-02 08:56:03 -06:00
|
|
|
#include "SGP4.h"
|
|
|
|
#include <string>
|
|
|
|
#include <time.h>
|
2020-02-11 08:54:41 -07:00
|
|
|
|
2020-01-21 11:13:29 -07:00
|
|
|
#include "CLI/CLI.hpp"
|
|
|
|
#include "version.hh"
|
|
|
|
|
|
|
|
static char program[]="tlecatch";
|
|
|
|
|
2019-09-02 08:56:03 -06:00
|
|
|
using namespace std;
|
2020-01-21 11:13:29 -07:00
|
|
|
|
|
|
|
extern const char* g_gitHash;
|
|
|
|
|
2019-09-02 08:56:03 -06:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
string line;
|
|
|
|
// DateTime d(2019, 8, 31, 1, 52, 30);
|
|
|
|
time_t now = time(0);
|
|
|
|
struct tm tm;
|
|
|
|
gmtime_r(&now, &tm);
|
2020-01-21 11:13:29 -07:00
|
|
|
bool doVERSION{false};
|
|
|
|
|
|
|
|
CLI::App app(program);
|
|
|
|
|
|
|
|
app.add_flag("--version", doVERSION, "show program version and copyright");
|
|
|
|
|
|
|
|
try {
|
|
|
|
app.parse(argc, argv);
|
|
|
|
} catch(const CLI::Error &e) {
|
|
|
|
return app.exit(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(doVERSION) {
|
2020-01-22 15:45:29 -07:00
|
|
|
showVersion(program, g_gitHash);
|
2020-01-21 11:13:29 -07:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2019-09-02 08:56:03 -06:00
|
|
|
for(;;) {
|
|
|
|
DateTime d(1900 + tm.tm_year, tm.tm_mon+1, tm.tm_mday, 04, 43, 51);
|
|
|
|
string name, line1, line2;
|
|
|
|
if(!getline(cin, name) || !getline(cin, line1) || !getline(cin, line2))
|
|
|
|
break;
|
|
|
|
name.resize(name.size()-1);
|
|
|
|
line1.resize(line1.size()-1);
|
|
|
|
line2.resize(line2.size()-1);
|
|
|
|
Tle tle(line1, line2);
|
|
|
|
/*
|
|
|
|
cout<<"line1: "<<line1<<endl;
|
|
|
|
cout<<"line2: "<<line2<<endl;
|
|
|
|
cout << tle.ToString() << endl;
|
|
|
|
*/
|
|
|
|
|
|
|
|
SGP4 sgp4(tle);
|
|
|
|
|
|
|
|
for(int n = 0 ; n < 1; ++n) {
|
|
|
|
auto eci = sgp4.FindPosition(d);
|
|
|
|
cout << name <<" "<<d <<": "<<eci.Position() << " " <<eci.Velocity() << " " << eci.ToGeodetic()<<endl;
|
|
|
|
double theta = -eci.GetDateTime().ToGreenwichSiderealTime();
|
|
|
|
Vector rot = eci.Position();
|
|
|
|
rot.x = eci.Position().x * cos(theta) - eci.Position().y * sin(theta);
|
|
|
|
rot.y = eci.Position().x * sin(theta) + eci.Position().y * cos(theta);
|
|
|
|
cout << " " << rot<< endl;
|
|
|
|
|
|
|
|
d = d.AddSeconds(30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|