This commit is contained in:
2025-12-15 17:26:26 +03:00
parent a30729fb37
commit a8dd511366
4 changed files with 703 additions and 72 deletions

View File

@@ -14,7 +14,51 @@ public:
typedef CO_LON_T x_t;
typedef CO_LAT_T y_t;
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y) : _x(x), _y(y) {}
static constexpr MccCoordPairKind pairKind =
!(std::derived_from<CO_LON_T, MccAngle> ||
std::derived_from<CO_LAT_T, MccAngle>) // unknown type (possibly just double or float)
? MccCoordPairKind::COORDS_KIND_GENERIC
: (std::same_as<CO_LON_T, MccAngle> || std::same_as<CO_LAT_T, MccAngle>) // one of the types is MccAngle
? MccCoordPairKind::COORDS_KIND_GENERIC
// ICRS RA and DEC
: (std::same_as<CO_LON_T, MccAngleRA_ICRS> && std::same_as<CO_LAT_T, MccAngleDEC_ICRS>)
? MccCoordPairKind::COORDS_KIND_RADEC_ICRS
// apparent RA and DEC
: (std::same_as<CO_LON_T, MccAngleRA_APP> && std::same_as<CO_LAT_T, MccAngleDEC_APP>)
? MccCoordPairKind::COORDS_KIND_RADEC_APP
// observed RA and DEC
: (std::same_as<CO_LON_T, MccAngleRA_OBS> && std::same_as<CO_LAT_T, MccAngleDEC_OBS>)
? MccCoordPairKind::COORDS_KIND_RADEC_APP
// apparent HA and DEC
: (std::same_as<CO_LON_T, MccAngleHA_APP> && std::same_as<CO_LAT_T, MccAngleDEC_APP>)
? MccCoordPairKind::COORDS_KIND_HADEC_APP
// observed HA and DEC
: (std::same_as<CO_LON_T, MccAngleHA_OBS> && std::same_as<CO_LAT_T, MccAngleDEC_OBS>)
? MccCoordPairKind::COORDS_KIND_HADEC_APP
// apparent AZ and ZD
: (std::same_as<CO_LON_T, MccAngleAZ> && std::same_as<CO_LAT_T, MccAngleZD>)
? MccCoordPairKind::COORDS_KIND_AZZD
// apparent AZ and ALT
: (std::same_as<CO_LON_T, MccAngleAZ> && std::same_as<CO_LAT_T, MccAngleALT>)
? MccCoordPairKind::COORDS_KIND_AZZD
// general purpose X and Y
: (std::same_as<CO_LON_T, MccAngleX> && std::same_as<CO_LAT_T, MccAngleY>)
? MccCoordPairKind::COORDS_KIND_XY
// geographical longitude and latitude
: (std::same_as<CO_LON_T, MccAngleLON> && std::same_as<CO_LAT_T, MccAngleLAT>)
? MccCoordPairKind::COORDS_KIND_LONLAT
: MccCoordPairKind::COORDS_KIND_UNKNOWN;
template <mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
MccCoordPair(CO_LON_T const& x, CO_LAT_T const& y, EpT const& epoch = EpT::now()) : _x(x), _y(y), _mjd(epoch.MJD)
{
}
MccCoordPair(const MccCoordPair&) = default;
MccCoordPair(MccCoordPair&&) = default;
MccCoordPair& operator=(const MccCoordPair&) = default;
MccCoordPair& operator=(MccCoordPair&&) = default;
virtual ~MccCoordPair() = default;
@@ -28,9 +72,16 @@ public:
return _y;
}
operator std::tuple<CO_LON_T, CO_LAT_T>() const
double MJD() const
{
return {_x, _y};
return _mjd;
}
// for something like:
// auto [ra, dec, mjd] = coord_pair;
operator std::tuple<CO_LON_T, CO_LAT_T, double>() const
{
return {_x, _y, _mjd};
}
void setX(const CO_LON_T& x)
@@ -43,9 +94,16 @@ public:
_y = y;
}
void setMJD(double mjd)
{
_mjd = mjd;
}
protected:
CO_LON_T _x;
CO_LAT_T _y;
double _mjd;
};
@@ -58,7 +116,50 @@ concept mcc_coord_pair_c = requires {
};
/* predefined coordinate pairs */
template <mcc_angle_c CO_LON_T, mcc_angle_c CO_LAT_T>
requires(std::derived_from<CO_LON_T, MccAngle> && std::derived_from<CO_LAT_T, MccAngle>)
class MccNamedCoordPair : public MccCoordPair<CO_LON_T, CO_LAT_T>
{
public:
template <typename CxT, typename CyT, mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
requires(std::is_arithmetic_v<CxT> && std::is_arithmetic_v<CyT>)
MccNamedCoordPair(CxT const& x, CyT const& y, EpT const& epoch = EpT::now())
: MccCoordPair<CO_LON_T, CO_LAT_T>(CO_LON_T{x}, CO_LAT_T{y}, epoch)
{
}
template <mcc_coord_epoch_c EpT = MccCelestialCoordEpoch>
MccNamedCoordPair(MccAngle const& x, MccAngle const& y, EpT const& epoch = EpT::now())
: MccCoordPair<CO_LON_T, CO_LAT_T>(CO_LON_T{(double)x}, CO_LAT_T{(double)y}, epoch)
{
}
MccNamedCoordPair(const MccNamedCoordPair&) = default;
MccNamedCoordPair(MccNamedCoordPair&&) = default;
MccNamedCoordPair& operator=(const MccNamedCoordPair&) = default;
MccNamedCoordPair& operator=(MccNamedCoordPair&&) = default;
virtual ~MccNamedCoordPair() = default;
};
using MccSkyRADEC_ICRS = MccNamedCoordPair<MccAngleRA_ICRS, MccAngleDEC_ICRS>;
using MccSkyRADEC_APP = MccNamedCoordPair<MccAngleRA_APP, MccAngleDEC_APP>;
using MccSkyRADEC_OBS = MccNamedCoordPair<MccAngleRA_OBS, MccAngleDEC_OBS>;
using MccSkyHADEC_APP = MccNamedCoordPair<MccAngleHA_APP, MccAngleDEC_APP>;
using MccSkyHADEC_OBS = MccNamedCoordPair<MccAngleHA_OBS, MccAngleDEC_OBS>;
using MccSkyAZZD = MccNamedCoordPair<MccAngleAZ, MccAngleZD>;
using MccSkyAZALT = MccNamedCoordPair<MccAngleAZ, MccAngleALT>;
using MccGenXY = MccNamedCoordPair<MccAngleX, MccAngleY>;
using MccGeoLONLAT = MccNamedCoordPair<MccAngleLON, MccAngleLAT>;
struct mcc_skycoord_interface_t {
virtual ~mcc_skycoord_interface_t() = default;
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_angle_c XT, mcc_angle_c YT>
SelfT& from(this SelfT&& self, XT&& x, YT&& y)
{
@@ -81,7 +182,7 @@ struct mcc_skycoord_interface_t {
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT, mcc_coord_pair_c... PTs>
SelfT& to(this SelfT&& self, PT& cpair, PTs&... cpairs)
{
return std::forward<SelfT>(self).to(cpair, cpairs);
return std::forward<SelfT>(self).to(cpair, cpairs...);
}
template <std::derived_from<mcc_skycoord_interface_t> SelfT, mcc_coord_pair_c PT>
@@ -103,4 +204,11 @@ concept mcc_skycoord_c = std::derived_from<T, mcc_skycoord_interface_t> && requi
{ T::meteo(std::declval<typename T::meteo_t const&>()) };
};
} // end namespace mcc
class MccSkyPoint : public mcc_skycoord_interface_t
{
public:
};
} // end namespace mcc