...
This commit is contained in:
@@ -21,6 +21,7 @@ enum class MccMountAstromEngineERFAErrorCode : int {
|
||||
ERROR_INVALID_INPUT_ARG,
|
||||
ERROR_JULDATE_INVALID_YEAR,
|
||||
ERROR_JULDATE_INVALID_MONTH,
|
||||
ERROR_UNSUPPORTED_COORD_PAIR,
|
||||
ERROR_BULLETINA_OUT_OF_RANGE,
|
||||
ERROR_LEAPSECONDS_OUT_OF_RANGE,
|
||||
ERROR_DUBIOUS_YEAR,
|
||||
@@ -75,6 +76,8 @@ struct MccMountAstromEngineERFACategory : public std::error_category {
|
||||
return "invalid year number";
|
||||
case MccMountAstromEngineERFAErrorCode::ERROR_JULDATE_INVALID_MONTH:
|
||||
return "invalid month number";
|
||||
case MccMountAstromEngineERFAErrorCode::ERROR_UNSUPPORTED_COORD_PAIR:
|
||||
return "unsupported coordinate pair";
|
||||
case MccMountAstromEngineERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE:
|
||||
return "time point is out of range";
|
||||
case MccMountAstromEngineERFAErrorCode::ERROR_LEAPSECONDS_OUT_OF_RANGE:
|
||||
@@ -449,6 +452,63 @@ public:
|
||||
}
|
||||
|
||||
|
||||
error_t obs2icrs(MccCoordPairKind coord_kind, coord_t x, coord_t y, juldate_t juldate, coord_t ra, coord_t dec)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
|
||||
auto dut1 = _currentState._bulletinA.DUT1(juldate.mjd);
|
||||
|
||||
if (!dut1.has_value()) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
|
||||
auto pol_pos = _currentState._bulletinA.polarCoords(juldate.mjd);
|
||||
if (!pol_pos.has_value()) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_BULLETINA_OUT_OF_RANGE;
|
||||
}
|
||||
const auto arcsec2rad = std::numbers::pi / 180 / 3600;
|
||||
pol_pos->x *= arcsec2rad;
|
||||
pol_pos->y *= arcsec2rad;
|
||||
|
||||
std::string type;
|
||||
switch (coord_kind) {
|
||||
case mcc::MccCoordPairKind::COORDS_KIND_AZZD:
|
||||
type = "A";
|
||||
break;
|
||||
case mcc::MccCoordPairKind::COORDS_KIND_AZALT:
|
||||
y = std::numbers::pi / 2.0 - y; // altitude to zenithal distance
|
||||
type = "A";
|
||||
break;
|
||||
case mcc::MccCoordPairKind::COORDS_KIND_HADEC_APP:
|
||||
type = "H";
|
||||
break;
|
||||
case mcc::MccCoordPairKind::COORDS_KIND_RADEC_APP:
|
||||
type = "R";
|
||||
break;
|
||||
default:
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UNSUPPORTED_COORD_PAIR;
|
||||
}
|
||||
|
||||
double ra_icrs, dec_icrs;
|
||||
|
||||
int ret = eraAtoc13(type.c_str(), x, y, juldate.MJD0, juldate.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,
|
||||
&ra_icrs, &dec_icrs);
|
||||
|
||||
if (ret == 1) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_DUBIOUS_YEAR;
|
||||
} else if (ret == -1) {
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_UNACCEPTABLE_DATE;
|
||||
}
|
||||
|
||||
ra = ra_icrs;
|
||||
dec = dec_icrs;
|
||||
|
||||
return MccMountAstromEngineERFAErrorCode::ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
error_t hadec2azalt(coord_t ha, coord_t dec, coord_t& az, coord_t& alt)
|
||||
{
|
||||
std::lock_guard lock{_stateMutex};
|
||||
|
||||
Reference in New Issue
Block a user