sgp4/Tle.h

216 lines
4.2 KiB
C
Raw Normal View History

2011-03-24 16:08:24 +00:00
#ifndef TLE_H_
#define TLE_H_
#include "Globals.h"
#include "Julian.h"
2011-05-31 12:06:22 +00:00
#include "TleException.h"
2011-03-24 16:08:24 +00:00
#include <iostream>
2011-12-14 10:13:00 +00:00
class Tle
{
2011-03-24 16:08:24 +00:00
public:
2011-12-14 10:13:00 +00:00
Tle(const std::string& line_one, const std::string& line_two)
: line_one_(line_one), line_two_(line_two)
{
Initialize();
}
Tle(const std::string& name, const std::string& line_one,
const std::string& line_two)
: name_(name),line_one_(line_one), line_two_(line_two)
{
Initialize();
}
2011-03-24 16:08:24 +00:00
Tle(const Tle& tle);
2011-12-14 10:13:00 +00:00
virtual ~Tle()
{
}
2011-03-24 16:08:24 +00:00
/*
2011-04-07 13:42:25 +00:00
* get raw strings
2011-03-24 16:08:24 +00:00
*/
2011-12-14 10:13:00 +00:00
std::string GetName() const
{
2011-04-07 13:42:25 +00:00
return name_;
}
2011-03-24 16:08:24 +00:00
2011-12-14 10:13:00 +00:00
std::string GetLine1() const
{
2011-04-07 13:42:25 +00:00
return line_one_;
}
2011-03-24 16:08:24 +00:00
2011-12-14 10:13:00 +00:00
std::string GetLine2() const
{
2011-04-07 13:42:25 +00:00
return line_two_;
2011-03-24 16:08:24 +00:00
}
/*
2011-04-07 13:42:25 +00:00
* get tle values
2011-03-24 16:08:24 +00:00
*/
2011-12-14 10:13:00 +00:00
unsigned int NoradNumber() const
{
2011-04-07 13:42:25 +00:00
return norad_number_;
}
2011-03-24 16:08:24 +00:00
2011-12-14 10:13:00 +00:00
std::string InternationlDesignator() const
{
2011-04-07 13:42:25 +00:00
return international_designator_;
2011-03-24 16:08:24 +00:00
}
2011-12-14 10:13:00 +00:00
Julian Epoch() const
{
2011-04-07 13:42:25 +00:00
return epoch_;
2011-03-24 16:08:24 +00:00
}
2011-12-14 10:13:00 +00:00
double MeanMotionDot() const
{
2011-04-07 13:42:25 +00:00
return mean_motion_dot_;
2011-03-24 16:08:24 +00:00
}
2011-12-14 10:13:00 +00:00
double MeanMotionDot2() const
{
2011-04-07 13:42:25 +00:00
return mean_motion_dot2_;
}
2011-12-14 10:13:00 +00:00
double BStar() const
{
2011-04-07 13:42:25 +00:00
return bstar_;
}
2011-12-14 10:13:00 +00:00
double Inclination(bool in_degrees) const
{
2011-04-07 13:42:25 +00:00
if (in_degrees)
2011-12-14 10:13:00 +00:00
{
2011-04-07 13:42:25 +00:00
return inclination_;
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
else
2011-12-14 10:13:00 +00:00
{
2011-05-20 21:09:23 +00:00
return DegreesToRadians(inclination_);
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
}
2011-12-14 10:13:00 +00:00
double RightAscendingNode(const bool in_degrees) const
{
2011-04-07 13:42:25 +00:00
if (in_degrees)
2011-12-14 10:13:00 +00:00
{
2011-04-07 13:42:25 +00:00
return right_ascending_node_;
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
else
2011-12-14 10:13:00 +00:00
{
2011-05-20 21:09:23 +00:00
return DegreesToRadians(right_ascending_node_);
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
}
2011-12-14 10:13:00 +00:00
double Eccentricity() const
{
2011-04-07 13:42:25 +00:00
return eccentricity_;
}
2011-12-14 10:13:00 +00:00
double ArgumentPerigee(const bool in_degrees) const
{
2011-04-07 13:42:25 +00:00
if (in_degrees)
2011-12-14 10:13:00 +00:00
{
2011-04-07 13:42:25 +00:00
return argument_perigee_;
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
else
2011-12-14 10:13:00 +00:00
{
2011-05-20 21:09:23 +00:00
return DegreesToRadians(argument_perigee_);
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
}
2011-12-14 10:13:00 +00:00
double MeanAnomaly(const bool in_degrees) const
{
2011-04-07 13:42:25 +00:00
if (in_degrees)
2011-12-14 10:13:00 +00:00
{
2011-04-07 13:42:25 +00:00
return mean_anomaly_;
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
else
2011-12-14 10:13:00 +00:00
{
2011-05-20 21:09:23 +00:00
return DegreesToRadians(mean_anomaly_);
2011-12-14 10:13:00 +00:00
}
2011-04-07 13:42:25 +00:00
}
2011-12-14 10:13:00 +00:00
double MeanMotion() const
{
2011-04-07 13:42:25 +00:00
return mean_motion_;
}
2011-12-14 10:13:00 +00:00
unsigned int OrbitNumber() const
{
2011-04-07 13:42:25 +00:00
return orbit_number_;
2011-03-24 16:08:24 +00:00
}
/*
2011-04-07 13:42:25 +00:00
* helper / validation methods
2011-03-24 16:08:24 +00:00
*/
2011-12-14 10:13:00 +00:00
static unsigned int GetLineLength()
{
2011-05-27 21:05:10 +00:00
return TLE_LEN_LINE_DATA;
}
2011-12-14 10:13:00 +00:00
2011-05-31 12:06:22 +00:00
static void IsValidPair(const std::string& line1, const std::string& line2);
2011-12-14 10:13:00 +00:00
static void IsValidLine(const std::string& str, int line_number);
2011-04-07 13:42:25 +00:00
private:
2011-03-24 16:08:24 +00:00
/*
2011-04-07 13:42:25 +00:00
* initialize from raw tle strings
2011-03-24 16:08:24 +00:00
*/
2011-04-07 13:42:25 +00:00
void Initialize();
2011-03-24 16:08:24 +00:00
/*
2011-04-07 13:42:25 +00:00
* format a raw string into an exponent string
2011-03-24 16:08:24 +00:00
*/
static std::string ExpToDecimal(const std::string&);
/*
2011-04-07 13:42:25 +00:00
* validate a line against a pattern
*/
2011-12-14 10:13:00 +00:00
static void ValidateLine(const std::string& line,
const std::string& pattern);
2011-04-07 13:42:25 +00:00
/*
* compute checksum
2011-03-24 16:08:24 +00:00
*/
2011-04-07 13:42:25 +00:00
static int CheckSum(const std::string& str);
2011-03-24 16:08:24 +00:00
2011-12-14 10:13:00 +00:00
static std::string ExtractNoradNumber(const std::string& str,
int line_number);
2011-05-31 12:06:22 +00:00
static bool IsValidLineLength(const std::string& str);
2011-04-07 13:42:25 +00:00
private:
2011-03-24 16:08:24 +00:00
/*
* raw tle data
*/
std::string name_;
std::string line_one_;
std::string line_two_;
/*
2011-04-07 13:42:25 +00:00
* extracted values all in native units
2011-03-24 16:08:24 +00:00
*/
unsigned int norad_number_;
2011-04-07 13:42:25 +00:00
std::string international_designator_;
Julian epoch_;
double mean_motion_dot_;
double mean_motion_dot2_;
double bstar_;
double inclination_;
double right_ascending_node_;
double eccentricity_;
double argument_perigee_;
double mean_anomaly_;
double mean_motion_;
unsigned int orbit_number_;
2011-03-24 16:08:24 +00:00
/*
2011-12-14 10:13:00 +00:00
* line lengths
2011-03-24 16:08:24 +00:00
*/
static const unsigned int TLE_LEN_LINE_DATA = 69;
static const unsigned int TLE_LEN_LINE_NAME = 22;
2011-12-14 10:13:00 +00:00
};
2011-03-24 16:08:24 +00:00
#endif