Remove unnecessary virtual destructor. Correct doxygen comments. Adjust formatting.

feature/19
Daniel Warner 2016-05-18 20:57:15 +01:00
parent faf87bed0d
commit 7cf5e6496b
24 changed files with 158 additions and 281 deletions

4
configure vendored
View File

@ -3234,9 +3234,9 @@ fi
if test x$enable_debug = xyes; then if test x$enable_debug = xyes; then
AM_CXXFLAGS="-g -O0 -Werror -Wextra -W -Wall -Wconversion" AM_CXXFLAGS="-g -O0 -Wextra -W -Wall -Wconversion -std=c++11"
else else
AM_CXXFLAGS="-DNDEBUG -O2 -fomit-frame-pointer -Wextra -Werror -W -Wall -Wconversion" AM_CXXFLAGS="-DNDEBUG -O2 -fomit-frame-pointer -Wextra -W -Wall -Wconversion -std=c++11"
fi fi
ac_ext=c ac_ext=c

View File

@ -19,9 +19,9 @@ AC_ARG_ENABLE(debug,
enable_debug=no) enable_debug=no)
if test x$enable_debug = xyes; then if test x$enable_debug = xyes; then
AM_CXXFLAGS="-g -O0 -Werror -Wextra -W -Wall -Wconversion" AM_CXXFLAGS="-g -O0 -Wextra -W -Wall -Wconversion -std=c++11"
else else
AM_CXXFLAGS="-DNDEBUG -O2 -fomit-frame-pointer -Wextra -Werror -W -Wall -Wconversion" AM_CXXFLAGS="-DNDEBUG -O2 -fomit-frame-pointer -Wextra -W -Wall -Wconversion -std=c++11"
fi fi
AC_SEARCH_LIBS([clock_gettime], AC_SEARCH_LIBS([clock_gettime],

View File

@ -79,13 +79,6 @@ public:
altitude = geo.altitude; altitude = geo.altitude;
} }
/**
* Destructor
*/
virtual ~CoordGeodetic()
{
}
/** /**
* Assignment operator * Assignment operator
* @param[in] geo object to copy from * @param[in] geo object to copy from
@ -158,8 +151,8 @@ private:
/** /**
* Dump a Coordgeodetic to a stream * Dump a Coordgeodetic to a stream
* @params[in,out] strm stream to output to * @param[in,out] strm stream to output to
* @params[in] g the CoordGeodetic to print * @param[in] g the CoordGeodetic to print
*/ */
inline std::ostream& operator<<(std::ostream& strm, const CoordGeodetic& g) inline std::ostream& operator<<(std::ostream& strm, const CoordGeodetic& g)
{ {

View File

@ -31,17 +31,17 @@
* Azimuth and elevation are stored in radians. Range in kilometres. Range * Azimuth and elevation are stored in radians. Range in kilometres. Range
* rate in kilometres/second. * rate in kilometres/second.
*/ */
struct CoordTopocentric struct CoordTopocentric final
{ {
public: public:
/** /**
* Default constructor * Default constructor
*/ */
CoordTopocentric() CoordTopocentric()
: azimuth(0.0), : azimuth(0.0)
elevation(0.0), , elevation(0.0)
range(0.0), , range(0.0)
range_rate(0.0) , range_rate(0.0)
{ {
} }
@ -57,10 +57,10 @@ public:
double el, double el,
double rnge, double rnge,
double rnge_rate) double rnge_rate)
: azimuth(az), : azimuth(az)
elevation(el), , elevation(el)
range(rnge), , range(rnge)
range_rate(rnge_rate) , range_rate(rnge_rate)
{ {
} }
@ -76,13 +76,6 @@ public:
range_rate = topo.range_rate; range_rate = topo.range_rate;
} }
/**
* Destructor
*/
virtual ~CoordTopocentric()
{
}
/** /**
* Assignment operator * Assignment operator
* @param[in] topo object to copy from * @param[in] topo object to copy from

View File

@ -21,6 +21,7 @@
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstdint>
#include "TimeSpan.h" #include "TimeSpan.h"
#include "Util.h" #include "Util.h"
@ -57,7 +58,7 @@ public:
* Constructor * Constructor
* @param[in] ticks raw tick value * @param[in] ticks raw tick value
*/ */
DateTime(unsigned long long ticks) DateTime(int64_t ticks)
: m_encoded(ticks) : m_encoded(ticks)
{ {
} }
@ -67,9 +68,10 @@ public:
* @param[in] year the year * @param[in] year the year
* @param[in] doy the day of the year * @param[in] doy the day of the year
*/ */
DateTime(int year, double doy) DateTime(unsigned int year, double doy)
{ {
m_encoded = TimeSpan(static_cast<long long int>(AbsoluteDays(year, doy) * TicksPerDay)).Ticks(); m_encoded = TimeSpan(
static_cast<int64_t>(AbsoluteDays(year, doy) * TicksPerDay)).Ticks();
} }
/** /**
@ -298,10 +300,9 @@ public:
/** /**
* *
*/ */
double AbsoluteDays(int year, double doy) const double AbsoluteDays(unsigned int year, double doy) const
{ {
int64_t previousYear = year - 1;
int previousYear = year - 1;
/* /*
* + days in previous years ignoring leap days * + days in previous years ignoring leap days
@ -309,10 +310,10 @@ public:
* - minus prior century years * - minus prior century years
* + plus prior years divisible by 400 days * + plus prior years divisible by 400 days
*/ */
long long daysSoFar = 365 * previousYear int64_t daysSoFar = 365 * previousYear
+ previousYear / 4 + previousYear / 4LL
- previousYear / 100 - previousYear / 100LL
+ previousYear / 400; + previousYear / 400LL;
return static_cast<double>(daysSoFar) + doy - 1.0; return static_cast<double>(daysSoFar) + doy - 1.0;
} }
@ -441,11 +442,11 @@ public:
DateTime AddMicroseconds(const double microseconds) const DateTime AddMicroseconds(const double microseconds) const
{ {
long long ticks = static_cast<long long>(microseconds * TicksPerMicrosecond); int64_t ticks = static_cast<int64_t>(microseconds * TicksPerMicrosecond);
return AddTicks(ticks); return AddTicks(ticks);
} }
DateTime AddTicks(long long ticks) const DateTime AddTicks(int64_t ticks) const
{ {
return DateTime(m_encoded + ticks); return DateTime(m_encoded + ticks);
} }
@ -454,7 +455,7 @@ public:
* Get the number of ticks * Get the number of ticks
* @returns the number of ticks * @returns the number of ticks
*/ */
long long Ticks() const int64_t Ticks() const
{ {
return m_encoded; return m_encoded;
} }
@ -646,7 +647,7 @@ public:
} }
private: private:
unsigned long long m_encoded; int64_t m_encoded;
}; };
inline std::ostream& operator<<(std::ostream& strm, const DateTime& dt) inline std::ostream& operator<<(std::ostream& strm, const DateTime& dt)
@ -656,24 +657,12 @@ inline std::ostream& operator<<(std::ostream& strm, const DateTime& dt)
inline DateTime operator+(const DateTime& dt, TimeSpan ts) inline DateTime operator+(const DateTime& dt, TimeSpan ts)
{ {
long long int res = dt.Ticks() + ts.Ticks(); return DateTime(dt.Ticks() + ts.Ticks());
if (res < 0 || res > MaxValueTicks)
{
throw 1;
}
return DateTime(res);
} }
inline DateTime operator-(const DateTime& dt, const TimeSpan& ts) inline DateTime operator-(const DateTime& dt, const TimeSpan& ts)
{ {
long long int res = dt.Ticks() - ts.Ticks(); return DateTime(dt.Ticks() - ts.Ticks());
if (res < 0 || res > MaxValueTicks)
{
throw 1;
}
return DateTime(res);
} }
inline TimeSpan operator-(const DateTime& dt1, const DateTime& dt2) inline TimeSpan operator-(const DateTime& dt1, const DateTime& dt2)

View File

@ -0,0 +1,5 @@
#include "DecayedException.h"
DecayedException::~DecayedException()
{
}

View File

@ -21,12 +21,13 @@
#include "DateTime.h" #include "DateTime.h"
#include "Vector.h" #include "Vector.h"
#include <exception> #include <stdexcept>
#include <string>
/** /**
* @brief The exception that the SGP4 class throws when a satellite decays. * @brief The exception that the SGP4 class throws when a satellite decays.
*/ */
class DecayedException : public std::exception class DecayedException : public std::runtime_error
{ {
public: public:
/** /**
@ -36,24 +37,16 @@ public:
* @param[in] vel velocity of the satellite at dt * @param[in] vel velocity of the satellite at dt
*/ */
DecayedException(const DateTime& dt, const Vector& pos, const Vector& vel) DecayedException(const DateTime& dt, const Vector& pos, const Vector& vel)
: _dt(dt), _pos(pos), _vel(vel) : runtime_error("Satellite decayed")
, _dt(dt)
, _pos(pos)
, _vel(vel)
{ {
} }
/** DecayedException(const DecayedException&) = default;
* Destructor
*/
virtual ~DecayedException(void) throw ()
{
}
/** virtual ~DecayedException();
* @returns the error string
*/
virtual const char* what() const throw ()
{
return "Error: Satellite decayed";
}
/** /**
* @returns the date * @returns the date

View File

@ -54,11 +54,11 @@ public:
/** /**
* @param[in] dt the date to be used for this position * @param[in] dt the date to be used for this position
* @param[in] position * @param[in] position the position
*/ */
Eci(const DateTime &dt, const Vector &position) Eci(const DateTime &dt, const Vector &position)
: m_dt(dt), : m_dt(dt)
m_position(position) , m_position(position)
{ {
} }
@ -68,16 +68,9 @@ public:
* @param[in] velocity the velocity * @param[in] velocity the velocity
*/ */
Eci(const DateTime &dt, const Vector &position, const Vector &velocity) Eci(const DateTime &dt, const Vector &position, const Vector &velocity)
: m_dt(dt), : m_dt(dt)
m_position(position), , m_position(position)
m_velocity(velocity) , m_velocity(velocity)
{
}
/**
* Destructor
*/
virtual ~Eci()
{ {
} }

View File

@ -7,6 +7,9 @@ libsgp4_a_SOURCES = \
Globals.cpp \ Globals.cpp \
Observer.cpp \ Observer.cpp \
OrbitalElements.cpp \ OrbitalElements.cpp \
DecayedException.cpp \
SatelliteException.cpp \
TleException.cpp \
SGP4.cpp \ SGP4.cpp \
SolarPosition.cpp \ SolarPosition.cpp \
TimeSpan.cpp \ TimeSpan.cpp \
@ -14,7 +17,7 @@ libsgp4_a_SOURCES = \
Util.cpp \ Util.cpp \
Vector.cpp Vector.cpp
include_HEADERS = \ include_HEADERS = \
CoordGeodetic.h \ CoordGeodetic.h \
CoordTopocentric.h \ CoordTopocentric.h \
DateTime.h \ DateTime.h \

View File

@ -102,8 +102,10 @@ libsgp4_a_LIBADD =
am_libsgp4_a_OBJECTS = CoordGeodetic.$(OBJEXT) \ am_libsgp4_a_OBJECTS = CoordGeodetic.$(OBJEXT) \
CoordTopocentric.$(OBJEXT) DateTime.$(OBJEXT) Eci.$(OBJEXT) \ CoordTopocentric.$(OBJEXT) DateTime.$(OBJEXT) Eci.$(OBJEXT) \
Globals.$(OBJEXT) Observer.$(OBJEXT) OrbitalElements.$(OBJEXT) \ Globals.$(OBJEXT) Observer.$(OBJEXT) OrbitalElements.$(OBJEXT) \
SGP4.$(OBJEXT) SolarPosition.$(OBJEXT) TimeSpan.$(OBJEXT) \ DecayedException.$(OBJEXT) SatelliteException.$(OBJEXT) \
Tle.$(OBJEXT) Util.$(OBJEXT) Vector.$(OBJEXT) TleException.$(OBJEXT) SGP4.$(OBJEXT) SolarPosition.$(OBJEXT) \
TimeSpan.$(OBJEXT) Tle.$(OBJEXT) Util.$(OBJEXT) \
Vector.$(OBJEXT)
libsgp4_a_OBJECTS = $(am_libsgp4_a_OBJECTS) libsgp4_a_OBJECTS = $(am_libsgp4_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ DEFAULT_INCLUDES = -I.@am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
@ -233,6 +235,9 @@ libsgp4_a_SOURCES = \
Globals.cpp \ Globals.cpp \
Observer.cpp \ Observer.cpp \
OrbitalElements.cpp \ OrbitalElements.cpp \
DecayedException.cpp \
SatelliteException.cpp \
TleException.cpp \
SGP4.cpp \ SGP4.cpp \
SolarPosition.cpp \ SolarPosition.cpp \
TimeSpan.cpp \ TimeSpan.cpp \
@ -337,14 +342,17 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoordGeodetic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoordGeodetic.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoordTopocentric.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoordTopocentric.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DateTime.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DateTime.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DecayedException.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Eci.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Eci.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Globals.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Globals.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Observer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Observer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OrbitalElements.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OrbitalElements.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SGP4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SGP4.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SatelliteException.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SolarPosition.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SolarPosition.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeSpan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeSpan.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tle.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TleException.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Util.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vector.Po@am__quote@

View File

@ -39,8 +39,8 @@ public:
Observer(const double latitude, Observer(const double latitude,
const double longitude, const double longitude,
const double altitude) const double altitude)
: m_geo(latitude, longitude, altitude), : m_geo(latitude, longitude, altitude)
m_eci(DateTime(), m_geo) , m_eci(DateTime(), m_geo)
{ {
} }
@ -49,15 +49,8 @@ public:
* @param[in] geo the observers position * @param[in] geo the observers position
*/ */
Observer(const CoordGeodetic &geo) Observer(const CoordGeodetic &geo)
: m_geo(geo), : m_geo(geo)
m_eci(DateTime(), geo) , m_eci(DateTime(), geo)
{
}
/**
* Destructor
*/
virtual ~Observer()
{ {
} }

View File

@ -31,10 +31,6 @@ class OrbitalElements
public: public:
OrbitalElements(const Tle& tle); OrbitalElements(const Tle& tle);
virtual ~OrbitalElements()
{
}
/* /*
* XMO * XMO
*/ */

View File

@ -215,8 +215,6 @@ void SGP4::Initialise()
} }
} }
#include <iomanip>
Eci SGP4::FindPosition(const DateTime& dt) const Eci SGP4::FindPosition(const DateTime& dt) const
{ {
return FindPosition((dt - elements_.Epoch()).TotalMinutes()); return FindPosition((dt - elements_.Epoch()).TotalMinutes());
@ -433,23 +431,6 @@ Eci SGP4::FindPositionSGP4(double tsince) const
} }
/**
* @param[in] tsince
* @param[in] e
* @param[in] a
* @param[in] omega
* @param[in] xl
* @param[in] xnode
* @param[in] xincl
* @param[in] xlcof
* @param[in] aycof
* @param[in] x3thml
* @param[in] x1mth2
* @param[in] x7thm1
* @param[in] cosio
* @param[in] sinio
* @returns Eci result
*/
Eci SGP4::CalculateFinalPositionVelocity( Eci SGP4::CalculateFinalPositionVelocity(
const double tsince, const double tsince,
const double e, const double e,
@ -633,14 +614,6 @@ Eci SGP4::CalculateFinalPositionVelocity(
return Eci(elements_.Epoch().AddMinutes(tsince), position, velocity); return Eci(elements_.Epoch().AddMinutes(tsince), position, velocity);
} }
/**
* @param[in] x
* @param[in] constant
* @param[in] linear
* @param[in] squared
* @param[in] cubed
* @returns result
*/
static inline double EvaluateCubicPolynomial( static inline double EvaluateCubicPolynomial(
const double x, const double x,
const double constant, const double constant,
@ -651,18 +624,6 @@ static inline double EvaluateCubicPolynomial(
return constant + x * (linear + x * (squared + x * cubed)); return constant + x * (linear + x * (squared + x * cubed));
} }
/**
* Deep space initialisation
* @param[in] eosq
* @param[in] sinio
* @param[in] cosio
* @param[in] betao
* @param[in] theta2
* @param[in] betao2
* @param[in] xmdot
* @param[in] omgdot
* @param[in] xnodot
*/
void SGP4::DeepSpaceInitialise( void SGP4::DeepSpaceInitialise(
const double eosq, const double eosq,
const double sinio, const double sinio,
@ -1073,15 +1034,6 @@ void SGP4::DeepSpaceInitialise(
} }
} }
/*
* Calculate lunar / solar terms
* @param[in] tsince
* @param[out] pe
* @param[out] pinc
* @param[out] pl
* @param[out] pgh
* @param[out] ph
*/
void SGP4::DeepSpaceCalculateLunarSolarTerms( void SGP4::DeepSpaceCalculateLunarSolarTerms(
const double tsince, const double tsince,
double& pe, double& pe,
@ -1149,15 +1101,6 @@ void SGP4::DeepSpaceCalculateLunarSolarTerms(
ph = shs + shl; ph = shs + shl;
} }
/*
* Calculate lunar / solar periodics and apply
* @param[in] tsince
* @param[in,out] em
* @param[in,out] xinc
* @param[in,out] omgasm
* @param[in,out] xnodes
* @param[in,out] xll
*/
void SGP4::DeepSpacePeriodics( void SGP4::DeepSpacePeriodics(
const double tsince, const double tsince,
double& em, double& em,
@ -1261,16 +1204,6 @@ void SGP4::DeepSpacePeriodics(
} }
} }
/*
* Deep space secular effects
* @param[in] tsince
* @param[in,out] xll
* @param[in,out] omgasm
* @param[in,out] xnodes
* @param[in,out] em
* @param[in,out] xinc
* @param[in,out] xn
*/
void SGP4::DeepSpaceSecular( void SGP4::DeepSpaceSecular(
const double tsince, const double tsince,
double& xll, double& xll,
@ -1372,10 +1305,6 @@ void SGP4::DeepSpaceSecular(
} }
} }
/*
* Calculate dot terms
* @param[in,out] the integrator values
*/
void SGP4::DeepSpaceCalcDotTerms(struct IntegratorValues& values) const void SGP4::DeepSpaceCalcDotTerms(struct IntegratorValues& values) const
{ {
static const double G22 = 5.7686396; static const double G22 = 5.7686396;
@ -1455,12 +1384,6 @@ void SGP4::DeepSpaceCalcDotTerms(struct IntegratorValues& values) const
values.xnddt *= values.xldot; values.xnddt *= values.xldot;
} }
/*
* Deep space integrator for time period of delt
* @param[in] delt
* @param[in] step2
* @param[in] values
*/
void SGP4::DeepSpaceIntegrator( void SGP4::DeepSpaceIntegrator(
const double delt, const double delt,
const double step2, const double step2,

View File

@ -33,7 +33,7 @@
/** /**
* @brief The simplified perturbations model 4 propagater. * @brief The simplified perturbations model 4 propagater.
*/ */
class SGP4 class SGP4 final
{ {
public: public:
SGP4(const Tle& tle) SGP4(const Tle& tle)
@ -42,10 +42,6 @@ public:
Initialise(); Initialise();
} }
virtual ~SGP4()
{
}
void SetTle(const Tle& tle); void SetTle(const Tle& tle);
Eci FindPosition(double tsince) const; Eci FindPosition(double tsince) const;
Eci FindPosition(const DateTime& date) const; Eci FindPosition(const DateTime& date) const;
@ -91,16 +87,7 @@ private:
double gsto; double gsto;
double zmol; double zmol;
double zmos; double zmos;
/*
* whether the deep space orbit is
* geopotential resonance for 12 hour orbits
*/
bool resonance_flag;
/*
* whether the deep space orbit is
* 24h synchronous resonance
*/
bool synchronous_flag;
/* /*
* lunar / solar constants for epoch * lunar / solar constants for epoch
* applied during DeepSpaceSecular() * applied during DeepSpaceSecular()
@ -154,6 +141,16 @@ private:
double del1; double del1;
double del2; double del2;
double del3; double del3;
/*
* whether the deep space orbit is
* geopotential resonance for 12 hour orbits
*/
bool resonance_flag;
/*
* whether the deep space orbit is
* 24h synchronous resonance
*/
bool synchronous_flag;
}; };
struct IntegratorValues struct IntegratorValues
@ -209,6 +206,9 @@ private:
const double x7thm1, const double x7thm1,
const double cosio, const double cosio,
const double sinio) const; const double sinio) const;
/**
* Deep space initialisation
*/
void DeepSpaceInitialise( void DeepSpaceInitialise(
const double eosq, const double eosq,
const double sinio, const double sinio,
@ -219,6 +219,9 @@ private:
const double xmdot, const double xmdot,
const double omgdot, const double omgdot,
const double xnodot); const double xnodot);
/*
* Calculate lunar / solar terms
*/
void DeepSpaceCalculateLunarSolarTerms( void DeepSpaceCalculateLunarSolarTerms(
const double tsince, const double tsince,
double& pe, double& pe,
@ -226,6 +229,9 @@ private:
double& pl, double& pl,
double& pgh, double& pgh,
double& ph) const; double& ph) const;
/**
* Calculate lunar / solar periodics and apply
*/
void DeepSpacePeriodics( void DeepSpacePeriodics(
const double tsince, const double tsince,
double& em, double& em,
@ -233,6 +239,9 @@ private:
double& omgasm, double& omgasm,
double& xnodes, double& xnodes,
double& xll) const; double& xll) const;
/**
* Deep space secular effects
*/
void DeepSpaceSecular( void DeepSpaceSecular(
const double tsince, const double tsince,
double& xll, double& xll,
@ -241,19 +250,20 @@ private:
double& em, double& em,
double& xinc, double& xinc,
double& xn) const; double& xn) const;
/**
* Calculate dot terms
* @param[in,out] values the integrator values
*/
void DeepSpaceCalcDotTerms(struct IntegratorValues& values) const; void DeepSpaceCalcDotTerms(struct IntegratorValues& values) const;
/**
* Deep space integrator for time period of delt
*/
void DeepSpaceIntegrator( void DeepSpaceIntegrator(
const double delt, const double delt,
const double step2, const double step2,
const struct IntegratorValues& values) const; const struct IntegratorValues& values) const;
void Reset(); void Reset();
/*
* flags
*/
bool use_simple_model_;
bool use_deep_space_;
/* /*
* the constants used * the constants used
*/ */
@ -268,6 +278,12 @@ private:
*/ */
OrbitalElements elements_; OrbitalElements elements_;
/*
* flags
*/
bool use_simple_model_;
bool use_deep_space_;
static const struct SGP4::CommonConstants Empty_CommonConstants; static const struct SGP4::CommonConstants Empty_CommonConstants;
static const struct SGP4::NearSpaceConstants Empty_NearSpaceConstants; static const struct SGP4::NearSpaceConstants Empty_NearSpaceConstants;
static const struct SGP4::DeepSpaceConstants Empty_DeepSpaceConstants; static const struct SGP4::DeepSpaceConstants Empty_DeepSpaceConstants;

View File

@ -0,0 +1,5 @@
#include "SatelliteException.h"
SatelliteException::~SatelliteException()
{
}

View File

@ -18,30 +18,23 @@
#ifndef SATELLITEEXCEPTION_H_ #ifndef SATELLITEEXCEPTION_H_
#define SATELLITEEXCEPTION_H_ #define SATELLITEEXCEPTION_H_
#include <exception> #include <stdexcept>
#include <string>
/** /**
* @brief The exception that the SGP4 class throws upon an error. * @brief The exception that the SGP4 class throws upon an error.
*/ */
class SatelliteException : public std::exception class SatelliteException : public std::runtime_error
{ {
public: public:
SatelliteException(const char* message) SatelliteException(const char* message)
: message_(message) : runtime_error(message)
{ {
} }
virtual ~SatelliteException(void) throw () SatelliteException(const SatelliteException&) = default;
{
}
virtual const char* what() const throw () virtual ~SatelliteException();
{
return message_.c_str();
}
private:
std::string message_;
}; };
#endif #endif

View File

@ -31,10 +31,6 @@ public:
{ {
} }
virtual ~SolarPosition()
{
}
Eci FindPosition(const DateTime& dt); Eci FindPosition(const DateTime& dt);
private: private:

View File

@ -22,22 +22,23 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <cmath> #include <cmath>
#include <cstdint>
namespace namespace
{ {
static const long long TicksPerDay = 86400000000LL; static const int64_t TicksPerDay = 86400000000LL;
static const long long TicksPerHour = 3600000000LL; static const int64_t TicksPerHour = 3600000000LL;
static const long long TicksPerMinute = 60000000LL; static const int64_t TicksPerMinute = 60000000LL;
static const long long TicksPerSecond = 1000000LL; static const int64_t TicksPerSecond = 1000000LL;
static const long long TicksPerMillisecond = 1000LL; static const int64_t TicksPerMillisecond = 1000LL;
static const long long TicksPerMicrosecond = 1LL; static const int64_t TicksPerMicrosecond = 1LL;
static const long long UnixEpoch = 62135596800000000LL; static const int64_t UnixEpoch = 62135596800000000LL;
static const long long MaxValueTicks = 315537897599999999LL; static const int64_t MaxValueTicks = 315537897599999999LL;
// 1582-Oct-15 // 1582-Oct-15
static const long long GregorianStart = 49916304000000000LL; static const int64_t GregorianStart = 49916304000000000LL;
} }
/** /**
@ -50,7 +51,7 @@ namespace
class TimeSpan class TimeSpan
{ {
public: public:
TimeSpan(long long ticks) TimeSpan(int64_t ticks)
: m_ticks(ticks) : m_ticks(ticks)
{ {
} }
@ -130,7 +131,7 @@ public:
return static_cast<int>(m_ticks % TicksPerSecond / TicksPerMicrosecond); return static_cast<int>(m_ticks % TicksPerSecond / TicksPerMicrosecond);
} }
long long Ticks() const int64_t Ticks() const
{ {
return m_ticks; return m_ticks;
} }
@ -194,7 +195,7 @@ public:
} }
private: private:
long long m_ticks; int64_t m_ticks;
void CalculateTicks(int days, void CalculateTicks(int days,
int hours, int hours,

View File

@ -25,9 +25,9 @@ namespace
static const unsigned int TLE1_LEN_NORADNUM = 5; static const unsigned int TLE1_LEN_NORADNUM = 5;
static const unsigned int TLE1_COL_INTLDESC_A = 9; static const unsigned int TLE1_COL_INTLDESC_A = 9;
static const unsigned int TLE1_LEN_INTLDESC_A = 2; static const unsigned int TLE1_LEN_INTLDESC_A = 2;
static const unsigned int TLE1_COL_INTLDESC_B = 11; // static const unsigned int TLE1_COL_INTLDESC_B = 11;
static const unsigned int TLE1_LEN_INTLDESC_B = 3; static const unsigned int TLE1_LEN_INTLDESC_B = 3;
static const unsigned int TLE1_COL_INTLDESC_C = 14; // static const unsigned int TLE1_COL_INTLDESC_C = 14;
static const unsigned int TLE1_LEN_INTLDESC_C = 3; static const unsigned int TLE1_LEN_INTLDESC_C = 3;
static const unsigned int TLE1_COL_EPOCH_A = 18; static const unsigned int TLE1_COL_EPOCH_A = 18;
static const unsigned int TLE1_LEN_EPOCH_A = 2; static const unsigned int TLE1_LEN_EPOCH_A = 2;
@ -39,10 +39,10 @@ namespace
static const unsigned int TLE1_LEN_MEANMOTIONDDT6 = 8; static const unsigned int TLE1_LEN_MEANMOTIONDDT6 = 8;
static const unsigned int TLE1_COL_BSTAR = 53; static const unsigned int TLE1_COL_BSTAR = 53;
static const unsigned int TLE1_LEN_BSTAR = 8; static const unsigned int TLE1_LEN_BSTAR = 8;
static const unsigned int TLE1_COL_EPHEMTYPE = 62; // static const unsigned int TLE1_COL_EPHEMTYPE = 62;
static const unsigned int TLE1_LEN_EPHEMTYPE = 1; // static const unsigned int TLE1_LEN_EPHEMTYPE = 1;
static const unsigned int TLE1_COL_ELNUM = 64; // static const unsigned int TLE1_COL_ELNUM = 64;
static const unsigned int TLE1_LEN_ELNUM = 4; // static const unsigned int TLE1_LEN_ELNUM = 4;
static const unsigned int TLE2_COL_NORADNUM = 2; static const unsigned int TLE2_COL_NORADNUM = 2;
static const unsigned int TLE2_LEN_NORADNUM = 5; static const unsigned int TLE2_LEN_NORADNUM = 5;
@ -147,6 +147,7 @@ void Tle::Initialize()
year += 2000; year += 2000;
else else
year += 1900; year += 1900;
epoch_ = DateTime(year, day); epoch_ = DateTime(year, day);
} }
@ -176,7 +177,7 @@ void Tle::ExtractInteger(const std::string& str, unsigned int& val)
if (isdigit(*i)) if (isdigit(*i))
{ {
found_digit = true; found_digit = true;
temp = (temp * 10) + (*i - '0'); temp = (temp * 10) + (static_cast<unsigned char>(*i) - '0');
} }
else if (found_digit) else if (found_digit)
{ {
@ -335,7 +336,7 @@ void Tle::ExtractExponential(const std::string& str, double& val)
throw TleException("Invalid sign"); throw TleException("Invalid sign");
} }
} }
else if (i == str.begin() + str.length() - 2) else if (i == str.end() - 2)
{ {
if (*i == '-' || *i == '+') if (*i == '-' || *i == '+')
{ {

View File

@ -37,8 +37,8 @@ public:
*/ */
Tle(const std::string& line_one, Tle(const std::string& line_one,
const std::string& line_two) const std::string& line_two)
: line_one_(line_one), : line_one_(line_one)
line_two_(line_two) , line_two_(line_two)
{ {
Initialize(); Initialize();
} }
@ -52,9 +52,9 @@ public:
Tle(const std::string& name, Tle(const std::string& name,
const std::string& line_one, const std::string& line_one,
const std::string& line_two) const std::string& line_two)
: name_(name), : name_(name)
line_one_(line_one), , line_one_(line_one)
line_two_(line_two) , line_two_(line_two)
{ {
Initialize(); Initialize();
} }
@ -84,13 +84,6 @@ public:
orbit_number_ = tle.orbit_number_; orbit_number_ = tle.orbit_number_;
} }
/**
* Destructor
*/
virtual ~Tle()
{
}
/** /**
* Get the satellite name * Get the satellite name
* @returns the satellite name * @returns the satellite name
@ -322,7 +315,6 @@ private:
std::string line_one_; std::string line_one_;
std::string line_two_; std::string line_two_;
unsigned int norad_number_;
std::string int_designator_; std::string int_designator_;
DateTime epoch_; DateTime epoch_;
double mean_motion_dt2_; double mean_motion_dt2_;
@ -334,6 +326,7 @@ private:
double argument_perigee_; double argument_perigee_;
double mean_anomaly_; double mean_anomaly_;
double mean_motion_; double mean_motion_;
unsigned int norad_number_;
unsigned int orbit_number_; unsigned int orbit_number_;
static const unsigned int TLE_LEN_LINE_DATA = 69; static const unsigned int TLE_LEN_LINE_DATA = 69;

5
libsgp4/TleException.cpp Normal file
View File

@ -0,0 +1,5 @@
#include "TleException.h"
TleException::~TleException()
{
}

View File

@ -18,14 +18,15 @@
#ifndef TLEEXCEPTION_H_ #ifndef TLEEXCEPTION_H_
#define TLEEXCEPTION_H_ #define TLEEXCEPTION_H_
#include <exception> #include <stdexcept>
#include <string>
/** /**
* @brief The exception that the Tle class throws on an error. * @brief The exception that the Tle class throws on an error.
* *
* The exception that the Tle decoder will throw on an error. * The exception that the Tle decoder will throw on an error.
*/ */
class TleException : public std::exception class TleException : public std::runtime_error
{ {
public: public:
/** /**
@ -33,29 +34,13 @@ public:
* @param message Exception message * @param message Exception message
*/ */
TleException(const char* message) TleException(const char* message)
: m_message(message) : runtime_error(message)
{ {
} }
/** TleException(const TleException&) = default;
* Destructor
*/
virtual ~TleException(void) throw ()
{
}
/** virtual ~TleException();
* Get the exception message
* @returns the exception message
*/
virtual const char* what() const throw ()
{
return m_message.c_str();
}
private:
/** the exception message */
std::string m_message;
}; };
#endif #endif

View File

@ -38,7 +38,7 @@ namespace Util
*/ */
inline double Mod(const double x, const double y) inline double Mod(const double x, const double y)
{ {
if (y == 0) if (y == 0.0)
{ {
return x; return x;
} }

View File

@ -80,13 +80,6 @@ public:
w = v.w; w = v.w;
} }
/**
* Destructor
*/
virtual ~Vector()
{
}
/** /**
* Assignment operator * Assignment operator
* @param v value to copy from * @param v value to copy from