This commit is contained in:
2025-04-16 18:12:02 +03:00
parent e80116d4ae
commit ea99bc721b
3 changed files with 25 additions and 11 deletions

View File

@@ -73,28 +73,30 @@ public:
// auto ang = MccCoordinate{180.0, mcc_degrees};
MccCoordinate(std::convertible_to<double> auto const& val, const MccDegreeTag tag)
{
_angleInRads = val * std::numbers::pi / 180.0;
_angleInRads = val * utils::deg2radCoeff;
}
// constuct angle from sexagesimal representation, e.g.:
// constuct angle from sexagesimal representation or floating-point number of degrees, e.g.:
// auto ang = MccCoordinate{"-12:34:56.789"}; // from degrees:minutes:seconds
// auto ang = MccCoordinate{"123.574698"}; // from degrees
MccCoordinate(traits::mcc_input_char_range auto const& val)
{
auto res = utils::parsAngleString(val);
if (res.has_value()) {
_angleInRads = res.value() * std::numbers::pi / 180.0;
_angleInRads = res.value() * utils::deg2radCoeff;
} else {
throw std::invalid_argument("invalid sexagesimal representation");
}
}
// construct angle from sexagesimal representation, e.g.:
// construct angle from sexagesimal representation or floating-point number of degrees, e.g.:
// auto ang = MccCoordinate{"01:23:45.6789", mcc_hms}; // from hours:minutes:seconds
// auto ang = MccCoordinate{"123.574698"}; // from degrees
MccCoordinate(traits::mcc_input_char_range auto const& val, const MccHMSTag)
{
auto res = utils::parsAngleString(val, true);
if (res.has_value()) {
_angleInRads = res.value() * std::numbers::pi / 180.0;
_angleInRads = res.value() * utils::deg2radCoeff;
} else {
throw std::invalid_argument("invalid sexagesimal representation");
}