From e6b4604bfa69ca57185d7623a1fc7bfec3a696d7 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Thu, 23 Oct 2025 18:08:44 +0300 Subject: [PATCH] ... --- mcc/mcc_netserver_proto.h | 56 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/mcc/mcc_netserver_proto.h b/mcc/mcc_netserver_proto.h index 246aa22..b35a610 100644 --- a/mcc/mcc_netserver_proto.h +++ b/mcc/mcc_netserver_proto.h @@ -494,7 +494,7 @@ concept mcc_netmessage_c = requires(T t) { T(); }; /* helper types to format serialized celestial coordinates */ -/* it can be used as inputs in "construct" method or corresponded constructor */ +/* it can be used as inputs in "construct" method or corresponding constructor */ // format of output (serialized) coordinates enum class MccNetMessageCoordFormat { CFMT_DEGREES, CFMT_SGM }; @@ -510,7 +510,6 @@ template class MccNetMessage { -public: protected: class DefaultDeserializer : protected mcc::utils::MccSimpleDeserializer { @@ -530,7 +529,7 @@ protected: return ec; } - if (vs.size() < 2) { // al least a pair of coordinates must be given + if (vs.size() < 2) { // at least a pair of coordinates must be given return std::make_error_code(std::errc::invalid_argument); } @@ -681,6 +680,57 @@ protected: // std::ranges::copy(mcc_pairkind2str(value), std::back_inserter(bytes)); } else if constexpr (traits::mcc_time_duration_c) { (*this)(value.count(), bytes); + } else if constexpr (mcc_eqt_hrz_coord_c) { + // output format: RA, DEC, HA, AZ, ZD, ALT, X, Y, pair-kind, time-point + // in the case of sexagesimal output X,Y coordinates will be interprateted + // according to value.pair_kind field + if (_currentCoordFormat == MccNetMessageCoordFormat::CFMT_DEGREES) { + std::format_to(std::back_inserter(bytes), "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", + MccAngle(value.RA).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.DEC).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.HA).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.AZ).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.ZD).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.ALT).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.X).degrees(), MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.Y).degrees()); + } else { + std::format_to(std::back_inserter(bytes), "{}{}{}{}{}{}{}{}{}{}{}{}", + MccAngle(value.RA).sexagesimal(true, _currentCoordPrec.hour_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.DEC).sexagesimal(false, _currentCoordPrec.deg_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.HA).sexagesimal(true, _currentCoordPrec.hour_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.AZ).sexagesimal(false, _currentCoordPrec.deg_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.ZD).sexagesimal(false, _currentCoordPrec.deg_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, + MccAngle(value.ALT).sexagesimal(false, _currentCoordPrec.deg_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ); + + // interpretate X,Y angles according to .pair_kind field + switch (value.pair_kind) { + case MccCoordPairKind::COORDS_KIND_RADEC_ICRS: + case MccCoordPairKind::COORDS_KIND_RADEC_APP: + case MccCoordPairKind::COORDS_KIND_HADEC_APP: + std::format_to(std::back_inserter(bytes), "{}{}{}{}", + MccAngle(value.X).sexagesimal(true, _currentCoordPrec.hour_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ); + break; + default: + std::format_to(std::back_inserter(bytes), "{}{}", + MccAngle(value.X).sexagesimal(false, _currentCoordPrec.deg_prec), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ); + } + std::format_to(std::back_inserter(bytes), "{}", + MccAngle(value.Y).sexagesimal(false, _currentCoordPrec.deg_prec)); + } + + std::format_to(std::back_inserter(bytes), "{0:}{1:}{2:}{3:%F}T{3:%T}", + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, MccCoordPairKindToStr(value.pair_kind), + MCC_COMMPROTO_RANGEPARAM_DELIM_SEQ, value.time_point); + } else if constexpr (mcc_celestial_point_c) { if (_currentCoordFormat == MccNetMessageCoordFormat::CFMT_DEGREES) { std::format_to(std::back_inserter(bytes), "{}{}{}", MccAngle(value.X).degrees(),