...
This commit is contained in:
parent
95fcca2deb
commit
610862b3a7
@ -185,7 +185,11 @@ struct earth_orient_db_elem_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef std::vector<earth_orient_db_elem_t> earth_orient_db_t;
|
// typedef std::vector<earth_orient_db_elem_t> earth_orient_db_t;
|
||||||
|
struct earth_orient_db_t {
|
||||||
|
std::chrono::system_clock::time_point bulletinDate{};
|
||||||
|
std::vector<earth_orient_db_elem_t> db{};
|
||||||
|
};
|
||||||
|
|
||||||
// init to some known state
|
// init to some known state
|
||||||
static leapsecond_db_t CURRENT_LEAPSECONDS_DB = {
|
static leapsecond_db_t CURRENT_LEAPSECONDS_DB = {
|
||||||
@ -202,8 +206,30 @@ static leapsecond_db_t CURRENT_LEAPSECONDS_DB = {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static earth_orient_db_t CURRENT_EARTH_ORIENT_DB;
|
||||||
|
|
||||||
bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '*')
|
bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto& stream, char comment_sym = '*')
|
||||||
{
|
{
|
||||||
|
const std::regex bull_date_rx{
|
||||||
|
"^ *[0-9]{1,2} +(January|Febraury|March|April|May|June|July|August|September|October|November|December) "
|
||||||
|
"+[0-9]{4,} + Vol\\.[XMLCDVI]+ +No\\. +[0-9]+ *$"};
|
||||||
|
|
||||||
|
const std::regex bull_tab_title_rx{"^ *MJD +x\\(arcsec\\) +y\\(arcsec\\) +UT1-UTC\\(sec\\) *$"};
|
||||||
|
|
||||||
|
// 2025 3 7 60741 0.0663 0.3341 0.04348
|
||||||
|
const std::regex bull_tab_vals_rx{
|
||||||
|
"^ *[0-9]{4,} +[0-9]{1,2} +[0-9]{1,2} +[0-9]{5,} +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ +[0-9]+\\.[0-9]+ *$"};
|
||||||
|
|
||||||
|
earth_orient_db_t db;
|
||||||
|
enum { TAB_STATE_SEEK, TAB_STATE_START };
|
||||||
|
int tab_state = TAB_STATE_SEEK;
|
||||||
|
|
||||||
|
int year;
|
||||||
|
unsigned month, day;
|
||||||
|
double mjd, x, y, dut1;
|
||||||
|
std::istringstream is;
|
||||||
|
|
||||||
for (std::string line; std::getline(stream, line);) {
|
for (std::string line; std::getline(stream, line);) {
|
||||||
if (line.empty()) {
|
if (line.empty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -215,11 +241,41 @@ bool mcc_parse_bulletinA(std::derived_from<std::basic_istream<char>> auto& strea
|
|||||||
if (sv[0] == comment_sym) { // comment string
|
if (sv[0] == comment_sym) { // comment string
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
|
if (tab_state == TAB_STATE_START) {
|
||||||
|
if (std::regex_match(sv.begin(), sv.end(), bull_tab_vals_rx)) {
|
||||||
|
is.str({sv.begin(), sv.end()});
|
||||||
|
is >> year >> month >> day >> mjd >> x >> y >> dut1;
|
||||||
|
db.db.emplace_back(year, month, day, mjd, x, y, dut1);
|
||||||
|
} else { // end of the table - just stop parsing
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::regex_match(sv.begin(), sv.end(), bull_date_rx)) {
|
||||||
|
is.str({sv.begin(), sv.end()});
|
||||||
|
is >> std::chrono::parse("%d %B %Y", db.bulletinDate);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (std::regex_match(sv.begin(), sv.end(), bull_tab_title_rx)) {
|
||||||
|
tab_state = TAB_STATE_START;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // empty string (only spaces)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (db.db.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CURRENT_EARTH_ORIENT_DB = std::move(db);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user