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

refactor

parent 4911bf48
......@@ -229,7 +229,7 @@ bool OptOrbit::Build(Vect6& res)
bool ret = false;
int flag = 0;
while (1) {
while (true) {
Vect3 unitVector;
double r0;
......
......@@ -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)
{
jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
const jsonval::ConstMemberIterator itr = parent.FindMember(key.c_str());
if (itr == parent.MemberEnd() && exist) {
throw Exp() << "error: element '" << key << "' not found";
......@@ -484,6 +484,30 @@ void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std:
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>
void PutValue(jsonalloc& alc, jsonval& ss, const std::string conName, const std::vector<T>& vec)
{
......
......@@ -5,7 +5,7 @@
#include "TimeFunctions.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());
......
......@@ -3,7 +3,6 @@
#include "DrPeriod.h"
#include "GreenwichFrame.h"
#include "ECIFrame.h"
#include "METEFrame.h"
#include "XMLFunctions.h"
#include "mathconst.h"
......
......@@ -10,8 +10,8 @@ class AscNodeOrbit
public:
AscNodeOrbit();
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_desc(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, bool vzmode, bool gcs_node, bool calc_params = true);
void calculate_params(const PhasePoint6D& j2000AscNodePoint);
double get_latitude() const { return m_latitude; }
double get_longitude() const { return m_longitude; }
......@@ -29,9 +29,9 @@ public:
double get_age() const { return m_age; }
bool is_desc() const { return m_is_desc; }
private:
void calc_asc_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, const bool vzmode, const 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_asc_node(Propagator& prop, const TimeJD& date, bool vzmode, 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, bool vzmode, bool gcs_node, double& dracp, double& vdracp) const;
double get_kep_time(double TA, double e, double w) const;
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;
......
......@@ -81,7 +81,7 @@ static const char* GetKeyById(const EnumToId* ids, int id, int size)
TAssert(0);
return 0;
return nullptr;
}
static const char* KpModelKeyById(int id)
......
#include "AtmModel.h"
#include "XMLFunctions.h"
#include <map>
#include <utility>
AtmModel::AtmModel()
: m_model("ATM_NONE")
......@@ -9,8 +10,8 @@ AtmModel::AtmModel()
AtmModel::AtmModel(std::string model, std::string kpmodel)
:
m_model(model),
m_kpModel(kpmodel)
m_model(std::move(model)),
m_kpModel(std::move(kpmodel))
{
}
......
#ifndef ATMMODEL_H
#define ATMMODEL_H
#include <iostream>
#include <string>
#include <myXML_Document.hpp>
#include "json_functions.h"
......
......@@ -2,8 +2,6 @@
#define __TIME_H_
#include <string>
#include "Converter.h"
#include <iostream>
#include <iomanip>
#include "globals.h"
#include <cmath>
......
#pragma once
#include <string>
#include <sstream>
// enum STR2INT_ERROR { XSUCCESS, XOVERFLOW, XUNDERFLOW, XINCONVERTIBLE };
//
......
......@@ -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::map<std::string, double> covmap;
for (int i = 0; i < 36; ++i) {
for (const auto& name : names) {
double value;
bool loaded;
LoadXML(con, names[i], value, false, &loaded);
LoadXML(con, name, value, false, &loaded);
if (loaded) {
covmap[names[i]] = value;
covmap[name] = value;
}
}
......@@ -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::map<std::string, double> covmap;
for (int i = 0; i < 36; ++i) {
for (const auto& name : names) {
double value;
if (loadjson(parent, names[i], value, false)) {
covmap[names[i]] = value;
if (loadjson(parent, name, value, false)) {
covmap[name] = value;
}
}
......
#include "EarthModel.h"
#include "XMLFunctions.h"
#include <map>
#include <utility>
EarthModel::EarthModel()
{
}
EarthModel::EarthModel() = default;
EarthModel::EarthModel(std::string model, int m, int n)
:
m_model(model),
m_harmonicsM(m),
m_harmonicsN(n)
m_harmonicsN(n),
m_model(std::move(model))
{
}
......
......@@ -9,7 +9,7 @@ class EarthModel
{
public:
EarthModel();
EarthModel(std::string m_model, int m, int n);
EarthModel(std::string model, int m, int n);
bool Load(myXML::Contain* parent);
void load(const jsonval& parent);
std::string GetModel() const { return m_model; }
......
......@@ -11,8 +11,8 @@ void KepData::Init(const Kepler& kep)
m_aol = kep.U;
m_raan = kep.Omega;
m_period = kep.GetPeriod();
m_hApogee = kep.GetHA(0);
m_hPerigee = kep.GetHP(0);
m_hApogee = kep.GetHA(nullptr);
m_hPerigee = kep.GetHP(nullptr);
m_rApogee = kep.GetRA();
m_rPerigee = kep.GetRP();
}
......
#include "LightModel.h"
#include "XMLFunctions.h"
#include <map>
......@@ -3,11 +3,11 @@
MagData::MagData()
:
m_hasData(false),
m_hasGeomData(false),
m_mag(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)
double MagData::CalcA0g(double stdmag, double stdphase, double stdrange, double sunMag)
{
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 C = pow(10.0, ((sunMag - stdmag) / 2.5));
const double F = 2 / 3.0 * sqr(Pi) * ((Pi - stdphase) * cos(stdphase) + sin(stdphase)) * (1 - stdphase / Pi);
return C * sqr(stdrange * 1E6) / F;
}
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));
}
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_phase = phase;
m_range = range;
......@@ -70,9 +70,9 @@ void MagData::CalcMag(double phase, double range)
void MagData::CalcGeomMag(double phase, double range)
{
double sunMag = -26.58;
double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi);
double A0g = m_rcs * 0.15;
const double sunMag = -26.58;
const double F = 2 / 3.0 * sqr(Pi) * ((Pi - phase) * cos(phase) + sin(phase)) * (1 - phase / Pi);
const double A0g = m_rcs * 0.15;
m_mag = sunMag - 2.5 * log10(F * A0g / sqr(range * 1E6));
m_phase = phase;
m_range = range;
......
#include "PrognozPredict.h"
#include "Consts.h"
#include "IAstroBase.h"
#include "Kepler.h"
#include "METEFrame.h"
......
#include "PropInfoBase.h"
#include <utility>
#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_earthModel(earthModel),
m_atmModel(atmModel),
m_atmModel(std::move(atmModel)),
m_earthModel(std::move(earthModel)),
m_lightModel(std::move(lightModel)),
m_sun(sun),
m_moon(moon),
m_type(type)
......
......@@ -2,8 +2,6 @@
#define PROPINFOBASE_H
#include <myXML_Document.hpp>
#include "DVectors.h"
#include <map>
#include "AtmModel.h"
#include "EarthModel.h"
......@@ -23,7 +21,7 @@ public:
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);
void load(const jsonval& parent);
......
#include "Propagator.h"
#include <vector>
#include "Consts.h"
#include "TextFunctions.h"
#include "METEFrame.h"
#include "GreenwichFrame.h"
#include "J2000Frame.h"
#include "ECIFrame.h"
#include "KeplPredict.h"
#include "Kepler.h"
#include "TimeFunctions.h"
#include "DVectors.h"
#include "PhasePoint.h"
......@@ -16,14 +11,14 @@
Propagator::Propagator()
:
m_predictor(0),
m_predictor(nullptr),
m_has_orbit(false)
{
}
Propagator::Propagator(const SInitOrbit& initOrbit, bool variates)
:
m_predictor(0),
m_predictor(nullptr),
m_has_orbit(false)
{
Init(initOrbit.GetPropagatorData(), initOrbit, variates);
......
......@@ -25,8 +25,8 @@ public:
bool SetKeplerPropagation(TimeJD firstPointTime);
bool Init(const PropInfoBase& propInfo, 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 InitStvPredictor(TrjNumVar& 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& propInfo);
static void InitKepPredictor(KeplerTrj& trj, const SInitOrbit& initOrbit);
static void InitPrognozPredictor(PrognozTrj& trj, const SInitOrbit& initOrbit);
static void InitSGPPredictor(SGPTrj& trj, const SInitOrbit& initOrbit);
......
#include "SGPTrj.h"
#include "PhasePoint.h"
#include "METEFrame.h"
#include "ECIFrame.h"
SGPTrj::SGPTrj() : InitTime(0, 0.0)
{
......
......@@ -6,8 +6,7 @@
#include "Consts.h"
#include "BNOAstroBase.h"
class SXYZCoordinates
{
class SXYZCoordinates {
public:
bool Load(myXML::Contain* parent)
{
......@@ -21,13 +20,12 @@ public:
double GetY() const { return m_y; }
double GetZ() const { return m_z; }
private:
double m_x;
double m_y;
double m_z;
double m_x{0};
double m_y{0};
double m_z{0};
};
class SGeoCoordinates
{
class SGeoCoordinates {
public:
bool Load(myXML::Contain* parent)
{
......@@ -54,9 +52,9 @@ public:
std::string GetEllipsoid() const { return m_ellipsoid; }
private:
double m_lat;
double m_lon;
double m_alt;
double m_lat{0};
double m_lon{0};
double m_alt{0};
std::string m_ellipsoid;
};
......@@ -83,9 +81,9 @@ void Site::load(const jsonval& parent)
converter.H = sgc.GetAlt();
converter.GetXYZ(m_coordinates);
m_lat_deg = sgc.GetLat()*rad2deg;
m_lon_deg = sgc.GetLon()*rad2deg;
m_alt_m = sgc.GetAlt()*1E6;
m_lat_deg = sgc.GetLat() * rad2deg;
m_lon_deg = sgc.GetLon() * rad2deg;
m_alt_m = sgc.GetAlt() * 1E6;
}
}
......
#include "StateVector.h"
#include <utility>
#include "XMLFunctions.h"
#include "GreenwichFrame.h"
#include "PhasePoint.h"
#include "METEFrame.h"
#include "Kepler.h"
#include "ECIFrame.h"
#include "BNOAstroBase.h"
#include "StAlgorithms.h"
#define BASEFRAME J2000Frame()
......@@ -49,12 +48,12 @@ private:
SInitOrbit::SInitOrbit()
:
m_coordinates(0, 0, 0),
m_velocities(0, 0, 0),
m_date(0, 0),
m_ballisticCoefficient(0),
m_solarPresureCoefficient(0),
//m_srcType (ORBSRCTYPE_UNK),
m_coordinates(0, 0, 0),
m_velocities(0, 0, 0)
m_ballisticCoefficient(0),
m_solarPresureCoefficient(0)
{
}
......@@ -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_propInfo(propagator),
m_ballisticCoefficient(ballc),
m_solarPresureCoefficient(solarpc),
m_periodChangePerRev(periodChangePerRev),
m_covmtx(std::move(covmtx)),
//m_srcType (ORBSRCTYPE_OPT),
m_covmtx(covmtx),
m_rev(rev),
m_baseid(baseid)
m_baseid(std::move(baseid)),
m_propInfo(std::move(propagator)), rev_(rev)
{
CreateFromPos(pos, "J2000");
}
......@@ -82,7 +90,7 @@ bool SInitOrbit::CheckFrame(const std::string& frame)
return !(frame != "ECI" && frame != "J2000" && frame != "METE" && frame != "GCS");
}
int SInitOrbit::ParseSrcType(TOrbitId id)
int SInitOrbit::ParseSrcType(const TOrbitId& id)
{
int ret;
std::string sep("::");
......
......@@ -4,12 +4,10 @@
#include <myXML_Document.hpp>
#include "DVectors.h"
#include "TM.h"
#include "IFrames.h"
#include "PhasePoint.h"
#include "KepData.h"
#include "TleData.h"
#include <map>
#include "Matrix.h"
#include "PropInfoBase.h"
#include "CovMtx.h"
#include "uncert.h"
......@@ -27,11 +25,11 @@ enum OrbitTypes
class SInitOrbit
{
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();
virtual ~SInitOrbit();
bool Load(myXML::Contain* parent);
bool Load(myXML::Contain* con);
void load(const jsonval& parent);
bool LoadNewStyle(myXML::Contain* con);
Vect3 GetCoortinates() const { return m_coordinates; }
......@@ -84,7 +82,7 @@ public:
void SetIntegratorCfg(const IntegratorCfg& icfg) { m_integratorCfg = icfg; }
const IntegratorCfg& GetIntegratorCfg() const { return m_integratorCfg; }
protected:
static int ParseSrcType(TOrbitId id);
static int ParseSrcType(const TOrbitId& id);
void CreateFromKepler(const KepData& kd, const std::string& frame);
void CreateFromPos(Vect6 dst, const std::string& frame);
static bool CheckFrame(const std::string& frame);
......@@ -105,6 +103,7 @@ protected:
TOrbitId m_baseid;
PropInfoBase m_propInfo;
IntegratorCfg m_integratorCfg;
int rev_;
};
typedef std::vector<SInitOrbit> SInitOrbits;
......
......@@ -2,7 +2,6 @@
#define __TASKINIT_H_
#include <string>
#include <clocale>
#include <sstream>
#include <fstream>
#include "BNOAstroBase.h"
......@@ -11,7 +10,7 @@
static bool TestBreak(const std::string& tFile, bool lastCall = false)
{
if (!tFile.empty()) {
std::ifstream ifile(tFile.c_str());
const std::ifstream ifile(tFile.c_str());
if (ifile) {
if (lastCall) {
remove(tFile.c_str());
......@@ -84,14 +83,14 @@ static void InitData(const std::string& file, BNOAstroBase& ab, myXML::Document&
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 diffms = (diffticks) / CLOCKS_PER_SEC;
return diffms;
}
void Tic(bool timing, const std::string& message)
inline void Tic(bool timing, const std::string& message)
{
if (timing && !message.empty()) {
end = clock();
......@@ -104,7 +103,7 @@ void Tic(bool timing, const std::string& message)
}
}
void Tic(bool timing)
inline void Tic(bool timing)
{
Tic(timing, "");
}
......
......@@ -7,7 +7,7 @@
#include <string>
#include <map>
#include <list>
#include <stdio.h>
#include "stdio.h"
#include <iomanip>
#include "Converter.h"
#include "MException.h"
......@@ -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)
{
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) {
return "";
}
......@@ -127,9 +127,9 @@ static std::string trim(const std::string& s, const std::string& t = SPACES)
template <typename ContainerT>
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) {
pos = str.find_first_of(delimiters, lastPos);
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
if (pos == std::string::npos) {
pos = str.length();
......@@ -181,9 +181,9 @@ static bool ReadFile(const std::string& path, std::string& str)
return false;
}
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.
char* buf = new char[len + 1]; //malloc buffer
auto* buf = new char[len + 1]; //malloc buffer
buf[len] = 0;
size_t res = fread(buf, len, 1, fp); //read into buffer
fclose(fp);
......@@ -249,7 +249,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int
}
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;
}
......@@ -258,7 +258,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, int& ret, int
checkBounds(ret, min, max, strict);
}
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();
}
}
......@@ -275,7 +275,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& 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);
}
......@@ -284,7 +284,7 @@ static void parseStrA(const std::string& data, int pos1, int pos2, double& ret,
checkBounds(ret, (double*)min, (double*)max, strict);
}
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();
}
}
......@@ -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)
{
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)
{
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)
......@@ -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)
{
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)
{
parseStrA(data, -1, -1, ret, 0, 0, false);
parseStrA(data, -1, -1, ret, nullptr, nullptr, false);
}
template <typename T, typename T2>
......
......@@ -65,8 +65,7 @@ static bool StrToDate(const std::string& date, TimeGD& gd)
if (part1.size() > 8) {
const size_t pos = part1.find_first_of('.');
if (pos != std::string::npos) {
std::string fracStr = part1.substr(pos);
ret = ret && Converter::ToNumber(fracStr, gd.Fraction);
ret = ret && Converter::ToNumber(part1.substr(pos), gd.Fraction);
}
}
}
......@@ -106,7 +105,7 @@ static std::string DateToStr(int year, int month, int day, int hour, int minute,
int d = hour;
int m = minute;
int s = second;
int k2 = (int)pow(10.0, prec);
const auto k2 = (int)pow(10.0, prec);
int msec = Round(fraction * k2);
if (msec >= k2) {
......@@ -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);
int nd = (int)(seconds / 86400.0);
auto nd = (int)(seconds / 86400.0);
jd += nd;
jf += (seconds / 86400.0 - nd);
......@@ -283,9 +282,9 @@ static void DegToDMS(double deg, int& rd, int& rm, double& rs)
deg = fabs(deg);
}
int h = (int)deg;
int m = (int)((deg - h) * 60);
double s = ((deg - h) * 60 - m) * 60.0;
auto h = (int)deg;
auto m = (int)((deg - h) * 60);
const double s = ((deg - h) * 60 - m) * 60.0;
rd = h;
rm = m;
......@@ -299,9 +298,9 @@ static void DegToHMS(double deg, int& rd, int& rm, double& rs)
deg = deg / 360.0 * 24;
int h = (int)deg;
int m = (int)((deg - h) * 60);
double s = ((deg - h) * 60 - m) * 60.0;
auto h = (int)deg;
auto m = (int)((deg - h) * 60);
const double s = ((deg - h) * 60 - m) * 60.0;
rd = h;
rm = m;
......@@ -348,12 +347,9 @@ static void JToSystemTime(double J, int& Cyear, int& Cmonth, int& Cday, int& Cho
a = (jd + 1) % 7;
dd = day + J - jd + 0.5;
int cyear = year;
if (BC) {
year = -year + 1;
cyear = -year;
Cyear = year;
}
else
......
#include "XMLFunctions.h"
#include <iomanip>
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*>&
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) {
items[it->first] = it->second;
for (const auto& it : parent) {
items[it.first] = it.second;
}
}
......
......@@ -12,9 +12,9 @@
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 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(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>
void ReadXML(T storage, TimeGD& result);
......@@ -187,7 +187,7 @@ void LoadXMLUnitVector(T1 storage, std::string name, std::string subname, T2& re
}
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) {
*loaded = false;
......@@ -200,7 +200,7 @@ void LoadXMLUnitVector(T1 storage, std::string subname, T2& result, bool exist,
}
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) {
*loaded = false;
......@@ -255,37 +255,37 @@ void LoadXMLMap(T1 storage, std::string subname, std::map<T2, T3>& result, bool
}
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);
}
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);
}
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);
}
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);
}
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);
}
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;
LoadXMLUnit(storage, name, date, exist, loaded);
......@@ -293,7 +293,7 @@ void LoadXML(T storage, std::string name, TimeJD& result, bool exist = true, boo
}
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);
}
......
#include "exec.h"
#include <stdio.h>
#include <cstdio>
std::string exec(const char* cmd)
{
......@@ -13,7 +13,7 @@ std::string exec(const char* cmd)
char buffer[128];
std::string result;
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != NULL)
if (fgets(buffer, 128, pipe) != nullptr)
result += buffer;
}
......
#include "gfcsRotator.h"
#include "BNOAstroBase.h"
#include "GreenwichFrame.h"
#include "LocalJ2000Frame.h"
#include "NZEFrame.h"
GFCSRotator::GFCSRotator(TimeJD baseDate)
GFCSRotator::GFCSRotator(const TimeJD& baseDate)
{
Init(baseDate);
}
void GFCSRotator::Init(TimeJD baseDate)
void GFCSRotator::Init(const TimeJD& baseDate)
{
m_baseDate = baseDate;
IAstroBase* ab = GetAstroBase();
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();
double w = ab->GetEarthRotation();
......@@ -36,7 +35,7 @@ void GFCSRotator::Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ
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;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
......@@ -55,7 +54,7 @@ void GFCSRotator::GCSToJ2000(TimeJD date, const Vect6& gcs, Vect6& j2000) const
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
// FrameConverter6D j2000ToGcs;
......@@ -98,7 +97,7 @@ void GFCSRotator::J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const
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;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
......@@ -113,7 +112,7 @@ void GFCSRotator::GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000T
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;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
......@@ -128,7 +127,7 @@ void GFCSRotator::GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ
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.Init(siteGcsPos);
......@@ -144,7 +143,7 @@ void GFCSRotator::GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameC
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;
Rotate(date, CJ2000toGFCS, CGFCStoJ2000);
......@@ -164,14 +163,14 @@ void GFCSRotator::GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos,
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;
GetJ2000ToNze6dConverter(date, siteGcsPos, J2000toNze);
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;
GetJ2000ToLocalJ20006dConverter(date, siteGcsPos, J2000toLocalJ2000);
......
......@@ -10,20 +10,20 @@ public:
GFCSRotator()
{
};
GFCSRotator(TimeJD baseDate);
void Init(TimeJD baseDate);
void Rotate(TimeJD date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const;
GFCSRotator(const TimeJD& baseDate);
void Init(const TimeJD& baseDate);
void Rotate(const TimeJD& date, TransMtx& CJ2000toGFCS, TransMtx& CGFCStoJ2000) const;
void J2000ToGCS(const PhasePoint6D& j2000, PhasePoint6D& gcs) const;
void J2000ToGCS(TimeJD date, const Vect6& j2000, Vect6& gcs) const;
void J2000ToLocalJ2000(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const;
void J2000ToNze(TimeJD date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) const;
void J2000ToGCS(const TimeJD& date, const Vect6& j2000, Vect6& gcs) const;
void J2000ToLocalJ2000(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& localJ2000) const;
void J2000ToNze(const TimeJD& date, const Vect6& j2000, Vect3 siteGcsPos, Vect6& nze) 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:
void GetGcsToJ20006dConverter(TimeJD date, FrameConverter6D& gcsToJ2000) const;
void GetJ2000ToGcs6dConverter(TimeJD date, FrameConverter6D& j2000ToGcs) const;
void GetJ2000ToNze6dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& gcsToJ2000) const;
void GetJ2000ToLocalJ20006dConverter(TimeJD date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const;
void GetGcsToJ20006dConverter(const TimeJD& date, FrameConverter6D& gcsToJ2000) const;
void GetJ2000ToGcs6dConverter(const TimeJD& date, FrameConverter6D& j2000ToGcs) const;
void GetJ2000ToNze6dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toNze) const;
void GetJ2000ToLocalJ20006dConverter(const TimeJD& date, Vect3 siteGcsPos, FrameConverter6D& J2000toLocalJ2000) const;
TransMtx BJ2000toGFCS;
TimeJD m_baseDate;
};
#include "globals.h"
#include <cmath>
#include "Consts.h"
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,
y1 = R * cosb * sin(l);
z1 = R * sin(b);
double a11, a12, a13, a21, a22, a23, a31, a32, a33;
double a21, a22, a23, a31, a32, a33;
// a11 = cosfi*cosla;
a21 = -sinla;
......
......@@ -33,8 +33,8 @@ void OrbBlocksStore::init(
init_min_dist(sordet_orbits, nbeg, nend, min_dist_forced);
if (interpolate) {
for (OrbBlocks::iterator it = m_blocks.begin(); it != m_blocks.end(); ++it) {
it->interpolate(it->get_beg(), it->get_end());
for (auto& m_block : m_blocks) {
m_block.interpolate(m_block.get_beg(), m_block.get_end());
}
}
}
......@@ -190,7 +190,7 @@ public:
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 p2 = m_ip2.get_pos(date);
......@@ -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
{
XInterpolator ip1(orb1, beg, end);
XInterpolator ip2(orb2, beg, end);
const XInterpolator ip1(orb1, beg, end);
const XInterpolator ip2(orb2, beg, end);
MinDistEvaluator eval(ip1, ip2, beg);
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
// 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) {
result.push_back(ShiftDateX(sdate, step_sec * (i + 1)));
result.emplace_back(ShiftDateX(sdate, step_sec * (i + 1)));
}
if (result.back() != edate) {
......@@ -52,14 +52,14 @@ template <typename T>
void propagate_dir_prop(Propagator& prop, const std::vector<TimeJD>& dates, int dir, std::vector<T>& result)
{
if (dir > 0) {
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); it++) {
for (const auto& date : dates) {
T item;
propagate_date(prop, *it, item);
propagate_date(prop, date, item);
result.push_back(item);
}
}
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;
propagate_date(prop, *it, item);
result.push_back(item);
......@@ -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)
{
for (std::vector<TimeJD>::const_iterator it = dates.begin(); it != dates.end(); ++it) {
if (*it < date) {
dates_left.push_back(*it);
for (const auto& it : dates) {
if (it < date) {
dates_left.push_back(it);
}
else {
dates_right.push_back(*it);
dates_right.push_back(it);
}
}
}
......
......@@ -17,7 +17,7 @@ public:
{
}
virtual const TimeJD& GetTime() const { return TimeJD(); };
virtual IPredict* GetPredictor() { return 0; }
virtual IPredict* GetPredictor() { return nullptr; }
private:
const OrbBlocksStore& m_orbit_processor;
};
......@@ -16,7 +16,7 @@ public:
{
}
virtual const TimeJD& GetTime() const { return TimeJD(); }
virtual IPredict* GetPredictor() { return 0; }
virtual IPredict* GetPredictor() { return nullptr; }
private:
const XInterpolator& m_itp;
};
......@@ -6,8 +6,8 @@
template <typename T>
double golden_section_search(const T& f, double a, double b, double tol)
{
double invphi = (std::sqrt(5.0) - 1) / 2.0;
double invphi2 = (3 - std::sqrt(5.0)) / 2.0;
const double invphi = (std::sqrt(5.0) - 1) / 2.0;
const double invphi2 = (3 - std::sqrt(5.0)) / 2.0;
a = std::min(a, b);
b = std::max(a, b);
......@@ -18,7 +18,7 @@ double golden_section_search(const T& f, double a, double b, double tol)
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 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