...
This commit is contained in:
parent
412f038eb0
commit
e6b4604bfa
@ -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 <mcc::traits::mcc_char_range BYTEREPR_T = std::string_view,
|
||||
mcc_netmsg_valid_keys_c BASE_T = MccNetMessageValidKeywords>
|
||||
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<T>) {
|
||||
(*this)(value.count(), bytes);
|
||||
} else if constexpr (mcc_eqt_hrz_coord_c<T>) {
|
||||
// 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<T>) {
|
||||
if (_currentCoordFormat == MccNetMessageCoordFormat::CFMT_DEGREES) {
|
||||
std::format_to(std::back_inserter(bytes), "{}{}{}", MccAngle(value.X).degrees(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user