...
This commit is contained in:
@@ -272,9 +272,9 @@ public:
|
||||
auto days = std::chrono::floor<std::chrono::days>(tp);
|
||||
std::chrono::year_month_day ymd{days};
|
||||
|
||||
double mjd0;
|
||||
double mjd0, mjd;
|
||||
|
||||
int err = eraCal2jd((int)ymd.year(), (unsigned)ymd.month(), (unsigned)ymd.day(), &mjd0, &julday->mjd);
|
||||
int err = eraCal2jd((int)ymd.year(), (unsigned)ymd.month(), (unsigned)ymd.day(), &mjd0, &mjd);
|
||||
|
||||
if (err != 0) {
|
||||
ret = err == -1 ? MccCCTE_ERFAErrorCode::ERROR_julday_INVALID_YEAR
|
||||
@@ -282,15 +282,14 @@ public:
|
||||
: err == -3 ? MccCCTE_ERFAErrorCode::ERROR_julday_INVALID_DAY
|
||||
: MccCCTE_ERFAErrorCode::ERROR_UNEXPECTED;
|
||||
} else { // partial part of day
|
||||
julday->mjd +=
|
||||
std::chrono::duration_cast<std::chrono::duration<double, std::ratio<86400>>>(tp - days).count();
|
||||
mjd += std::chrono::duration_cast<std::chrono::duration<double, std::ratio<86400>>>(tp - days).count();
|
||||
*julday = mjd + mjd0;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
error_t timepointToAppSideral(mcc_time_point_c auto tp, mcc_angle_c auto* st, bool islocal = false)
|
||||
error_t juldayToAppSideral(mcc_julday_c auto jd, mcc_angle_c auto* st, bool islocal = false)
|
||||
{
|
||||
error_t ret = MccCCTE_ERFAErrorCode::ERROR_OK;
|
||||
|
||||
@@ -300,19 +299,12 @@ public:
|
||||
|
||||
using real_days_t = std::chrono::duration<double, std::ratio<86400>>;
|
||||
|
||||
MccJulianDay julday;
|
||||
|
||||
ret = timepointToJulday(tp, &julday);
|
||||
if (ret != MccCCTE_ERFAErrorCode::ERROR_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
double ut1 = julday.mjd;
|
||||
double tt = julday.mjd;
|
||||
double ut1 = jd.MJD();
|
||||
double tt = jd.MJD();
|
||||
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(julday.mjd);
|
||||
auto dut1 = _currentState._bulletinA.DUT1(jd.MJD());
|
||||
|
||||
if (dut1.has_value()) {
|
||||
ut1 += std::chrono::duration_cast<real_days_t>(dut1.value()).count();
|
||||
@@ -320,7 +312,7 @@ public:
|
||||
return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
auto tai_utc = _currentState._leapSeconds[julday.mjd];
|
||||
auto tai_utc = _currentState._leapSeconds[jd.MJD()];
|
||||
if (tai_utc.has_value()) {
|
||||
tt += std::chrono::duration_cast<real_days_t>(tai_utc.value()).count();
|
||||
} else {
|
||||
@@ -331,7 +323,7 @@ public:
|
||||
auto tt_tai = _currentState._bulletinA.TT_TAI();
|
||||
tt += std::chrono::duration_cast<real_days_t>(tt_tai).count();
|
||||
|
||||
*st = eraGst06a(julday.MJD0, ut1, julday.MJD0, tt);
|
||||
*st = eraGst06a(ERFA_DJM0, ut1, ERFA_DJM0, tt);
|
||||
|
||||
if (islocal) {
|
||||
*st += _currentState.lon;
|
||||
@@ -341,6 +333,57 @@ public:
|
||||
return ret;
|
||||
}
|
||||
|
||||
error_t timepointToAppSideral(mcc_time_point_c auto tp, mcc_angle_c auto* st, bool islocal = false)
|
||||
{
|
||||
error_t ret = MccCCTE_ERFAErrorCode::ERROR_OK;
|
||||
|
||||
if (st == nullptr) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
MccJulianDay julday;
|
||||
|
||||
ret = timepointToJulday(tp, &julday);
|
||||
if (ret != MccCCTE_ERFAErrorCode::ERROR_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return juldayToAppSideral(julday, st, islocal);
|
||||
|
||||
// double ut1 = julday.MJD();
|
||||
// double tt = julday.MJD();
|
||||
|
||||
// std::lock_guard lock{*_stateMutex};
|
||||
|
||||
// auto dut1 = _currentState._bulletinA.DUT1(julday.MJD());
|
||||
|
||||
// if (dut1.has_value()) {
|
||||
// ut1 += std::chrono::duration_cast<real_days_t>(dut1.value()).count();
|
||||
// } else { // out of range
|
||||
// return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
// }
|
||||
|
||||
// auto tai_utc = _currentState._leapSeconds[julday.MJD()];
|
||||
// if (tai_utc.has_value()) {
|
||||
// tt += std::chrono::duration_cast<real_days_t>(tai_utc.value()).count();
|
||||
// } else {
|
||||
// return MccCCTE_ERFAErrorCode::ERROR_LEAPSECONDS_OUT_OF_RANGE;
|
||||
// }
|
||||
|
||||
|
||||
// auto tt_tai = _currentState._bulletinA.TT_TAI();
|
||||
// tt += std::chrono::duration_cast<real_days_t>(tt_tai).count();
|
||||
|
||||
// *st = eraGst06a(ERFA_DJM0, ut1, ERFA_DJM0, tt);
|
||||
|
||||
// if (islocal) {
|
||||
// *st += _currentState.lon;
|
||||
// }
|
||||
|
||||
|
||||
// return ret;
|
||||
}
|
||||
|
||||
|
||||
// coordinates transformations
|
||||
|
||||
@@ -691,13 +734,13 @@ protected:
|
||||
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(jd.mjd);
|
||||
auto dut1 = _currentState._bulletinA.DUT1(jd.MJD());
|
||||
|
||||
if (!dut1.has_value()) {
|
||||
return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
auto pol_pos = _currentState._bulletinA.polarCoords(jd.mjd);
|
||||
auto pol_pos = _currentState._bulletinA.polarCoords(jd.MJD());
|
||||
if (!pol_pos.has_value()) {
|
||||
return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
@@ -709,7 +752,7 @@ protected:
|
||||
|
||||
double az, zd, ha, ra, dec, eo;
|
||||
|
||||
int err = eraAtco13(pt.X, pt.Y, 0.0, 0.0, 0.0, 0.0, jd.MJD0, jd.mjd, dut1->count(), _currentState.lon,
|
||||
int err = eraAtco13(pt.X, pt.Y, 0.0, 0.0, 0.0, 0.0, jd.MJD0, jd.MJD(), dut1->count(), _currentState.lon,
|
||||
_currentState.lat, _currentState.elev, pol_pos->x, pol_pos->y, _currentState.meteo.pressure,
|
||||
_currentState.meteo.temperature, _currentState.meteo.humidity, _currentState.wavelength,
|
||||
&az, &zd, &ha, &dec, &ra, &eo);
|
||||
@@ -750,13 +793,13 @@ protected:
|
||||
|
||||
std::lock_guard lock{*_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(jd.mjd);
|
||||
auto dut1 = _currentState._bulletinA.DUT1(jd.MJD());
|
||||
|
||||
if (!dut1.has_value()) {
|
||||
return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
auto pol_pos = _currentState._bulletinA.polarCoords(jd.mjd);
|
||||
auto pol_pos = _currentState._bulletinA.polarCoords(jd.MJD());
|
||||
if (!pol_pos.has_value()) {
|
||||
return MccCCTE_ERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
@@ -793,7 +836,7 @@ protected:
|
||||
return MccCCTE_ERFAErrorCode::ERROR_UNSUPPORTED_COORD_PAIR;
|
||||
}
|
||||
|
||||
int err = eraAtoc13(type.c_str(), from_pt.X, from_pt.Y, jd.MJD0, jd.mjd, dut1->count(), _currentState.lon,
|
||||
int err = eraAtoc13(type.c_str(), from_pt.X, from_pt.Y, jd.MJD0, jd.MJD(), dut1->count(), _currentState.lon,
|
||||
_currentState.lat, _currentState.elev, pol_pos->x, pol_pos->y, _currentState.meteo.pressure,
|
||||
_currentState.meteo.temperature, _currentState.meteo.humidity, _currentState.wavelength,
|
||||
&to_pt->X, &to_pt->Y);
|
||||
@@ -842,7 +885,8 @@ protected:
|
||||
return MccCCTE_ERFAErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
MccJulianDay jd, tt;
|
||||
MccJulianDay jd;
|
||||
double tt;
|
||||
auto ret = timepointToJulday(tp, &jd);
|
||||
if (ret) {
|
||||
return ret;
|
||||
@@ -852,14 +896,14 @@ protected:
|
||||
|
||||
using real_days_t = std::chrono::duration<double, std::ratio<86400>>;
|
||||
|
||||
auto tai_utc = _currentState._leapSeconds[jd.mjd];
|
||||
auto tai_utc = _currentState._leapSeconds[jd.MJD()];
|
||||
if (tai_utc.has_value()) {
|
||||
tt.mjd = jd.mjd + std::chrono::duration_cast<real_days_t>(tai_utc.value()).count();
|
||||
tt = jd.MJD() + std::chrono::duration_cast<real_days_t>(tai_utc.value()).count();
|
||||
|
||||
auto tt_tai = _currentState._bulletinA.TT_TAI();
|
||||
tt.mjd = jd.mjd + std::chrono::duration_cast<real_days_t>(tt_tai).count();
|
||||
tt += +std::chrono::duration_cast<real_days_t>(tt_tai).count();
|
||||
|
||||
*eo = eraEo06a(tt.MJD0, tt.mjd);
|
||||
*eo = eraEo06a(jd.MJD0, tt);
|
||||
} else {
|
||||
ret = MccCCTE_ERFAErrorCode::ERROR_LEAPSECONDS_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user