Commit 21350fd2 authored by Alexander Lapshin's avatar Alexander Lapshin

refactor

parent 4911bf48
...@@ -229,7 +229,7 @@ bool OptOrbit::Build(Vect6& res) ...@@ -229,7 +229,7 @@ bool OptOrbit::Build(Vect6& res)
bool ret = false; bool ret = false;
int flag = 0; int flag = 0;
while (1) { while (true) {
Vect3 unitVector; Vect3 unitVector;
double r0; double r0;
......
...@@ -19,7 +19,7 @@ typedef rapidjson::Document jsondoc; ...@@ -19,7 +19,7 @@ typedef rapidjson::Document jsondoc;
inline bool extract_value(const jsonval& parent, const std::string& key, bool exist, bool* loaded, jsonval::ConstMemberIterator& result) inline bool extract_value(const jsonval& parent, const std::string& key, bool exist, bool* loaded, jsonval::ConstMemberIterator& result)
{ {
jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str()); const jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
if (itr == parent.MemberEnd() && exist) { if (itr == parent.MemberEnd() && exist) {
throw Exp() << "error: element '" << key << "' not found"; throw Exp() << "error: element '" << key << "' not found";
...@@ -484,6 +484,30 @@ void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std: ...@@ -484,6 +484,30 @@ void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std:
ss.AddMember(jname, jsvec, alc); ss.AddMember(jname, jsvec, alc);
} }
inline void PutValue(jsonalloc& alc, jsonval& ss, const std::string& conName, const std::vector<size_t>& vec)
{
jsonval jsvec(rapidjson::kArrayType);
for (const auto& el : vec) {
jsonval jvalue(el);
jsvec.PushBack(jvalue, alc);
}
jsonval jname(conName, alc);
ss.AddMember(jname, jsvec, alc);
}
inline void PutValue(jsonalloc& alc, jsonval& ss, const std::string& conName, const std::vector<double>& vec)
{
jsonval jsvec(rapidjson::kArrayType);
for (const auto& el : vec) {
jsonval jvalue(el);
jsvec.PushBack(jvalue, alc);
}
jsonval jname(conName, alc);
ss.AddMember(jname, jsvec, alc);
}
template <typename T> template <typename T>
void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std::vector<T>& vec) void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std::vector<T>& vec)
{ {
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "TimeFunctions.h" #include "TimeFunctions.h"
#include "json_functions.h" #include "json_functions.h"
static void loadjson(const jsonval& parent, const std::string& key, TimeJD& value, bool exist = true, bool* loaded = 0) static void loadjson(const jsonval& parent, const std::string& key, TimeJD& value, bool exist = true, bool* loaded = nullptr)
{ {
const jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str()); const jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "DrPeriod.h" #include "DrPeriod.h"
#include "GreenwichFrame.h" #include "GreenwichFrame.h"
#include "ECIFrame.h" #include "ECIFrame.h"
#include "METEFrame.h"
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include "mathconst.h" #include "mathconst.h"
......
...@@ -10,8 +10,8 @@ class AscNodeOrbit ...@@ -10,8 +10,8 @@ class AscNodeOrbit
public: public:
AscNodeOrbit(); AscNodeOrbit();
explicit AscNodeOrbit(const PhasePoint6D& p); explicit AscNodeOrbit(const PhasePoint6D& p);
void calculate(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, bool calc_params = true); void calculate(Propagator& prop, const TimeJD& date, bool vzmode, bool gcs_node, bool calc_params = true);
void calculate_desc(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, bool calc_params = true); void calculate_desc(Propagator& prop, const TimeJD& date, bool vzmode, bool gcs_node, bool calc_params = true);
void calculate_params(const PhasePoint6D& j2000AscNodePoint); void calculate_params(const PhasePoint6D& j2000AscNodePoint);
double get_latitude() const { return m_latitude; } double get_latitude() const { return m_latitude; }
double get_longitude() const { return m_longitude; } double get_longitude() const { return m_longitude; }
...@@ -29,9 +29,9 @@ public: ...@@ -29,9 +29,9 @@ public:
double get_age() const { return m_age; } double get_age() const { return m_age; }
bool is_desc() const { return m_is_desc; } bool is_desc() const { return m_is_desc; }
private: private:
void calc_asc_node(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, PhasePoint6D& result) const; void calc_asc_node(Propagator& prop, const TimeJD& date, bool vzmode, bool gcs_node, PhasePoint6D& result) const;
void calc_desc_node(Propagator& prop, const TimeJD& date, const bool vzmode, const bool gcs_node, PhasePoint6D& result) const; void calc_desc_node(Propagator& prop, const TimeJD& date, bool vzmode, bool gcs_node, PhasePoint6D& result) const;
void calc_draconic_period(Propagator& prop, const TimeJD& asc_node_date, const bool vzmode, const bool gcs_node, double& dracp, double& vdracp) const; void calc_draconic_period(Propagator& prop, const TimeJD& asc_node_date, bool vzmode, bool gcs_node, double& dracp, double& vdracp) const;
double get_kep_time(double TA, double e, double w) const; double get_kep_time(double TA, double e, double w) const;
static KepData get_kep_data(const Vect6& pos); static KepData get_kep_data(const Vect6& pos);
bool jump_arg_of_lat(const TimeJD& date, Propagator& prop, double dstU, bool gcs_node, SInitOrbit& result, int type = 0) const; bool jump_arg_of_lat(const TimeJD& date, Propagator& prop, double dstU, bool gcs_node, SInitOrbit& result, int type = 0) const;
......
...@@ -81,7 +81,7 @@ static const char* GetKeyById(const EnumToId* ids, int id, int size) ...@@ -81,7 +81,7 @@ static const char* GetKeyById(const EnumToId* ids, int id, int size)
TAssert(0); TAssert(0);
return 0; return nullptr;
} }
static const char* KpModelKeyById(int id) static const char* KpModelKeyById(int id)
......
#include "AtmModel.h" #include "AtmModel.h"
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include <map> #include <map>
#include <utility>
AtmModel::AtmModel() AtmModel::AtmModel()
: m_model("ATM_NONE") : m_model("ATM_NONE")
...@@ -9,8 +10,8 @@ AtmModel::AtmModel() ...@@ -9,8 +10,8 @@ AtmModel::AtmModel()
AtmModel::AtmModel(std::string model, std::string kpmodel) AtmModel::AtmModel(std::string model, std::string kpmodel)
: :
m_model(model), m_model(std::move(model)),
m_kpModel(kpmodel) m_kpModel(std::move(kpmodel))
{ {
} }
......
#ifndef ATMMODEL_H #ifndef ATMMODEL_H
#define ATMMODEL_H #define ATMMODEL_H
#include <iostream>
#include <string> #include <string>
#include <myXML_Document.hpp> #include <myXML_Document.hpp>
#include "json_functions.h" #include "json_functions.h"
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#define __TIME_H_ #define __TIME_H_
#include <string> #include <string>
#include "Converter.h"
#include <iostream>
#include <iomanip> #include <iomanip>
#include "globals.h" #include "globals.h"
#include <cmath> #include <cmath>
......
#pragma once #pragma once
#include <string> #include <string>
#include <sstream>
// enum STR2INT_ERROR { XSUCCESS, XOVERFLOW, XUNDERFLOW, XINCONVERTIBLE }; // enum STR2INT_ERROR { XSUCCESS, XOVERFLOW, XUNDERFLOW, XINCONVERTIBLE };
// //
......
...@@ -28,12 +28,12 @@ bool CovMtx::Load(myXML::Contain* parent, bool loadkb, bool loadsp) ...@@ -28,12 +28,12 @@ bool CovMtx::Load(myXML::Contain* parent, bool loadkb, bool loadsp)
std::string names[] = {"XX", "XY", "XZ", "XVX", "XVY", "XVZ", "YY", "YZ", "YVX", "YVY", "YVZ", "ZZ", "ZVX", "ZVY", "ZVZ", "VXVX", "VXVY", "VXVZ", "VYVY", "VYVZ", "VZVZ", "XS", "YS", "ZS", "VXS", "VYS", "VZS", "SK", "XK", "YK", "ZK", "VXK", "VYK", "VZK", "SS", "KK"}; std::string names[] = {"XX", "XY", "XZ", "XVX", "XVY", "XVZ", "YY", "YZ", "YVX", "YVY", "YVZ", "ZZ", "ZVX", "ZVY", "ZVZ", "VXVX", "VXVY", "VXVZ", "VYVY", "VYVZ", "VZVZ", "XS", "YS", "ZS", "VXS", "VYS", "VZS", "SK", "XK", "YK", "ZK", "VXK", "VYK", "VZK", "SS", "KK"};
std::map<std::string, double> covmap; std::map<std::string, double> covmap;
for (int i = 0; i < 36; ++i) { for (const auto& name : names) {
double value; double value;
bool loaded; bool loaded;
LoadXML(con, names[i], value, false, &loaded); LoadXML(con, name, value, false, &loaded);
if (loaded) { if (loaded) {
covmap[names[i]] = value; covmap[name] = value;
} }
} }
...@@ -61,10 +61,10 @@ void CovMtx::load(const jsonval& parent) ...@@ -61,10 +61,10 @@ void CovMtx::load(const jsonval& parent)
std::string names[] = {"XX", "XY", "XZ", "XVX", "XVY", "XVZ", "YY", "YZ", "YVX", "YVY", "YVZ", "ZZ", "ZVX", "ZVY", "ZVZ", "VXVX", "VXVY", "VXVZ", "VYVY", "VYVZ", "VZVZ", "XS", "YS", "ZS", "VXS", "VYS", "VZS", "SK", "XK", "YK", "ZK", "VXK", "VYK", "VZK", "SS", "KK"}; std::string names[] = {"XX", "XY", "XZ", "XVX", "XVY", "XVZ", "YY", "YZ", "YVX", "YVY", "YVZ", "ZZ", "ZVX", "ZVY", "ZVZ", "VXVX", "VXVY", "VXVZ", "VYVY", "VYVZ", "VZVZ", "XS", "YS", "ZS", "VXS", "VYS", "VZS", "SK", "XK", "YK", "ZK", "VXK", "VYK", "VZK", "SS", "KK"};
std::map<std::string, double> covmap; std::map<std::string, double> covmap;
for (int i = 0; i < 36; ++i) { for (const auto& name : names) {
double value; double value;
if (loadjson(parent, names[i], value, false)) { if (loadjson(parent, name, value, false)) {
covmap[names[i]] = value; covmap[name] = value;
} }
} }
......
#include "EarthModel.h" #include "EarthModel.h"
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include <map> #include <map>
#include <utility>
EarthModel::EarthModel() EarthModel::EarthModel() = default;
{
}
EarthModel::EarthModel(std::string model, int m, int n) EarthModel::EarthModel(std::string model, int m, int n)
: :
m_model(model),
m_harmonicsM(m), m_harmonicsM(m),
m_harmonicsN(n) m_harmonicsN(n),
m_model(std::move(model))
{ {
} }
......
...@@ -9,7 +9,7 @@ class EarthModel ...@@ -9,7 +9,7 @@ class EarthModel
{ {
public: public:
EarthModel(); EarthModel();
EarthModel(std::string m_model, int m, int n); EarthModel(std::string model, int m, int n);
bool Load(myXML::Contain* parent); bool Load(myXML::Contain* parent);
void load(const jsonval& parent); void load(const jsonval& parent);
std::string GetModel() const { return m_model; } std::string GetModel() const { return m_model; }
......
...@@ -11,8 +11,8 @@ void KepData::Init(const Kepler& kep) ...@@ -11,8 +11,8 @@ void KepData::Init(const Kepler& kep)
m_aol = kep.U; m_aol = kep.U;
m_raan = kep.Omega; m_raan = kep.Omega;
m_period = kep.GetPeriod(); m_period = kep.GetPeriod();
m_hApogee = kep.GetHA(0); m_hApogee = kep.GetHA(nullptr);
m_hPerigee = kep.GetHP(0); m_hPerigee = kep.GetHP(nullptr);
m_rApogee = kep.GetRA(); m_rApogee = kep.GetRA();
m_rPerigee = kep.GetRP(); m_rPerigee = kep.GetRP();
} }
......
#include "LightModel.h" #include "LightModel.h"
#include "XMLFunctions.h"
#include <map>
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
MagData::MagData() MagData::MagData()
: :
m_hasData(false),
m_hasGeomData(false),
m_mag(0),
m_phase(0), m_phase(0),
m_range(0) m_range(0),
m_mag(0),
m_hasData(false),
m_hasGeomData(false)
{ {
} }
...@@ -49,20 +49,20 @@ void MagData::load(const jsonval& parent) ...@@ -49,20 +49,20 @@ void MagData::load(const jsonval& parent)
double MagData::CalcA0g(double stdmag, double stdphase, double stdrange, double sunMag) double MagData::CalcA0g(double stdmag, double stdphase, double stdrange, double sunMag)
{ {
double C = pow(10.0, ((sunMag - stdmag) / 2.5)); const double C = pow(10.0, ((sunMag - stdmag) / 2.5));
double F = 2 / 3.0 * sqr(Pi) * ((Pi - stdphase) * cos(stdphase) + sin(stdphase)) * (1 - stdphase / Pi); const double F = 2 / 3.0 * sqr(Pi) * ((Pi - stdphase) * cos(stdphase) + sin(stdphase)) * (1 - stdphase / Pi);
return C * sqr(stdrange * 1E6) / F; return C * sqr(stdrange * 1E6) / F;
} }
double MagData::CalcRealMag(double A0g, double sunMag, double phase, double range) double MagData::CalcRealMag(double A0g, double sunMag, double phase, double range)
{ {
double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi); const double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi);
return sunMag - 2.5 * log10(F * A0g / sqr(range * 1E6)); return sunMag - 2.5 * log10(F * A0g / sqr(range * 1E6));
} }
void MagData::CalcMag(double phase, double range) void MagData::CalcMag(double phase, double range)
{ {
double sunMag = -26.58; const double sunMag = -26.58;
m_mag = CalcRealMag(CalcA0g(m_stdmag, m_stdphase, m_stdrange, sunMag), sunMag, phase, range); m_mag = CalcRealMag(CalcA0g(m_stdmag, m_stdphase, m_stdrange, sunMag), sunMag, phase, range);
m_phase = phase; m_phase = phase;
m_range = range; m_range = range;
...@@ -70,9 +70,9 @@ void MagData::CalcMag(double phase, double range) ...@@ -70,9 +70,9 @@ void MagData::CalcMag(double phase, double range)
void MagData::CalcGeomMag(double phase, double range) void MagData::CalcGeomMag(double phase, double range)
{ {
double sunMag = -26.58; const double sunMag = -26.58;
double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi); const double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi);
double A0g = m_rcs * 0.15; const double A0g = m_rcs * 0.15;
m_mag = sunMag - 2.5 * log10(F * A0g / sqr(range * 1E6)); m_mag = sunMag - 2.5 * log10(F * A0g / sqr(range * 1E6));
m_phase = phase; m_phase = phase;
m_range = range; m_range = range;
......
#include "PrognozPredict.h" #include "PrognozPredict.h"
#include "Consts.h"
#include "IAstroBase.h" #include "IAstroBase.h"
#include "Kepler.h" #include "Kepler.h"
#include "METEFrame.h" #include "METEFrame.h"
......
#include "PropInfoBase.h" #include "PropInfoBase.h"
#include <utility>
#include "XMLFunctions.h" #include "XMLFunctions.h"
PropInfoBase::PropInfoBase(std::string lightModel, const EarthModel& earthModel, const AtmModel& atmModel, bool sun, bool moon, int type) PropInfoBase::PropInfoBase(std::string lightModel, EarthModel earthModel, AtmModel atmModel, const bool sun, const bool moon, const int type)
: :
m_lightModel(lightModel), m_atmModel(std::move(atmModel)),
m_earthModel(earthModel), m_earthModel(std::move(earthModel)),
m_atmModel(atmModel), m_lightModel(std::move(lightModel)),
m_sun(sun), m_sun(sun),
m_moon(moon), m_moon(moon),
m_type(type) m_type(type)
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
#define PROPINFOBASE_H #define PROPINFOBASE_H
#include <myXML_Document.hpp> #include <myXML_Document.hpp>
#include "DVectors.h"
#include <map> #include <map>
#include "AtmModel.h" #include "AtmModel.h"
#include "EarthModel.h" #include "EarthModel.h"
...@@ -23,7 +21,7 @@ public: ...@@ -23,7 +21,7 @@ public:
PropInfoBase() PropInfoBase()
{ {
}; };
PropInfoBase(std::string lightModel, const EarthModel& earthModel, const AtmModel& atmModel, bool sun, bool moon, int type); PropInfoBase(std::string lightModel, EarthModel earthModel, AtmModel atmModel, bool sun, bool moon, int type);
bool Load(myXML::Contain* parent); bool Load(myXML::Contain* parent);
void load(const jsonval& parent); void load(const jsonval& parent);
......
#include "Propagator.h" #include "Propagator.h"
#include <vector>
#include "Consts.h" #include "Consts.h"
#include "TextFunctions.h" #include "TextFunctions.h"
#include "METEFrame.h" #include "METEFrame.h"
#include "GreenwichFrame.h"
#include "J2000Frame.h" #include "J2000Frame.h"
#include "ECIFrame.h"
#include "KeplPredict.h"
#include "Kepler.h"
#include "TimeFunctions.h" #include "TimeFunctions.h"
#include "DVectors.h" #include "DVectors.h"
#include "PhasePoint.h" #include "PhasePoint.h"
...@@ -16,14 +11,14 @@ ...@@ -16,14 +11,14 @@
Propagator::Propagator() Propagator::Propagator()
: :
m_predictor(0), m_predictor(nullptr),
m_has_orbit(false) m_has_orbit(false)
{ {
} }
Propagator::Propagator(const SInitOrbit& initOrbit, bool variates) Propagator::Propagator(const SInitOrbit& initOrbit, bool variates)
: :
m_predictor(0), m_predictor(nullptr),
m_has_orbit(false) m_has_orbit(false)
{ {
Init(initOrbit.GetPropagatorData(), initOrbit, variates); Init(initOrbit.GetPropagatorData(), initOrbit, variates);
......
...@@ -25,8 +25,8 @@ public: ...@@ -25,8 +25,8 @@ public:
bool SetKeplerPropagation(TimeJD firstPointTime); bool SetKeplerPropagation(TimeJD firstPointTime);
bool Init(const PropInfoBase& propInfo, const SInitOrbit& initOrbit, bool variates = false); bool Init(const PropInfoBase& propInfo, const SInitOrbit& initOrbit, bool variates = false);
bool Init(const SInitOrbit& initOrbit, bool variates = false); bool Init(const SInitOrbit& initOrbit, bool variates = false);
static void InitStPredictor(TrjNum& trj, const SInitOrbit& initOrbit, const PropInfoBase& PropInfoBase); static void InitStPredictor(TrjNum& trj, const SInitOrbit& initOrbit, const PropInfoBase& propInfo);
static void InitStvPredictor(TrjNumVar& trj, const SInitOrbit& initOrbit, const PropInfoBase& PropInfoBase); static void InitStvPredictor(TrjNumVar& trj, const SInitOrbit& initOrbit, const PropInfoBase& propInfo);
static void InitKepPredictor(KeplerTrj& trj, const SInitOrbit& initOrbit); static void InitKepPredictor(KeplerTrj& trj, const SInitOrbit& initOrbit);
static void InitPrognozPredictor(PrognozTrj& trj, const SInitOrbit& initOrbit); static void InitPrognozPredictor(PrognozTrj& trj, const SInitOrbit& initOrbit);
static void InitSGPPredictor(SGPTrj& trj, const SInitOrbit& initOrbit); static void InitSGPPredictor(SGPTrj& trj, const SInitOrbit& initOrbit);
......
#include "SGPTrj.h" #include "SGPTrj.h"
#include "PhasePoint.h" #include "PhasePoint.h"
#include "METEFrame.h" #include "METEFrame.h"
#include "ECIFrame.h"
SGPTrj::SGPTrj() : InitTime(0, 0.0) SGPTrj::SGPTrj() : InitTime(0, 0.0)
{ {
......
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
#include "Consts.h" #include "Consts.h"
#include "BNOAstroBase.h" #include "BNOAstroBase.h"
class SXYZCoordinates class SXYZCoordinates {
{
public: public:
bool Load(myXML::Contain* parent) bool Load(myXML::Contain* parent)
{ {
...@@ -21,13 +20,12 @@ public: ...@@ -21,13 +20,12 @@ public:
double GetY() const { return m_y; } double GetY() const { return m_y; }
double GetZ() const { return m_z; } double GetZ() const { return m_z; }
private: private:
double m_x; double m_x{0};
double m_y; double m_y{0};
double m_z; double m_z{0};
}; };
class SGeoCoordinates class SGeoCoordinates {
{
public: public:
bool Load(myXML::Contain* parent) bool Load(myXML::Contain* parent)
{ {
...@@ -54,9 +52,9 @@ public: ...@@ -54,9 +52,9 @@ public:
std::string GetEllipsoid() const { return m_ellipsoid; } std::string GetEllipsoid() const { return m_ellipsoid; }
private: private:
double m_lat; double m_lat{0};
double m_lon; double m_lon{0};
double m_alt; double m_alt{0};
std::string m_ellipsoid; std::string m_ellipsoid;
}; };
...@@ -83,9 +81,9 @@ void Site::load(const jsonval& parent) ...@@ -83,9 +81,9 @@ void Site::load(const jsonval& parent)
converter.H = sgc.GetAlt(); converter.H = sgc.GetAlt();
converter.GetXYZ(m_coordinates); converter.GetXYZ(m_coordinates);
m_lat_deg = sgc.GetLat()*rad2deg; m_lat_deg = sgc.GetLat() * rad2deg;
m_lon_deg = sgc.GetLon()*rad2deg; m_lon_deg = sgc.GetLon() * rad2deg;
m_alt_m = sgc.GetAlt()*1E6; m_alt_m = sgc.GetAlt() * 1E6;
} }
} }
......
#include "StateVector.h" #include "StateVector.h"
#include <utility>
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include "GreenwichFrame.h" #include "GreenwichFrame.h"
#include "PhasePoint.h" #include "PhasePoint.h"
#include "METEFrame.h" #include "METEFrame.h"
#include "Kepler.h" #include "Kepler.h"
#include "ECIFrame.h" #include "ECIFrame.h"
#include "BNOAstroBase.h"
#include "StAlgorithms.h"
#define BASEFRAME J2000Frame() #define BASEFRAME J2000Frame()
...@@ -49,12 +48,12 @@ private: ...@@ -49,12 +48,12 @@ private:
SInitOrbit::SInitOrbit() SInitOrbit::SInitOrbit()
: :
m_coordinates(0, 0, 0),
m_velocities(0, 0, 0),
m_date(0, 0), m_date(0, 0),
m_ballisticCoefficient(0),
m_solarPresureCoefficient(0),
//m_srcType (ORBSRCTYPE_UNK), //m_srcType (ORBSRCTYPE_UNK),
m_coordinates(0, 0, 0), m_ballisticCoefficient(0),
m_velocities(0, 0, 0) m_solarPresureCoefficient(0)
{ {
} }
...@@ -62,17 +61,26 @@ SInitOrbit::~SInitOrbit() ...@@ -62,17 +61,26 @@ SInitOrbit::~SInitOrbit()
{ {
} }
SInitOrbit::SInitOrbit(Vect6 pos, const TimeJD& date, double ballc, double solarpc, double periodChangePerRev, const PropInfoBase& propagator, const CovMtx& covmtx, int rev, TOrbitId baseid) SInitOrbit::SInitOrbit(
const Vect6 pos,
const TimeJD& date,
const double ballc,
const double solarpc,
const double periodChangePerRev,
PropInfoBase propagator,
CovMtx covmtx,
const int rev,
TOrbitId baseid)
: :
m_date(date), m_date(date),
m_propInfo(propagator),
m_ballisticCoefficient(ballc), m_ballisticCoefficient(ballc),
m_solarPresureCoefficient(solarpc), m_solarPresureCoefficient(solarpc),
m_periodChangePerRev(periodChangePerRev), m_periodChangePerRev(periodChangePerRev),
m_covmtx(std::move(covmtx)),
//m_srcType (ORBSRCTYPE_OPT), //m_srcType (ORBSRCTYPE_OPT),
m_covmtx(covmtx),
m_rev(rev), m_rev(rev),
m_baseid(baseid) m_baseid(std::move(baseid)),
m_propInfo(std::move(propagator)), rev_(rev)
{ {
CreateFromPos(pos, "J2000"); CreateFromPos(pos, "J2000");
} }
...@@ -82,7 +90,7 @@ bool SInitOrbit::CheckFrame(const std::string& frame) ...@@ -82,7 +90,7 @@ bool SInitOrbit::CheckFrame(const std::string& frame)
return !(frame != "ECI" && frame != "J2000" && frame != "METE" && frame != "GCS"); return !(frame != "ECI" && frame != "J2000" && frame != "METE" && frame != "GCS");
} }
int SInitOrbit::ParseSrcType(TOrbitId id) int SInitOrbit::ParseSrcType(const TOrbitId& id)
{ {
int ret; int ret;
std::string sep("::"); std::string sep("::");
......
...@@ -4,12 +4,10 @@ ...@@ -4,12 +4,10 @@
#include <myXML_Document.hpp> #include <myXML_Document.hpp>
#include "DVectors.h" #include "DVectors.h"
#include "TM.h" #include "TM.h"
#include "IFrames.h"
#include "PhasePoint.h" #include "PhasePoint.h"
#include "KepData.h" #include "KepData.h"
#include "TleData.h" #include "TleData.h"
#include <map> #include <map>
#include "Matrix.h"
#include "PropInfoBase.h" #include "PropInfoBase.h"
#include "CovMtx.h" #include "CovMtx.h"
#include "uncert.h" #include "uncert.h"
...@@ -27,11 +25,11 @@ enum OrbitTypes ...@@ -27,11 +25,11 @@ enum OrbitTypes
class SInitOrbit class SInitOrbit
{ {
public: public:
SInitOrbit(Vect6 pos, const TimeJD& date, double ballc, double solarpc, double periodChangePerRev, const PropInfoBase& propagator, const CovMtx& covmtx, int rev = 0, TOrbitId baseid = ""); SInitOrbit(Vect6 pos, const TimeJD& date, double ballc, double solarpc, double periodChangePerRev, PropInfoBase propagator, CovMtx covmtx, int rev = 0, TOrbitId baseid = "");
SInitOrbit(); SInitOrbit();
virtual ~SInitOrbit(); virtual ~SInitOrbit();
bool Load(myXML::Contain* parent); bool Load(myXML::Contain* con);
void load(const jsonval& parent); void load(const jsonval& parent);
bool LoadNewStyle(myXML::Contain* con); bool LoadNewStyle(myXML::Contain* con);
Vect3 GetCoortinates() const { return m_coordinates; } Vect3 GetCoortinates() const { return m_coordinates; }
...@@ -84,7 +82,7 @@ public: ...@@ -84,7 +82,7 @@ public:
void SetIntegratorCfg(const IntegratorCfg& icfg) { m_integratorCfg = icfg; } void SetIntegratorCfg(const IntegratorCfg& icfg) { m_integratorCfg = icfg; }
const IntegratorCfg& GetIntegratorCfg() const { return m_integratorCfg; } const IntegratorCfg& GetIntegratorCfg() const { return m_integratorCfg; }
protected: protected:
static int ParseSrcType(TOrbitId id); static int ParseSrcType(const TOrbitId& id);
void CreateFromKepler(const KepData& kd, const std::string& frame); void CreateFromKepler(const KepData& kd, const std::string& frame);
void CreateFromPos(Vect6 dst, const std::string& frame); void CreateFromPos(Vect6 dst, const std::string& frame);
static bool CheckFrame(const std::string& frame); static bool CheckFrame(const std::string& frame);
...@@ -105,6 +103,7 @@ protected: ...@@ -105,6 +103,7 @@ protected:
TOrbitId m_baseid; TOrbitId m_baseid;
PropInfoBase m_propInfo; PropInfoBase m_propInfo;
IntegratorCfg m_integratorCfg; IntegratorCfg m_integratorCfg;
int rev_;
}; };
typedef std::vector<SInitOrbit> SInitOrbits; typedef std::vector<SInitOrbit> SInitOrbits;
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define __TASKINIT_H_ #define __TASKINIT_H_
#include <string> #include <string>
#include <clocale>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
#include "BNOAstroBase.h" #include "BNOAstroBase.h"
...@@ -11,7 +10,7 @@ ...@@ -11,7 +10,7 @@
static bool TestBreak(const std::string& tFile, bool lastCall = false) static bool TestBreak(const std::string& tFile, bool lastCall = false)
{ {
if (!tFile.empty()) { if (!tFile.empty()) {
std::ifstream ifile(tFile.c_str()); const std::ifstream ifile(tFile.c_str());
if (ifile) { if (ifile) {
if (lastCall) { if (lastCall) {
remove(tFile.c_str()); remove(tFile.c_str());
...@@ -84,14 +83,14 @@ static void InitData(const std::string& file, BNOAstroBase& ab, myXML::Document& ...@@ -84,14 +83,14 @@ static void InitData(const std::string& file, BNOAstroBase& ab, myXML::Document&
clock_t begin, end; clock_t begin, end;
double diffclock(clock_t clock1, clock_t clock2) inline double diffclock(clock_t clock1, clock_t clock2)
{ {
double diffticks = clock1 - clock2; double diffticks = clock1 - clock2;
double diffms = (diffticks) / CLOCKS_PER_SEC; double diffms = (diffticks) / CLOCKS_PER_SEC;
return diffms; return diffms;
} }
void Tic(bool timing, const std::string& message) inline void Tic(bool timing, const std::string& message)
{ {
if (timing && !message.empty()) { if (timing && !message.empty()) {
end = clock(); end = clock();
...@@ -104,7 +103,7 @@ void Tic(bool timing, const std::string& message) ...@@ -104,7 +103,7 @@ void Tic(bool timing, const std::string& message)
} }
} }
void Tic(bool timing) inline void Tic(bool timing)
{ {
Tic(timing, ""); Tic(timing, "");
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <string> #include <string>
#include <map> #include <map>
#include <list> #include <list>
#include <stdio.h> #include "stdio.h"
#include <iomanip> #include <iomanip>
#include "Converter.h" #include "Converter.h"
#include "MException.h" #include "MException.h"
...@@ -57,7 +57,7 @@ static std::string ToStr(double value, int precision) ...@@ -57,7 +57,7 @@ static std::string ToStr(double value, int precision)
static std::string trim_right(const std::string& s, const std::string& t = SPACES) static std::string trim_right(const std::string& s, const std::string& t = SPACES)
{ {
std::string d(s); std::string d(s);
std::string::size_type i(d.find_last_not_of(t)); const std::string::size_type i(d.find_last_not_of(t));
if (i == std::string::npos) { if (i == std::string::npos) {
return ""; return "";
} }
...@@ -127,9 +127,9 @@ static std::string trim(const std::string& s, const std::string& t = SPACES) ...@@ -127,9 +127,9 @@ static std::string trim(const std::string& s, const std::string& t = SPACES)
template <typename ContainerT> template <typename ContainerT>
void splitstrf(const std::string& str, ContainerT& tokens, const std::string& delimiters = " ", const bool trimEmpty = false) void splitstrf(const std::string& str, ContainerT& tokens, const std::string& delimiters = " ", const bool trimEmpty = false)
{ {
std::string::size_type pos, lastPos = 0; std::string::size_type lastPos = 0;
while (true) { while (true) {
pos = str.find_first_of(delimiters, lastPos); std::string::size_type pos = str.find_first_of(delimiters, lastPos);
if (pos == std::string::npos) { if (pos == std::string::npos) {
pos = str.length(); pos = str.length();
...@@ -181,9 +181,9 @@ static bool ReadFile(const std::string& path, std::string& str) ...@@ -181,9 +181,9 @@ static bool ReadFile(const std::string& path, std::string& str)
return false; return false;
} }
fseek(fp, 0, SEEK_END); //go to end fseek(fp, 0, SEEK_END); //go to end
long len = ftell(fp); //get position at end (length) const long len = ftell(fp); //get position at end (length)
fseek(fp, 0, SEEK_SET); //go to beg. fseek(fp, 0, SEEK_SET); //go to beg.
char* buf = new char[len + 1]; //malloc buffer auto* buf = new char[len + 1]; //malloc buffer
buf[len] = 0; buf[len] = 0;
size_t res = fread(buf, len, 1, fp); //read into buffer size_t res = fread(buf, len, 1, fp); //read into buffer
fclose(fp); fclose(fp);
...@@ -249,7 +249,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int ...@@ -249,7 +249,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int
} }
if (!Converter::ToNumber(part, ret)) { if (!Converter::ToNumber(part, ret)) {
std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-"); const std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-");
throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part; throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part;
} }
...@@ -258,7 +258,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int ...@@ -258,7 +258,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int
checkBounds(ret, min, max, strict); checkBounds(ret, min, max, strict);
} }
catch (Exp& e) { catch (Exp& e) {
std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-"); const std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-");
throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part << ". " << e.what(); throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part << ". " << e.what();
} }
} }
...@@ -275,7 +275,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& ret, ...@@ -275,7 +275,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& ret,
} }
if (!Converter::ToNumber(part, ret)) { if (!Converter::ToNumber(part, ret)) {
std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-"); const std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-");
throw (Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part); throw (Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part);
} }
...@@ -284,7 +284,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& ret, ...@@ -284,7 +284,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& ret,
checkBounds(ret, (double*)min, (double*)max, strict); checkBounds(ret, (double*)min, (double*)max, strict);
} }
catch (Exp& e) { catch (Exp& e) {
std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-"); const std::string errstr = pos2 ? (ToStr(pos1) + ":" + ToStr(pos2)) : (ToStr(pos1) + ":-");
throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part << ". " << e.what(); throw Exp() << "bad substr format in line [" + data + "] at position" << errstr << " " << part << ". " << e.what();
} }
} }
...@@ -302,12 +302,12 @@ static void parseStr(const std::string& data, int pos1, int pos2, double& ret, d ...@@ -302,12 +302,12 @@ static void parseStr(const std::string& data, int pos1, int pos2, double& ret, d
static void parseStr(const std::string& data, int pos1, int pos2, int& ret) static void parseStr(const std::string& data, int pos1, int pos2, int& ret)
{ {
parseStrA(data, pos1, pos2, ret, 0, 0, false); parseStrA(data, pos1, pos2, ret, nullptr, nullptr, false);
} }
static void parseStr(const std::string& data, int pos1, int pos2, double& ret) static void parseStr(const std::string& data, int pos1, int pos2, double& ret)
{ {
parseStrA(data, pos1, pos2, ret, 0, 0, false); parseStrA(data, pos1, pos2, ret, nullptr, nullptr, false);
} }
static void parseStr(const std::string& data, int& ret, int min, int max, bool strict = false) static void parseStr(const std::string& data, int& ret, int min, int max, bool strict = false)
...@@ -322,12 +322,12 @@ static void parseStr(const std::string& data, double& ret, double min, double ma ...@@ -322,12 +322,12 @@ static void parseStr(const std::string& data, double& ret, double min, double ma
static void parseStr(const std::string& data, int& ret) static void parseStr(const std::string& data, int& ret)
{ {
parseStrA(data, -1, -1, ret, 0, 0, false); parseStrA(data, -1, -1, ret, nullptr, nullptr, false);
} }
static void parseStr(const std::string& data, double& ret) static void parseStr(const std::string& data, double& ret)
{ {
parseStrA(data, -1, -1, ret, 0, 0, false); parseStrA(data, -1, -1, ret, nullptr, nullptr, false);
} }
template <typename T, typename T2> template <typename T, typename T2>
......
...@@ -65,8 +65,7 @@ static bool StrToDate(const std::string& date, TimeGD& gd) ...@@ -65,8 +65,7 @@ static bool StrToDate(const std::string& date, TimeGD& gd)
if (part1.size() > 8) { if (part1.size() > 8) {
const size_t pos = part1.find_first_of('.'); const size_t pos = part1.find_first_of('.');
if (pos != std::string::npos) { if (pos != std::string::npos) {
std::string fracStr = part1.substr(pos); ret = ret && Converter::ToNumber(part1.substr(pos), gd.Fraction);
ret = ret && Converter::ToNumber(fracStr, gd.Fraction);
} }
} }
} }
...@@ -106,7 +105,7 @@ static std::string DateToStr(int year, int month, int day, int hour, int minute, ...@@ -106,7 +105,7 @@ static std::string DateToStr(int year, int month, int day, int hour, int minute,
int d = hour; int d = hour;
int m = minute; int m = minute;
int s = second; int s = second;
int k2 = (int)pow(10.0, prec); const auto k2 = (int)pow(10.0, prec);
int msec = Round(fraction * k2); int msec = Round(fraction * k2);
if (msec >= k2) { if (msec >= k2) {
...@@ -219,7 +218,7 @@ static TimeGD ShiftDateX(const TimeGD& date, double seconds) ...@@ -219,7 +218,7 @@ static TimeGD ShiftDateX(const TimeGD& date, double seconds)
convertTimeGJ(date.Year, date.Month, date.Day, date.Hour, date.Min, date.Sec, date.Fraction, jd, jf); convertTimeGJ(date.Year, date.Month, date.Day, date.Hour, date.Min, date.Sec, date.Fraction, jd, jf);
int nd = (int)(seconds / 86400.0); auto nd = (int)(seconds / 86400.0);
jd += nd; jd += nd;
jf += (seconds / 86400.0 - nd); jf += (seconds / 86400.0 - nd);
...@@ -283,9 +282,9 @@ static void DegToDMS(double deg, int& rd, int& rm, double& rs) ...@@ -283,9 +282,9 @@ static void DegToDMS(double deg, int& rd, int& rm, double& rs)
deg = fabs(deg); deg = fabs(deg);
} }
int h = (int)deg; auto h = (int)deg;
int m = (int)((deg - h) * 60); auto m = (int)((deg - h) * 60);
double s = ((deg - h) * 60 - m) * 60.0; const double s = ((deg - h) * 60 - m) * 60.0;
rd = h; rd = h;
rm = m; rm = m;
...@@ -299,9 +298,9 @@ static void DegToHMS(double deg, int& rd, int& rm, double& rs) ...@@ -299,9 +298,9 @@ static void DegToHMS(double deg, int& rd, int& rm, double& rs)
deg = deg / 360.0 * 24; deg = deg / 360.0 * 24;
int h = (int)deg; auto h = (int)deg;
int m = (int)((deg - h) * 60); auto m = (int)((deg - h) * 60);
double s = ((deg - h) * 60 - m) * 60.0; const double s = ((deg - h) * 60 - m) * 60.0;
rd = h; rd = h;
rm = m; rm = m;
...@@ -349,11 +348,8 @@ static void JToSystemTime(double J, int& Cyear, int& Cmonth, int& Cday, int& Cho ...@@ -349,11 +348,8 @@ static void JToSystemTime(double J, int& Cyear, int& Cmonth, int& Cday, int& Cho
dd = day + J - jd + 0.5; dd = day + J - jd + 0.5;
int cyear = year;
if (BC) { if (BC) {
year = -year + 1; year = -year + 1;
cyear = -year;
Cyear = year; Cyear = year;
} }
else else
......
#include "XMLFunctions.h" #include "XMLFunctions.h"
#include <iomanip>
void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>& items) void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>& items)
{ {
...@@ -14,8 +13,8 @@ void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>& ...@@ -14,8 +13,8 @@ void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>&
void GetChildren(const std::map<std::string, myXML::Contain*>& parent, std::map<std::string, myXML::Contain*>& items) void GetChildren(const std::map<std::string, myXML::Contain*>& parent, std::map<std::string, myXML::Contain*>& items)
{ {
for (std::map<std::string, myXML::Contain*>::const_iterator it = parent.begin(); it != parent.end(); ++it) { for (const auto& it : parent) {
items[it->first] = it->second; items[it.first] = it.second;
} }
} }
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>& items); void GetChildren(myXML::Contain* parent, std::map<std::string, myXML::Contain*>& items);
void GetChildren(const std::map<std::string, myXML::Contain*>& parent, std::map<std::string, myXML::Contain*>& items); void GetChildren(const std::map<std::string, myXML::Contain*>& parent, std::map<std::string, myXML::Contain*>& items);
void GenerateEmergeXML(const std::string& msg, const std::string& outputfile); void GenerateEmergeXML(const std::string& msg, const std::string& outputfile);
bool FindFirstContainer(myXML::Contain* parent, const std::string& path, myXML::Contain*& ret); bool FindFirstContainer(myXML::Contain* parent, const std::string& name, myXML::Contain*& ret);
bool FindXMLContainer(const std::map<std::string, myXML::Contain*>& items, const std::string& name, myXML::Contain*& result); bool FindXMLContainer(const std::map<std::string, myXML::Contain*>& items, const std::string& name, myXML::Contain*& result);
bool FindXMLContainer(myXML::Contain* parent, const std::string& path, myXML::Contain*& result); bool FindXMLContainer(myXML::Contain* parent, const std::string& name, myXML::Contain*& result);
template <typename T> template <typename T>
void ReadXML(T storage, TimeGD& result); void ReadXML(T storage, TimeGD& result);
...@@ -187,7 +187,7 @@ void LoadXMLUnitVector(T1 storage, std::string name, std::string subname, T2& re ...@@ -187,7 +187,7 @@ void LoadXMLUnitVector(T1 storage, std::string name, std::string subname, T2& re
} }
template <typename T1, typename T2> template <typename T1, typename T2>
void LoadXMLUnitVector(T1 storage, std::string subname, T2& result, bool exist, bool* loaded = 0) void LoadXMLUnitVector(T1 storage, std::string subname, T2& result, bool exist, bool* loaded = nullptr)
{ {
if (loaded) { if (loaded) {
*loaded = false; *loaded = false;
...@@ -200,7 +200,7 @@ void LoadXMLUnitVector(T1 storage, std::string subname, T2& result, bool exist, ...@@ -200,7 +200,7 @@ void LoadXMLUnitVector(T1 storage, std::string subname, T2& result, bool exist,
} }
template <typename T1, typename T2> template <typename T1, typename T2>
void LoadXMLUnitVectorSingle(T1 storage, std::string name, std::string subname, T2& result, bool exist, bool* loaded = 0) void LoadXMLUnitVectorSingle(T1 storage, std::string name, std::string subname, T2& result, bool exist, bool* loaded = nullptr)
{ {
if (loaded) { if (loaded) {
*loaded = false; *loaded = false;
...@@ -255,37 +255,37 @@ void LoadXMLMap(T1 storage, std::string subname, std::map<T2, T3>& result, bool ...@@ -255,37 +255,37 @@ void LoadXMLMap(T1 storage, std::string subname, std::map<T2, T3>& result, bool
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, double& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, double& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, int& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, int& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, bool& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, bool& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, std::string& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, std::string& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, TimeGD& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, TimeGD& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
template <typename T> template <typename T>
void LoadXML(T storage, std::string name, TimeJD& result, bool exist = true, bool* loaded = 0) void LoadXML(T storage, std::string name, TimeJD& result, bool exist = true, bool* loaded = nullptr)
{ {
TimeGD date; TimeGD date;
LoadXMLUnit(storage, name, date, exist, loaded); LoadXMLUnit(storage, name, date, exist, loaded);
...@@ -293,7 +293,7 @@ void LoadXML(T storage, std::string name, TimeJD& result, bool exist = true, boo ...@@ -293,7 +293,7 @@ void LoadXML(T storage, std::string name, TimeJD& result, bool exist = true, boo
} }
template <typename T1, typename T2> template <typename T1, typename T2>
void LoadXML(T1 storage, std::string name, T2& result, bool exist = true, bool* loaded = 0) void LoadXML(T1 storage, std::string name, T2& result, bool exist = true, bool* loaded = nullptr)
{ {
LoadXMLUnit(storage, name, result, exist, loaded); LoadXMLUnit(storage, name, result, exist, loaded);
} }
......
#include "exec.h" #include "exec.h"
#include <stdio.h> #include <cstdio>
std::string exec(const char* cmd) std::string exec(const char* cmd)
{ {
...@@ -13,7 +13,7 @@ std::string exec(const char* cmd) ...@@ -13,7 +13,7 @@ std::string exec(const char* cmd)
char buffer[128]; char buffer[128];
std::string result; std::string result;
while (!feof(pipe)) { while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL) if (fgets(buffer, 128, pipe) != nullptr)
result += buffer; result += buffer;
} }
......
#include "gfcsRotator.h" #include "gfcsRotator.h"
#include "BNOAstroBase.h" #include "BNOAstroBase.h"
#include "GreenwichFrame.h" #include "GreenwichFrame.h"
#include "LocalJ2000Frame.h"
#include "NZEFrame.h" #include "NZEFrame.h"
GFCSRotator::GFCSRotator(TimeJD baseDate) GFCSRotator::GFCSRotator(const TimeJD& baseDate)
{ {
Init(baseDate); Init(baseDate);
} }
void GFCSRotator::Init(TimeJD baseDate) void GFCSRotator::Init(const TimeJD& baseDate)
{ {
m_baseDate = baseDate; m_baseDate = baseDate;
IAstroBase* ab = GetAstroBase(); IAstroBase* ab = GetAstroBase();
ab->MtxJ20002GFCS(baseDate, BJ2000toGFCS); ab->MtxJ20002GFCS(baseDate, BJ2000toGFCS);
} }
void GFCSRotator::Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const void GFCSRotator::Rotate(const TimeJD& date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const
{ {
IAstroBase* ab = GetAstroBase(); IAstroBase* ab = GetAstroBase();
double w = ab->GetEarthRotation(); double w = ab->GetEarthRotation();
...@@ -36,7 +35,7 @@ void GFCSRotator::Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ ...@@ -36,7 +35,7 @@ void GFCSRotator::Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ
CJ2000toGFCS.Transp(CGFCStoJ2000); CJ2000toGFCS.Transp(CGFCStoJ2000);
} }
void GFCSRotator::GCSToJ2000(TimeJD date, const Vect6& gcs, Vect6& j2000) const void GFCSRotator::GCSToJ2000(const TimeJD& date, const Vect6& gcs, Vect6& j2000) const
{ {
TransMtx CJ2000toGFCS, CGFCStoJ2000; TransMtx CJ2000toGFCS, CGFCStoJ2000;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000); Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
...@@ -55,7 +54,7 @@ void GFCSRotator::GCSToJ2000(TimeJD date, const Vect6& gcs, Vect6& j2000) const ...@@ -55,7 +54,7 @@ void GFCSRotator::GCSToJ2000(TimeJD date, const Vect6& gcs, Vect6& j2000) const
j2000 = Vect6(RGr, VGr); j2000 = Vect6(RGr, VGr);
} }
void GFCSRotator::J2000ToGCS(TimeJD date, const Vect6& j2000, Vect6& gcs) const void GFCSRotator::J2000ToGCS(const TimeJD& date, const Vect6& j2000, Vect6& gcs) const
{ {
//new short style but slower //new short style but slower
// FrameConverter6D j2000ToGcs; // FrameConverter6D j2000ToGcs;
...@@ -98,7 +97,7 @@ void GFCSRotator::J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const ...@@ -98,7 +97,7 @@ void GFCSRotator::J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const
gcs.Init(fr, pGcs, j2000.T); gcs.Init(fr, pGcs, j2000.T);
} }
void GFCSRotator::GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000ToGcs) const void GFCSRotator::GetJ2000ToGcs6dConverter(const TimeJD& date, FrameConverter6D& j2000ToGcs) const
{ {
TransMtx CJ2000toGFCS, CGFCStoJ2000; TransMtx CJ2000toGFCS, CGFCStoJ2000;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000); Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
...@@ -113,7 +112,7 @@ void GFCSRotator::GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000T ...@@ -113,7 +112,7 @@ void GFCSRotator::GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000T
j2000ToGcs.Converter3D.Rotation.mul(w, j2000ToGcs.VRotation); j2000ToGcs.Converter3D.Rotation.mul(w, j2000ToGcs.VRotation);
} }
void GFCSRotator::GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ2000) const void GFCSRotator::GetGcsToJ20006dConverter(const TimeJD& date, FrameConverter6D& gcsToJ2000) const
{ {
TransMtx CJ2000toGFCS, CGFCStoJ2000; TransMtx CJ2000toGFCS, CGFCStoJ2000;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000); Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
...@@ -128,7 +127,7 @@ void GFCSRotator::GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ ...@@ -128,7 +127,7 @@ void GFCSRotator::GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ
gcsToJ2000.Converter3D.Rotation.mul(w, gcsToJ2000.VRotation); gcsToJ2000.Converter3D.Rotation.mul(w, gcsToJ2000.VRotation);
} }
void GFCSRotator::GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& J2000toNze) const void GFCSRotator::GetJ2000ToNze6dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toNze) const
{ {
NZEFrame nzeFrame; NZEFrame nzeFrame;
nzeFrame.Init(siteGcsPos); nzeFrame.Init(siteGcsPos);
...@@ -144,7 +143,7 @@ void GFCSRotator::GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameC ...@@ -144,7 +143,7 @@ void GFCSRotator::GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameC
J2000toNze.Invert(); J2000toNze.Invert();
} }
void GFCSRotator::GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const void GFCSRotator::GetJ2000ToLocalJ20006dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const
{ {
TransMtx CJ2000toGFCS, CGFCStoJ2000; TransMtx CJ2000toGFCS, CGFCStoJ2000;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000); Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
...@@ -164,14 +163,14 @@ void GFCSRotator::GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos, ...@@ -164,14 +163,14 @@ void GFCSRotator::GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos,
J2000toLocalJ2000.Invert(); J2000toLocalJ2000.Invert();
} }
void GFCSRotator::J2000ToNze(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) const void GFCSRotator::J2000ToNze(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) const
{ {
FrameConverter6D J2000toNze; FrameConverter6D J2000toNze;
GetJ2000ToNze6dConverter(date, siteGcsPos, J2000toNze); GetJ2000ToNze6dConverter(date, siteGcsPos, J2000toNze);
J2000toNze.Convert(j2000, nze); J2000toNze.Convert(j2000, nze);
} }
void GFCSRotator::J2000ToLocalJ2000(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const void GFCSRotator::J2000ToLocalJ2000(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const
{ {
FrameConverter6D J2000toLocalJ2000; FrameConverter6D J2000toLocalJ2000;
GetJ2000ToLocalJ20006dConverter(date, siteGcsPos, J2000toLocalJ2000); GetJ2000ToLocalJ20006dConverter(date, siteGcsPos, J2000toLocalJ2000);
......
...@@ -10,20 +10,20 @@ public: ...@@ -10,20 +10,20 @@ public:
GFCSRotator() GFCSRotator()
{ {
}; };
GFCSRotator(TimeJD baseDate); GFCSRotator(const TimeJD& baseDate);
void Init(TimeJD baseDate); void Init(const TimeJD& baseDate);
void Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const; void Rotate(const TimeJD& date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const;
void J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const; void J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const;
void J2000ToGCS(TimeJD date, const Vect6& j2000, Vect6& gcs) const; void J2000ToGCS(const TimeJD& date, const Vect6& j2000, Vect6& gcs) const;
void J2000ToLocalJ2000(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const; void J2000ToLocalJ2000(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const;
void J2000ToNze(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) const; void J2000ToNze(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) const;
void GCSToJ2000(const PhasePoint6D& gcs, PhasePoint6D& j2000) const; void GCSToJ2000(const PhasePoint6D& gcs, PhasePoint6D& j2000) const;
void GCSToJ2000(TimeJD date, const Vect6& gcs, Vect6& j2000) const; void GCSToJ2000(const TimeJD& date, const Vect6& gcs, Vect6& j2000) const;
private: private:
void GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ2000) const; void GetGcsToJ20006dConverter(const TimeJD& date, FrameConverter6D& gcsToJ2000) const;
void GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000ToGcs) const; void GetJ2000ToGcs6dConverter(const TimeJD& date, FrameConverter6D& j2000ToGcs) const;
void GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& gcsToJ2000) const; void GetJ2000ToNze6dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toNze) const;
void GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const; void GetJ2000ToLocalJ20006dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const;
TransMtx BJ2000toGFCS; TransMtx BJ2000toGFCS;
TimeJD m_baseDate; TimeJD m_baseDate;
}; };
#include "globals.h" #include "globals.h"
#include <cmath> #include <cmath>
#include "Consts.h"
void Topo(double el, double az, double ksi, double teta, double dzita, double& rel, double& raz) void Topo(double el, double az, double ksi, double teta, double dzita, double& rel, double& raz)
{ {
...@@ -50,7 +49,7 @@ void Topo2(double lat, double lon, double R, double el, double az, double& teta, ...@@ -50,7 +49,7 @@ void Topo2(double lat, double lon, double R, double el, double az, double& teta,
y1 = R * cosb * sin(l); y1 = R * cosb * sin(l);
z1 = R * sin(b); z1 = R * sin(b);
double a11, a12, a13, a21, a22, a23, a31, a32, a33; double a21, a22, a23, a31, a32, a33;
// a11 = cosfi*cosla; // a11 = cosfi*cosla;
a21 = -sinla; a21 = -sinla;
......
...@@ -33,8 +33,8 @@ void OrbBlocksStore::init( ...@@ -33,8 +33,8 @@ void OrbBlocksStore::init(
init_min_dist(sordet_orbits, nbeg, nend, min_dist_forced); init_min_dist(sordet_orbits, nbeg, nend, min_dist_forced);
if (interpolate) { if (interpolate) {
for (OrbBlocks::iterator it = m_blocks.begin(); it != m_blocks.end(); ++it) { for (auto& m_block : m_blocks) {
it->interpolate(it->get_beg(), it->get_end()); m_block.interpolate(m_block.get_beg(), m_block.get_end());
} }
} }
} }
...@@ -190,7 +190,7 @@ public: ...@@ -190,7 +190,7 @@ public:
double calc(double time) const double calc(double time) const
{ {
TimeJD date = ShiftDate(m_base, time * 86400); const TimeJD date = ShiftDate(m_base, time * 86400);
const Vect6 p1 = m_ip1.get_pos(date); const Vect6 p1 = m_ip1.get_pos(date);
const Vect6 p2 = m_ip2.get_pos(date); const Vect6 p2 = m_ip2.get_pos(date);
...@@ -209,8 +209,8 @@ private: ...@@ -209,8 +209,8 @@ private:
void OrbBlocksStore::calc_min_dist(const SInitOrbit& orb1, const SInitOrbit& orb2, const TimeJD& beg, const TimeJD& end, TimeJD& result_jd, double& result_dist) const void OrbBlocksStore::calc_min_dist(const SInitOrbit& orb1, const SInitOrbit& orb2, const TimeJD& beg, const TimeJD& end, TimeJD& result_jd, double& result_dist) const
{ {
XInterpolator ip1(orb1, beg, end); const XInterpolator ip1(orb1, beg, end);
XInterpolator ip2(orb2, beg, end); const XInterpolator ip2(orb2, beg, end);
MinDistEvaluator eval(ip1, ip2, beg); MinDistEvaluator eval(ip1, ip2, beg);
const double step = (int)(std::min(orb1.GetKeplerData().GetPeriod(), orb2.GetKeplerData().GetPeriod()) * 1000 / 20); const double step = (int)(std::min(orb1.GetKeplerData().GetPeriod(), orb2.GetKeplerData().GetPeriod()) * 1000 / 20);
......
...@@ -17,9 +17,9 @@ std::vector<TimeJD> generate_dates(const TimeJD& sdate, const TimeJD& edate, dou ...@@ -17,9 +17,9 @@ std::vector<TimeJD> generate_dates(const TimeJD& sdate, const TimeJD& edate, dou
// return result; // return result;
//} //}
int n = (int)(DaysInterval(sdate, edate) * 86400 / step_sec); const int n = (int)(DaysInterval(sdate, edate) * 86400 / step_sec);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
result.push_back(ShiftDateX(sdate, step_sec * (i + 1))); result.emplace_back(ShiftDateX(sdate, step_sec * (i + 1)));
} }
if (result.back() != edate) { if (result.back() != edate) {
...@@ -52,14 +52,14 @@ template <typename T> ...@@ -52,14 +52,14 @@ template <typename T>
void propagate_dir_prop(Propagator& prop, const std::vector<TimeJD>& dates, int dir, std::vector<T>& result) void propagate_dir_prop(Propagator& prop, const std::vector<TimeJD>& dates, int dir, std::vector<T>& result)
{ {
if (dir > 0) { if (dir > 0) {
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); it++) { for (const auto& date : dates) {
T item; T item;
propagate_date(prop, *it, item); propagate_date(prop, date, item);
result.push_back(item); result.push_back(item);
} }
} }
else if (dir < 0) { else if (dir < 0) {
for (std::vector<TimeJD>::const_reverse_iterator it = dates.rbegin(); it != dates.rend(); it++) { for (auto it = dates.rbegin(); it != dates.rend(); ++it) {
T item; T item;
propagate_date(prop, *it, item); propagate_date(prop, *it, item);
result.push_back(item); result.push_back(item);
...@@ -81,12 +81,12 @@ void propagate_dir(const SInitOrbit& orbit, const std::vector<TimeJD>& dates, in ...@@ -81,12 +81,12 @@ void propagate_dir(const SInitOrbit& orbit, const std::vector<TimeJD>& dates, in
void split_dates(const std::vector<TimeJD>& dates, const TimeJD& date, std::vector<TimeJD>& dates_left, std::vector<TimeJD>& dates_right) void split_dates(const std::vector<TimeJD>& dates, const TimeJD& date, std::vector<TimeJD>& dates_left, std::vector<TimeJD>& dates_right)
{ {
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); ++it) { for (const auto& it : dates) {
if (*it < date) { if (it < date) {
dates_left.push_back(*it); dates_left.push_back(it);
} }
else { else {
dates_right.push_back(*it); dates_right.push_back(it);
} }
} }
} }
......
...@@ -17,7 +17,7 @@ public: ...@@ -17,7 +17,7 @@ public:
{ {
} }
virtual const TimeJD& GetTime() const { return TimeJD(); }; virtual const TimeJD& GetTime() const { return TimeJD(); };
virtual IPredict* GetPredictor() { return 0; } virtual IPredict* GetPredictor() { return nullptr; }
private: private:
const OrbBlocksStore& m_orbit_processor; const OrbBlocksStore& m_orbit_processor;
}; };
...@@ -16,7 +16,7 @@ public: ...@@ -16,7 +16,7 @@ public:
{ {
} }
virtual const TimeJD& GetTime() const { return TimeJD(); } virtual const TimeJD& GetTime() const { return TimeJD(); }
virtual IPredict* GetPredictor() { return 0; } virtual IPredict* GetPredictor() { return nullptr; }
private: private:
const XInterpolator& m_itp; const XInterpolator& m_itp;
}; };
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
template <typename T> template <typename T>
double golden_section_search(const T& f, double a, double b, double tol) double golden_section_search(const T& f, double a, double b, double tol)
{ {
double invphi = (std::sqrt(5.0) - 1) / 2.0; const double invphi = (std::sqrt(5.0) - 1) / 2.0;
double invphi2 = (3 - std::sqrt(5.0)) / 2.0; const double invphi2 = (3 - std::sqrt(5.0)) / 2.0;
a = std::min(a, b); a = std::min(a, b);
b = std::max(a, b); b = std::max(a, b);
...@@ -18,7 +18,7 @@ double golden_section_search(const T& f, double a, double b, double tol) ...@@ -18,7 +18,7 @@ double golden_section_search(const T& f, double a, double b, double tol)
return (a + b) / 2.0; return (a + b) / 2.0;
} }
int n = (int)ceil(std::log(tol / h) / std::log(invphi)); const int n = (int)ceil(std::log(tol / h) / std::log(invphi));
double c = a + invphi2 * h; double c = a + invphi2 * h;
double d = a + invphi * h; double d = a + invphi * h;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment