diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index c27e1227b..98d6100e6 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -730,7 +730,184 @@ void override_stream_with_new_data(std::fstream& out, const std::string& filenam } -void add_header_start(std::fstream& out, const std::string& type, const std::string& constellation, const std::string& local_time, const std::string& version) +void add_obs_rinex_version_and_type(std::fstream& out, const std::string& type, const std::string& version) +{ + std::string line; + line += std::string(5, ' '); + line += version; + line += std::string(11, ' '); + line += leftJustify("OBSERVATION DATA", 20); + line += satelliteSystem.at(type); + line += std::string(19, ' '); + line += std::string("RINEX VERSION / TYPE"); + lengthCheck(line); + out << line << '\n'; +} + + +void add_constellation_legend(std::fstream& out, const std::string& constellation_legend) +{ + std::string line; + line += leftJustify(constellation_legend, 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_run_by_line(std::fstream& out, const std::string& local_time) +{ + std::string line; + line += local_time; + line += std::string("PGM / RUN BY / DATE"); + line += std::string(1, ' '); + lengthCheck(line); + out << line << '\n'; +} + + +void add_generated_by_gnss_sdr(std::fstream& out, const std::string& constellation, const std::string& file_type) +{ + std::string line; + line += leftJustify(constellation + " " + file_type + " FILE GENERATED BY GNSS-SDR", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); + out << line << '\n'; +} + +void add_gnss_sdr_version(std::fstream& out) +{ + std::string line; + std::string gnss_sdr_version(GNSS_SDR_VERSION); + line += "GNSS-SDR VERSION "; + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_gnss_sdr_url(std::fstream& out) +{ + std::string line; + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_marker_type(std::fstream& out, const std::string& marker_type, const std::string& marker_type_id) +{ + // -------- Line MARKER TYPE + std::string line; + line += leftJustify(marker_type, 60); // put a flag or a property + line += leftJustify("MARKER " + marker_type_id, 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_marker_name(std::fstream& out) +{ + std::string line; + line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, + line += leftJustify("MARKER NAME", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_obs_observer_agency(std::fstream& out) +{ + // -------- Line OBSERVER / AGENCY + std::string line; + std::string username; +#if ANDROID + username = "ANDROID USER"; +#else + std::array c_username{}; + const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); + if (nGet == 0) + { + username = c_username.data(); + } + else + { + username = "UNKNOWN USER"; + } +#endif + line += leftJustify(username, 20); + line += leftJustify("CTTC", 40); // add flag and property + line += leftJustify("OBSERVER / AGENCY", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_obs_rec_type(std::fstream& out) +{ + std::string line; + std::string gnss_sdr_version(GNSS_SDR_VERSION); + // -------- Line REC / TYPE VERS + line += leftJustify("GNSS-SDR", 20); // add flag and property + line += leftJustify("Software Receiver", 20); // add flag and property + // line += leftJustify(google::VersionString(), 20); // add flag and property + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } + line += leftJustify(gnss_sdr_version, 20); + line += leftJustify("REC # / TYPE / VERS", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_obs_antenna(std::fstream& out) +{ + std::string line; + + // -------- ANTENNA TYPE + line.clear(); + line += leftJustify("Antenna number", 20); // add flag and property + line += leftJustify("Antenna type", 20); // add flag and property + line += std::string(20, ' '); + line += leftJustify("ANT # / TYPE", 20); + lengthCheck(line); + out << line << '\n'; + + // -------- APPROX POSITION (optional for moving platforms) + // put here real data! + double antena_x = 0.0; + double antena_y = 0.0; + double antena_z = 0.0; + line.clear(); + line += rightJustify(asString(antena_x, 4), 14); + line += rightJustify(asString(antena_y, 4), 14); + line += rightJustify(asString(antena_z, 4), 14); + line += std::string(18, ' '); + line += leftJustify("APPROX POSITION XYZ", 20); + lengthCheck(line); + out << line << '\n'; + + // -------- ANTENNA: DELTA H/E/N + // put here real data! + double antena_h = 0.0; + double antena_e = 0.0; + double antena_n = 0.0; + line.clear(); + line += rightJustify(asString(antena_h, 4), 14); + line += rightJustify(asString(antena_e, 4), 14); + line += rightJustify(asString(antena_n, 4), 14); + line += std::string(18, ' '); + line += leftJustify("ANTENNA: DELTA H/E/N", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_navigation_header_start(std::fstream& out, const std::string& type, const std::string& constellation, const std::string& local_time, const std::string& version) { std::string line; @@ -747,37 +924,62 @@ void add_header_start(std::fstream& out, const std::string& type, const std::str out << line << '\n'; // -------- Line 2 - line.clear(); - line += local_time; - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; + add_run_by_line(out, local_time); // -------- Line COMMENT - line.clear(); - line += leftJustify(constellation + " NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_generated_by_gnss_sdr(out, constellation, "NAVIGATION MESSAGE"); // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_version(out); // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_url(out); } +void add_observation_header_start(std::fstream& out, + const std::string& type, + const std::string& constellation, + const std::string& local_time, + const std::string& version, + const std::string& constellation_legend, + const std::string& marker_type = "", + const std::string& marker_type_id = "") +{ + // -------- Line 1 + add_obs_rinex_version_and_type(out, type, version); + + // -------- Line 2 + add_constellation_legend(out, constellation_legend); + + // -------- Line 3 + add_run_by_line(out, local_time); + + // -------- Line COMMENT + add_generated_by_gnss_sdr(out, constellation, "OBSERVATION DATA"); + + // -------- Line COMMENT + add_gnss_sdr_version(out); + + // -------- Line COMMENT + add_gnss_sdr_url(out); + + // -------- Line MARKER NAME + add_marker_name(out); + + // -------- Line MARKER TYPE + if (!marker_type.empty()) + { + add_marker_type(out, marker_type, marker_type_id); + } + + // -------- Line OBSERVER / AGENCY + add_obs_observer_agency(out); + + // -------- Line REC / TYPE VERS + add_obs_rec_type(out); + + add_obs_antenna(out); +} std::string get_iono_line(const std::string& identifier, double value0, double value1, double value2, double value3) { @@ -961,11 +1163,30 @@ std::string get_glonass_to_gps_time_corr_line(const Glonass_Gnav_Utc_Model& utc_ } +std::string get_leap_second_line_v2(const Gps_Utc_Model& utc_model) +{ + std::string line; + line += rightJustify(std::to_string(utc_model.DeltaT_LS), 6); + line += std::string(54, ' '); + line += leftJustify("LEAP SECONDS", 20); + return line; +} + + std::string get_leap_second_line(const Gps_Utc_Model& utc_model) { return get_leap_second_line(utc_model.DeltaT_LS, utc_model.DeltaT_LSF, utc_model.WN_LSF, utc_model.DN); } +std::string get_leap_second_line(const Gps_Utc_Model& utc_model, int32_t version) +{ + if (version == 2) + { + return get_leap_second_line_v2(utc_model); + } + return get_leap_second_line(utc_model); +} + std::string get_leap_second_line(const Gps_CNAV_Utc_Model& utc_model) { @@ -1055,99 +1276,9 @@ std::string get_nav_broadcast_orbit(const double* value0, const double* value1, } -void add_obs_observer_agency(std::fstream& out) -{ - // -------- Line OBSERVER / AGENCY - std::string line; - std::string username; -#if ANDROID - username = "ANDROID USER"; -#else - std::array c_username{}; - const int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1); - if (nGet == 0) - { - username = c_username.data(); - } - else - { - username = "UNKNOWN USER"; - } -#endif - line += leftJustify(username, 20); - line += leftJustify("CTTC", 40); // add flag and property - line += leftJustify("OBSERVER / AGENCY", 20); - lengthCheck(line); - out << line << '\n'; -} - - -void add_obs_rec_type(std::fstream& out, std::string gnss_sdr_version) -{ - std::string line; - - // -------- Line REC / TYPE VERS - line += leftJustify("GNSS-SDR", 20); // add flag and property - line += leftJustify("Software Receiver", 20); // add flag and property - // line += leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += leftJustify(gnss_sdr_version, 20); - line += leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; -} - - -void add_obs_antenna(std::fstream& out) -{ - std::string line; - - // -------- ANTENNA TYPE - line.clear(); - line += leftJustify("Antenna number", 20); // add flag and property - line += leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += leftJustify("ANT # / TYPE", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- APPROX POSITION (optional for moving platforms) - // put here real data! - double antena_x = 0.0; - double antena_y = 0.0; - double antena_z = 0.0; - line.clear(); - line += rightJustify(asString(antena_x, 4), 14); - line += rightJustify(asString(antena_y, 4), 14); - line += rightJustify(asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += leftJustify("APPROX POSITION XYZ", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- ANTENNA: DELTA H/E/N - // put here real data! - double antena_h = 0.0; - double antena_e = 0.0; - double antena_n = 0.0; - line.clear(); - line += rightJustify(asString(antena_h, 4), 14); - line += rightJustify(asString(antena_e, 4), 14); - line += rightJustify(asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += leftJustify("ANTENNA: DELTA H/E/N", 20); - lengthCheck(line); - out << line << '\n'; -} - - void add_obs_signal_strength(std::fstream& out) { std::string line; - line += leftJustify("DBHZ", 20); line += std::string(40, ' '); line += leftJustify("SIGNAL STRENGTH UNIT", 20); @@ -1156,7 +1287,7 @@ void add_obs_signal_strength(std::fstream& out) } -void add_obs_time_first_obs(std::fstream& out, const boost::posix_time::ptime& p_gps_time, double gps_tow) +void add_obs_time_first_obs(std::fstream& out, const std::string& constellation, const boost::posix_time::ptime& p_gps_time, double tow) { const std::string timestring = boost::posix_time::to_iso_string(p_gps_time); const std::string year(timestring, 0, 4); @@ -1164,7 +1295,7 @@ void add_obs_time_first_obs(std::fstream& out, const boost::posix_time::ptime& p const std::string day(timestring, 6, 2); const std::string hour(timestring, 9, 2); const std::string minutes(timestring, 11, 2); - const double seconds = fmod(gps_tow, 60); + const double seconds = fmod(tow, 60); std::string line; line += rightJustify(year, 6); line += rightJustify(month, 6); @@ -1172,7 +1303,7 @@ void add_obs_time_first_obs(std::fstream& out, const boost::posix_time::ptime& p line += rightJustify(hour, 6); line += rightJustify(minutes, 6); line += rightJustify(asString(seconds, 7), 13); - line += rightJustify(std::string("GPS"), 8); + line += rightJustify(constellation, 8); line += std::string(9, ' '); line += leftJustify("TIME OF FIRST OBS", 20); lengthCheck(line); @@ -1188,10 +1319,7 @@ void add_obs_sys_obs_type(std::fstream& out, { // one line per available system std::string line; - if (!sys_char.empty()) - { - line += sys_char; - } + line += sys_char; line += std::string(2, ' '); std::stringstream strm; strm << numberTypesObservations; @@ -1239,9 +1367,7 @@ void add_obs_sys_obs_type(std::fstream& out, } } - const auto satsys = satelliteSystem.find(constellation); - const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; - + const auto& sys_char = satelliteSystem.at(constellation); add_obs_sys_obs_type(out, sys_char, number_of_observations, observationType, obsCodes); } @@ -1304,6 +1430,82 @@ void add_obs_sys_obs_type_beidou(std::fstream& out, add_obs_sys_obs_type(out, "Beidou", bands, observationType, observationCode, band_to_code_map); } + +void add_obs_sys_obs_type_v2(std::fstream& out, + const std::string& codeKey, + const std::map& observationType, + const std::map& observationCode) +{ + std::string line; + std::stringstream strm; + strm << 4; + line += rightJustify(strm.str(), 6); + // per type of observation + line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); + line += observationCode.at(codeKey); + line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); + line += observationCode.at(codeKey); + line += rightJustify(observationType.at("DOPPLER_v2"), 5); + line += observationCode.at(codeKey); + line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); + line += observationCode.at(codeKey); + line += std::string(60 - line.size(), ' '); + line += leftJustify("# / TYPES OF OBSERV", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_obs_glonass_slot_freq(std::fstream& out) +{ + // TODO Need to provide system with list of all satellites and update this accordingly + std::string line; + line += rightJustify(std::to_string(0), 3); // Number of satellites in list + line += std::string(1, ' '); + line += satelliteSystem.at("GLONASS"); + line += rightJustify(std::to_string(0), 2); // Slot Number + line += std::string(1, ' '); + line += rightJustify(std::to_string(0), 2); // Frequency Number + line += std::string(1, ' '); + line += std::string(60 - line.size(), ' '); + line += leftJustify("GLONASS SLOT / FRQ #", 20); + lengthCheck(line); + out << line << '\n'; +} + + +void add_obs_glonass_code_phase_bias(std::fstream& out, + const std::map& observationType, + const std::map& observationCode) +{ + // No GLONASS Phase bias correction used to align code and phase observations. + std::string line; + line += std::string(1, ' '); + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_CA"); + line += std::string(1, ' '); + line += rightJustify(asString(0.0, 3), 8); + line += std::string(1, ' '); + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_P"); + line += std::string(1, ' '); + line += rightJustify(asString(0.0, 3), 8); + line += std::string(1, ' '); + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_CA"); + line += std::string(1, ' '); + line += rightJustify(asString(0.0, 3), 8); + line += std::string(1, ' '); + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_P"); + line += std::string(1, ' '); + line += rightJustify(asString(0.0, 3), 8); + line += std::string(60 - line.size(), ' '); + line += leftJustify("GLONASS COD/PHS/BIS", 20); + lengthCheck(line); + out << line << '\n'; +} + } // namespace @@ -1436,41 +1638,45 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, const auto only_glonass = has_glonass && !(has_gps || has_galileo || has_beidou); const auto only_beidou = has_beidou && !(has_gps || has_galileo || has_glonass); + const bool has_gps_lnav_eph = !pvt_solver->gps_ephemeris_map.empty(); + const bool has_gps_cnav_eph = !pvt_solver->gps_cnav_ephemeris_map.empty(); + const bool has_galileo_eph = !pvt_solver->galileo_ephemeris_map.empty(); + const bool has_glonass_eph = !pvt_solver->glonass_gnav_ephemeris_map.empty(); + const bool has_beidou_dnav_eph = !pvt_solver->beidou_dnav_ephemeris_map.empty(); + if (!d_rinex_header_written) // & we have utc data in nav message! { bool rinex_header_written = true; - if (flags.check_only_enabled(GPS_1C) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + if (flags.check_only_enabled(GPS_1C) && has_gps_lnav_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, rx_time); rinex_nav_header(navFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second); output_navfilename.push_back(navfilename); log_rinex_nav(navFile, pvt_solver->gps_ephemeris_map); } - else if ((flags.check_only_enabled(GPS_2S) || flags.check_only_enabled(GPS_L5)) && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + else if ((flags.check_only_enabled(GPS_2S) || flags.check_only_enabled(GPS_L5)) && has_gps_cnav_eph) { rinex_obs_header(obsFile, gps_cnav_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model); output_navfilename.push_back(navfilename); log_rinex_nav(navFile, pvt_solver->gps_cnav_ephemeris_map); } - else if (only_galileo && galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + else if (only_galileo && has_galileo_eph) { rinex_obs_header(obsFile, galileo_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); output_navfilename.push_back(navGalfilename); log_rinex_nav(navGalFile, pvt_solver->galileo_ephemeris_map); } - else if (only_glonass && glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + else if (only_glonass && has_glonass_eph) { rinex_obs_header(obsFile, glonass_gnav_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navGloFile, pvt_solver->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); output_navfilename.push_back(navGlofilename); log_rinex_nav(navGloFile, pvt_solver->glonass_gnav_ephemeris_map); } - else if (only_beidou && beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend()) + else if (only_beidou && has_beidou_dnav_eph) { rinex_obs_header(obsFile, beidou_dnav_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navBdsFile, pvt_solver->beidou_dnav_iono, pvt_solver->beidou_dnav_utc_model); @@ -1480,8 +1686,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, else if ((flags.check_only_enabled(GPS_1C, GPS_2S) || flags.check_only_enabled(GPS_1C, GPS_L5) || flags.check_only_enabled(GPS_1C, GPS_2S, GPS_L5)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + has_gps_lnav_eph && has_gps_cnav_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second); @@ -1497,8 +1702,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, } } else if ((flags.check_only_enabled(GPS_1C, GAL_1B) || flags.check_only_enabled(GPS_1C, GAL_E5a) || flags.check_only_enabled(GPS_1C, GAL_E5b)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + has_gps_lnav_eph && has_galileo_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -1506,8 +1710,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, log_rinex_nav(navMixFile, pvt_solver->gps_ephemeris_map, pvt_solver->galileo_ephemeris_map); } else if (flags.check_only_enabled(GPS_L5, GAL_E5a) && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + has_gps_cnav_eph && has_galileo_eph) { rinex_obs_header(obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, signal, signal); rinex_nav_header(navMixFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); @@ -1515,8 +1718,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, log_rinex_nav(navMixFile, pvt_solver->gps_cnav_ephemeris_map, pvt_solver->galileo_ephemeris_map); } else if ((flags.check_only_enabled(GPS_1C, GLO_1G) || flags.check_only_enabled(GPS_1C, GLO_2G)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + has_gps_lnav_eph && has_glonass_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, signal); if (d_version == 3) @@ -1536,8 +1738,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, } } else if ((flags.check_only_enabled(GLO_1G, GPS_2S) || flags.check_only_enabled(GLO_2G, GPS_2S)) && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend() && - glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + has_gps_cnav_eph && has_glonass_eph) { rinex_obs_header(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navMixFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1545,8 +1746,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, log_rinex_nav(navMixFile, pvt_solver->gps_cnav_ephemeris_map, pvt_solver->glonass_gnav_ephemeris_map); } else if ((flags.check_only_enabled(GAL_1B, GLO_1G) || flags.check_only_enabled(GAL_1B, GLO_2G)) && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend() && - glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + has_galileo_eph && has_glonass_eph) { rinex_obs_header(obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, signal, signal); rinex_nav_header(navMixFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); @@ -1556,28 +1756,23 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, else if ((flags.check_only_enabled(GPS_1C, GAL_1B, GPS_L5, GAL_E5a) || flags.check_only_enabled(GPS_1C, GAL_1B, GPS_L5, GAL_E5a, GAL_E6) || flags.check_only_enabled(GPS_1C, GAL_1B, GPS_2S, GPS_L5, GAL_E5a)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + has_gps_lnav_eph && has_gps_cnav_eph && has_galileo_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, signal, signal); rinex_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); output_navfilename.push_back(navMixfilename); log_rinex_nav(navMixFile, pvt_solver->gps_ephemeris_map, pvt_solver->galileo_ephemeris_map); } - else if ((flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E5a) || flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E5b)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + else if ((flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E5a) || flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E5b)) && has_gps_lnav_eph && has_galileo_eph) { rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, signal); rinex_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); output_navfilename.push_back(navMixfilename); log_rinex_nav(navMixFile, pvt_solver->gps_ephemeris_map, pvt_solver->galileo_ephemeris_map); } - else if (flags.check_only_enabled(GPS_1C, GAL_E6) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + else if (flags.check_only_enabled(GPS_1C, GAL_E6) && has_gps_lnav_eph) { - if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + if (has_galileo_eph) { // we have Galileo ephemeris, maybe from assistance rinex_obs_header(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, signal); @@ -1594,7 +1789,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, log_rinex_nav(navFile, pvt_solver->gps_ephemeris_map); } } - else if (has_beidou && beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend()) + else if (has_beidou && has_beidou_dnav_eph) { rinex_obs_header(obsFile, beidou_dnav_ephemeris_iter->second, rx_time, signal); // Not implemented for beidou @@ -1609,44 +1804,39 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, if (d_rinex_header_written && flag_write_RINEX_obs_output) // The header is already written, we can now log the navigation message data { - if (flags.check_only_enabled(GPS_1C) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + if (flags.check_only_enabled(GPS_1C) && has_gps_lnav_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); d_rinex_header_updated = true; } } - else if (flags.check_only_enabled(GPS_1C, GPS_2S) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + else if (flags.check_only_enabled(GPS_1C, GPS_2S) && has_gps_lnav_eph && has_gps_cnav_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); d_rinex_header_updated = true; } } - else if (flags.check_only_enabled(GPS_1C, GPS_L5) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + else if (flags.check_only_enabled(GPS_1C, GPS_L5) && has_gps_lnav_eph && has_gps_cnav_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && ((pvt_solver->gps_cnav_utc_model.A0 != 0) || (pvt_solver->gps_utc_model.A0 != 0))) { if (pvt_solver->gps_cnav_utc_model.A0 != 0) { - update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_cnav_utc_model)); update_nav_header(navFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono); } else { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); } d_rinex_header_updated = true; @@ -1654,150 +1844,144 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, } else if (flags.check_only_enabled(GPS_2S) || flags.check_only_enabled(GPS_L5) || flags.check_only_enabled(GPS_2S, GPS_L5)) { - if (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + if (has_gps_cnav_eph) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map); } if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_cnav_utc_model)); update_nav_header(navFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono); d_rinex_header_updated = true; } } else if (flags.check_only_enabled(GPS_1C, GPS_2S, GPS_L5)) { - if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + if (has_gps_lnav_eph && has_gps_cnav_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, rx_time, gnss_observables_map, true); } - if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (has_gps_lnav_eph)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); d_rinex_header_updated = true; } } else if (only_galileo) { - if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + if (has_galileo_eph) { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, signal); } if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { update_nav_header(navGalFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); - update_obs_header(obsFile, pvt_solver->galileo_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->galileo_utc_model)); d_rinex_header_updated = true; } } else if (only_glonass) { - if (glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + if (has_glonass_eph) { log_rinex_obs(obsFile, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map, signal); } if (!d_rinex_header_updated && (pvt_solver->glonass_gnav_utc_model.d_tau_c != 0)) { update_nav_header(navGloFile, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); - update_obs_header(obsFile, pvt_solver->glonass_gnav_utc_model); d_rinex_header_updated = true; } } else if (only_beidou) { - if (beidou_dnav_ephemeris_iter != pvt_solver->beidou_dnav_ephemeris_map.cend()) + if (has_beidou_dnav_eph) { log_rinex_obs(obsFile, beidou_dnav_ephemeris_iter->second, rx_time, gnss_observables_map, signal); } if (!d_rinex_header_updated && (pvt_solver->beidou_dnav_utc_model.A0_UTC != 0)) { - update_obs_header(obsFile, pvt_solver->beidou_dnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->beidou_dnav_utc_model)); update_nav_header(navBdsFile, pvt_solver->beidou_dnav_utc_model, pvt_solver->beidou_dnav_iono); d_rinex_header_updated = true; } } else if ((flags.check_only_enabled(GPS_1C, GAL_1B) || flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E6)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + has_gps_lnav_eph && has_galileo_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); d_rinex_header_updated = true; } } else if ((flags.check_only_enabled(GPS_1C, GLO_1G) || flags.check_only_enabled(GPS_1C, GLO_2G)) && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) + has_gps_lnav_eph && has_glonass_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); d_rinex_header_updated = true; // do not write header anymore } } else if (flags.check_only_enabled(GPS_L5, GAL_E5a)) { - if ((gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((has_gps_cnav_eph) && (has_galileo_eph)) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); } if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_cnav_utc_model)); update_nav_header(navMixFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); d_rinex_header_updated = true; // do not write header anymore } } else if (flags.check_only_enabled(GAL_1B, GLO_1G) || flags.check_only_enabled(GAL_1B, GLO_2G)) { - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend())) + if ((has_glonass_eph) && (has_galileo_eph)) { log_rinex_obs(obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } if (!d_rinex_header_updated && (pvt_solver->galileo_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->galileo_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->galileo_utc_model)); update_nav_header(navMixFile, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); d_rinex_header_updated = true; // do not write header anymore } } else if (flags.check_only_enabled(GPS_2S, GLO_1G) || flags.check_only_enabled(GPS_2S, GLO_2G)) { - if ((glonass_gnav_ephemeris_iter != pvt_solver->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend())) + if ((has_glonass_eph) && (has_gps_cnav_eph)) { log_rinex_obs(obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, rx_time, gnss_observables_map); } if (!d_rinex_header_updated && (pvt_solver->gps_cnav_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_cnav_utc_model)); update_nav_header(navMixFile, pvt_solver->gps_cnav_iono, pvt_solver->gps_cnav_utc_model, pvt_solver->glonass_gnav_utc_model, pvt_solver->glonass_gnav_almanac); d_rinex_header_updated = true; // do not write header anymore } } else if (flags.check_only_enabled(GPS_1C, GAL_1B, GPS_L5, GAL_E5a)) { - if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + if (has_gps_lnav_eph && has_gps_cnav_eph && has_galileo_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && ((pvt_solver->gps_cnav_utc_model.A0 != 0) || (pvt_solver->gps_utc_model.A0 != 0)) && (pvt_solver->galileo_utc_model.A0 != 0)) { if (pvt_solver->gps_cnav_utc_model.A0 != 0) { - update_obs_header(obsFile, pvt_solver->gps_cnav_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_cnav_utc_model)); update_nav_header(navMixFile, pvt_solver->gps_cnav_utc_model, pvt_solver->gps_cnav_iono, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); } else { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); } d_rinex_header_updated = true; // do not write header anymore @@ -1806,13 +1990,12 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, } else if (flags.check_only_enabled(GPS_1C, GAL_1B, GAL_E5a)) { - if (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + if (has_gps_lnav_eph && has_galileo_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); d_rinex_header_updated = true; // do not write header anymore } @@ -1820,28 +2003,26 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, } else if (flags.check_only_enabled(GPS_1C, GAL_1B, GPS_L5, GAL_E5a, GAL_E6) || flags.check_only_enabled(GPS_1C, GAL_1B, GPS_2S, GPS_L5, GAL_E5a)) { - if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend() && - gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend() && - gps_cnav_ephemeris_iter != pvt_solver->gps_cnav_ephemeris_map.cend()) + if (has_galileo_eph && has_gps_lnav_eph && has_gps_cnav_eph) { log_rinex_obs(obsFile, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map, true); } - if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0) && (gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend())) + if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0) && (pvt_solver->galileo_utc_model.A0 != 0) && (has_gps_lnav_eph)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); d_rinex_header_updated = true; } } - else if (flags.check_only_enabled(GPS_1C, GAL_E6) && gps_ephemeris_iter != pvt_solver->gps_ephemeris_map.cend()) + else if (flags.check_only_enabled(GPS_1C, GAL_E6) && has_gps_lnav_eph) { - if (galileo_ephemeris_iter != pvt_solver->galileo_ephemeris_map.cend()) + if (has_galileo_eph) { // we have Galileo ephemeris, maybe from assistance log_rinex_obs(obsFile, gps_ephemeris_iter->second, galileo_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navMixFile, pvt_solver->gps_iono, pvt_solver->gps_utc_model, gps_ephemeris_iter->second, pvt_solver->galileo_iono, pvt_solver->galileo_utc_model); d_rinex_header_updated = true; } @@ -1852,7 +2033,7 @@ void Rinex_Printer::print_rinex_annotation(const Rtklib_Solver* pvt_solver, log_rinex_obs(obsFile, gps_ephemeris_iter->second, rx_time, gnss_observables_map); if (!d_rinex_header_updated && (pvt_solver->gps_utc_model.A0 != 0)) { - update_obs_header(obsFile, pvt_solver->gps_utc_model); + update_obs_header(obsFile, get_leap_second_line(pvt_solver->gps_utc_model, d_version)); update_nav_header(navFile, pvt_solver->gps_utc_model, pvt_solver->gps_iono, gps_ephemeris_iter->second); d_rinex_header_updated = true; } @@ -2127,7 +2308,7 @@ std::string Rinex_Printer::getLocalTime() const void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model, const Glonass_Gnav_Ephemeris& glonass_gnav_eph) { - add_header_start(out, "R: GLONASS", "GLONASS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "R: GLONASS", "GLONASS", Rinex_Printer::getLocalTime(), d_stringVersion); std::string line; @@ -2174,7 +2355,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono d_stringVersion = "3.02"; d_version = 3; - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_gps_iono_alpha_line(gps_iono) << '\n'; @@ -2204,7 +2385,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps d_stringVersion = "3.02"; d_version = 3; - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_gps_iono_alpha_line(gps_iono) << '\n'; @@ -2232,7 +2413,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali { } // Avoid compiler warning - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; @@ -2253,7 +2434,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model) const { - add_header_start(out, "E: GALILEO", "GALILEO", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "E: GALILEO", "GALILEO", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_galileo_iono_alpha_line(iono) << '\n'; @@ -2274,7 +2455,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& iono, const Gps_CNAV_Utc_Model& utc_model) const { - add_header_start(out, "G: GPS", "GPS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "G: GPS", "GPS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_gps_iono_alpha_line(iono) << '\n'; @@ -2295,7 +2476,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& ion void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& iono, const Gps_CNAV_Utc_Model& utc_model, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) const { - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; @@ -2350,35 +2531,16 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co out << line << '\n'; // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; + add_run_by_line(out, Rinex_Printer::getLocalTime()); // -------- Line 3 - line.clear(); - line += leftJustify("GPS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_generated_by_gnss_sdr(out, "GPS", "NAVIGATION MESSAGE"); // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_version(out); // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_url(out); // -------- Line ionospheric info 1 line.clear(); @@ -2500,7 +2662,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Gps_Ephemeris& eph, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) const { - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; @@ -2527,7 +2689,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& iono, const Beidou_Dnav_Utc_Model& utc_model) const { - add_header_start(out, "F: BDS", "BDS", Rinex_Printer::getLocalTime(), d_stringVersion); // TODO version handling + add_navigation_header_start(out, "F: BDS", "BDS", Rinex_Printer::getLocalTime(), d_stringVersion); // TODO version handling // -------- Line ionospheric info 1, only version 3 supported out << get_beidou_iono_alpha_line(iono) << '\n'; @@ -2548,7 +2710,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono, const Gps_Utc_Model& gps_utc_model, const Gps_Ephemeris& gps_eph, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) const { - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; @@ -2578,7 +2740,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps d_stringVersion = "3.02"; d_version = 3; - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; @@ -2605,7 +2767,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_Model& glo_gnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) const { - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; @@ -2629,7 +2791,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) const { - add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); + add_navigation_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; @@ -2755,20 +2917,10 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const out << line << '\n'; // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_version(out); // -------- Line COMMENT 2 - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; + add_gnss_sdr_url(out); // -------- End of Header out << get_end_of_header_line() << '\n'; @@ -3430,8 +3582,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_M void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; - const auto satsys = satelliteSystem.find("GPS"); - const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; + const auto sys_char = satelliteSystem.at("GPS"); for (const auto& gps_ephemeris_iter : eph_map) { @@ -3651,8 +3802,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { - const auto satsys = satelliteSystem.find("GPS"); - const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; + const auto sys_char = satelliteSystem.at("GPS"); for (const auto& gps_ephemeris_iter : eph_map) { @@ -3714,8 +3864,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - const auto satsys_gal = satelliteSystem.find("Galileo"); - const auto sys_char = satsys_gal != satelliteSystem.cend() ? satsys_gal->second : ""; + const auto sys_char = satelliteSystem.at("Galileo"); for (const auto& galileo_ephemeris_iter : eph_map) { @@ -3801,8 +3950,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; - const auto satsys = satelliteSystem.find("GLONASS"); - const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; + const auto sys_char = satelliteSystem.at("GLONASS"); for (const auto& glonass_gnav_ephemeris_iter : eph_map) { @@ -3951,8 +4099,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - const auto satsys_bds = satelliteSystem.find("Beidou"); - const auto sys_char = satsys_bds != satelliteSystem.cend() ? satsys_bds->second : ""; + const auto sys_char = satelliteSystem.at("Beidou"); for (const auto& bds_ephemeris_iter : eph_map) { @@ -3993,104 +4140,24 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map 0.0) - { - } // Avoid compiler warning std::string line; std::map::const_iterator glonass_gnav_ephemeris_iter; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_glo = satelliteSystem.find("GLONASS"); - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; + std::string constellation_legend; + std::string marker_type_id; - // -------- Line 2 - line.clear(); if (d_version == 2) { - line += leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); + constellation_legend = "BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED"; + marker_type_id = "NUMBER"; } if (d_version == 3) { - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - } - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("GLONASS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - if (d_version == 2) - { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER NUMBER", 20); - lengthCheck(line); - out << line << '\n'; - } - if (d_version == 3) - { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER TYPE", 20); - lengthCheck(line); - out << line << '\n'; + constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + marker_type_id = "TYPE"; } - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + add_observation_header_start(out, "GLONASS", "GLONASS", Rinex_Printer::getLocalTime(), d_stringVersion, constellation_legend, "GROUND_CRAFT", marker_type_id); // -------- SYS / OBS TYPES if (d_version == 3) @@ -4101,27 +4168,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem if (d_version == 2) { // -------- SYS / OBS TYPES - line.clear(); - std::stringstream strm; - strm << 4; - line += rightJustify(strm.str(), 6); - // per type of observation - // GLONASS L1 C/A PSEUDORANGE - line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS L1 PHASE - line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS DOPPLER L1 - line += rightJustify(observationType.at("DOPPLER_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS L1 SIGNAL STRENGTH - line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - line += std::string(60 - line.size(), ' '); - line += leftJustify("# / TYPES OF OBSERV", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_v2(out, "GLONASS_G1_CA_v2", observationType, observationCode); } // -------- Signal Strength units (Only version 3) @@ -4131,77 +4178,19 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem } // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_UTC_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - const std::string year(timestring, 0, 4); - const std::string month(timestring, 4, 2); - const std::string day(timestring, 6, 2); - const std::string hour(timestring, 9, 2); - const std::string minutes(timestring, 11, 2); double intpart = 0; + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_UTC_time(eph, d_TOW_first_observation); const double seconds = p_utc_time.time_of_day().seconds() + modf(d_TOW_first_observation, &intpart); - line.clear(); - line += rightJustify(year, 6); - line += rightJustify(month, 6); - line += rightJustify(day, 6); - line += rightJustify(hour, 6); - line += rightJustify(minutes, 6); - line += rightJustify(asString(seconds, 7), 13); - line += rightJustify(std::string("GLO"), 8); - line += std::string(9, ' '); - line += leftJustify("TIME OF FIRST OBS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, "GLO", p_utc_time, seconds); // -------- GLONASS SLOT / FRQ # (On;y d_version 3) if (d_version == 3) { // -------- GLONASS SLOT / FRQ # - // TODO Need to provide system with list of all satellites and update this accordingly - line.clear(); - line += rightJustify(std::to_string(0), 3); // Number of satellites in list - line += std::string(1, ' '); - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += rightJustify(std::to_string(0), 2); // Slot Number - line += std::string(1, ' '); - line += rightJustify(std::to_string(0), 2); // Frequency Number - line += std::string(1, ' '); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS SLOT / FRQ #", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_slot_freq(out); // -------- GLONASS CODE/PHS/BIS - // No GLONASS Phase bias correction used to align code and phase observations. - line.clear(); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS COD/PHS/BIS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_code_phase_bias(out, observationType, observationCode); } // -------- END OF HEADER @@ -4209,99 +4198,22 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double d_TOW_first_observation, const std::string& glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Glonass_Gnav_Ephemeris& /*glonass_gnav_eph*/, double d_TOW_first_observation, const std::string& glonass_bands) { - if (glonass_gnav_eph.d_m > 0.0) - { - } // avoid warning, not needed std::string line; + std::string marker_type_id; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GPS/GLO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME / TYPE if (d_version == 2) { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER NUMBER", 20); - lengthCheck(line); - out << line << '\n'; + marker_type_id = "NUMBER"; } - if (d_version == 3) + else if (d_version == 3) { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER TYPE", 20); - lengthCheck(line); - out << line << '\n'; + marker_type_id = "TYPE"; } - // -------- Line MARKER TYPE - line.clear(); - line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER TYPE", 20); - lengthCheck(line); - out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GPS/GLO)", Rinex_Printer::getLocalTime(), d_stringVersion, constellation_legend, "GROUND_CRAFT", marker_type_id); // -------- SYS / OBS TYPES if (d_version == 3) @@ -4315,27 +4227,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps if (d_version == 2) { // -------- SYS / OBS TYPES - line.clear(); - std::stringstream strm; - strm << 4; - line += rightJustify(strm.str(), 6); - // per type of observation - // GLONASS L1 C/A PSEUDORANGE - line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS L1 PHASE - line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS DOPPLER L1 - line += rightJustify(observationType.at("DOPPLER_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - // GLONASS L1 SIGNAL STRENGTH - line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); - line += observationCode.at("GLONASS_G1_CA_v2"); - line += std::string(60 - line.size(), ' '); - line += leftJustify("# / TYPES OF OBSERV", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_v2(out, "GLONASS_G1_CA_v2", observationType, observationCode); } // -------- Signal Strength units (only version 3) @@ -4345,58 +4237,16 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation), d_TOW_first_observation); // -------- GLONASS SLOT / FRQ # (On;y version 3) if (d_version == 3) { // -------- GLONASS SLOT / FRQ # - // TODO Need to provide system with list of all satellites and update this accordingly - line.clear(); - line += rightJustify(std::to_string(0), 3); // Number of satellites in list - line += std::string(1, ' '); - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += rightJustify(std::to_string(0), 2); // Slot Number - line += std::string(1, ' '); - line += rightJustify(std::to_string(0), 2); // Frequency Number - line += std::string(1, ' '); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS SLOT / FRQ #", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_slot_freq(out); // -------- GLONASS CODE/PHS/BIS - // No GLONASS Phase bias correction used to align code and phase observations. - line.clear(); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS COD/PHS/BIS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_code_phase_bias(out, observationType, observationCode); } // -------- end of header @@ -4404,98 +4254,22 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double d_TOW_first_observation, const std::string& glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& gps_cnav_eph, const Glonass_Gnav_Ephemeris& /*glonass_gnav_eph*/, double d_TOW_first_observation, const std::string& glonass_bands) { - if (glonass_gnav_eph.d_m > 0.0) - { - } // avoid warning, not needed std::string line; + std::string marker_type_id; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GPS/GLO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NUMBER / TYPE if (d_version == 2) { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER NUMBER", 20); - lengthCheck(line); - out << line << '\n'; + marker_type_id = "NUMBER"; } - if (d_version == 3) + else if (d_version == 3) { - line.clear(); - line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER TYPE", 20); - lengthCheck(line); - out << line << '\n'; + marker_type_id = "TYPE"; } - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GPS/GLO)", Rinex_Printer::getLocalTime(), d_stringVersion, constellation_legend, "GROUND_CRAFT", marker_type_id); // -------- SYS / OBS TYPES @@ -4509,143 +4283,25 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); - + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation), d_TOW_first_observation); // -------- GLONASS SLOT / FRQ # - // TODO Need to provide system with list of all satellites and update this accordingly - line.clear(); - line += rightJustify(std::to_string(0), 3); // Number of satellites in list - line += std::string(1, ' '); - const auto satsys_glo = satelliteSystem.find("GLONASS"); - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } - line += rightJustify(std::to_string(0), 2); // Slot Number - line += std::string(1, ' '); - line += rightJustify(std::to_string(0), 2); // Frequency Number - line += std::string(1, ' '); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS SLOT / FRQ #", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_slot_freq(out); // -------- GLONASS CODE/PHS/BIS - // No GLONASS Phase bias correction used to align code and phase observations. - line.clear(); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G1_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_CA"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(1, ' '); - line += observationType.at("PSEUDORANGE"); - line += observationCode.at("GLONASS_G2_P"); - line += std::string(1, ' '); - line += rightJustify(asString(0.0, 3), 8); - line += std::string(60 - line.size(), ' '); - line += leftJustify("GLONASS COD/PHS/BIS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_glonass_code_phase_bias(out, observationType, observationCode); // -------- end of header out << get_end_of_header_line() << '\n'; } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& glonass_gnav_eph, double d_TOW_first_observation, const std::string& galileo_bands, const std::string& glonass_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& galileo_eph, const Glonass_Gnav_Ephemeris& /*glonass_gnav_eph*/, double d_TOW_first_observation, const std::string& galileo_bands, const std::string& glonass_bands) { - if (glonass_gnav_eph.d_m > 0.0) - { - } // avoid warning, not needed - std::string line; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += "3.02"; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GALILEO/GLONASS) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - line.clear(); - line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - line += std::string(40, ' '); - line += leftJustify("MARKER TYPE", 20); - lengthCheck(line); - out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GALILEO/GLONASS)", Rinex_Printer::getLocalTime(), "3.02", constellation_legend, "NON_GEODETIC", "TYPE"); // -------- SYS / OBS TYPES @@ -4659,27 +4315,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); - const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(galileo_eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); - const std::string year(timestring, 0, 4); - const std::string month(timestring, 4, 2); - const std::string day(timestring, 6, 2); - const std::string hour(timestring, 9, 2); - const std::string minutes(timestring, 11, 2); - const double galileo_t = d_TOW_first_observation; - const double seconds = fmod(galileo_t, 60); - line += rightJustify(year, 6); - line += rightJustify(month, 6); - line += rightJustify(day, 6); - line += rightJustify(hour, 6); - line += rightJustify(minutes, 6); - line += rightJustify(asString(seconds, 7), 13); - line += rightJustify(std::string("Galileo"), 8); - line += std::string(9, ' '); - line += leftJustify("TIME OF FIRST OBS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, "Galileo", Rinex_Printer::compute_Galileo_time(galileo_eph, d_TOW_first_observation), d_TOW_first_observation); // -------- end of header out << get_end_of_header_line() << '\n'; @@ -4689,87 +4325,18 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, double d_TOW_first_observation) { std::string line; + std::string constellation_legend; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); if (d_version == 2) { - line += leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); + constellation_legend = "BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED"; } if (d_version == 3) { - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; } - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + add_observation_header_start(out, "GPS", "GPS", Rinex_Printer::getLocalTime(), "3.02", constellation_legend, "NON_GEODETIC", "TYPE"); if (d_version == 2) { @@ -4793,27 +4360,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph if (d_version == 2) { // -------- SYS / OBS TYPES - line.clear(); - std::stringstream strm; - strm << 4; - line += rightJustify(strm.str(), 6); - // per type of observation - // GPS L1 PSEUDORANGE - line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); - line += observationCode.at("GPS_L1_CA_v2"); - // GPS L1 PHASE - line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); - line += observationCode.at("GPS_L1_CA_v2"); - // GPS DOPPLER L1 - line += rightJustify(observationType.at("DOPPLER_v2"), 5); - line += observationCode.at("GPS_L1_CA_v2"); - // GPS L1 SIGNAL STRENGTH - line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); - line += observationCode.at("GPS_L1_CA_v2"); - line += std::string(60 - line.size(), ' '); - line += leftJustify("# / TYPES OF OBSERV", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_v2(out, "GPS_L1_CA_v2", observationType, observationCode); } if (d_version == 3) @@ -4823,9 +4370,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); - + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation), d_TOW_first_observation); // -------- SYS /PHASE SHIFTS @@ -4836,81 +4381,8 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph, double d_TOW_first_observation, const std::string& gps_bands) { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "GPS", "GPS", Rinex_Printer::getLocalTime(), d_stringVersion, constellation_legend); // -------- SYS / OBS TYPES add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); @@ -4919,9 +4391,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); - + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation), d_TOW_first_observation); // -------- SYS /PHASE SHIFTS @@ -4930,86 +4400,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& eph_cnav, double d_TOW_first_observation, const std::string& gps_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph, const Gps_CNAV_Ephemeris& /*eph_cnav*/, double d_TOW_first_observation, const std::string& gps_bands) { - if (eph_cnav.i_0 > 0.0) - { - } // avoid warning, not needed - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "GPS", "GPS", Rinex_Printer::getLocalTime(), d_stringVersion, constellation_legend); // -------- SYS / OBS TYPES add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); @@ -5018,8 +4412,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation), d_TOW_first_observation); // -------- SYS /PHASE SHIFTS @@ -5028,92 +4421,12 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& eph_cnav, const Galileo_Ephemeris& galileo_eph, double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Gps_CNAV_Ephemeris& /*eph_cnav*/, const Galileo_Ephemeris& /*galileo_eph*/, double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) { - std::string line; d_version = 3; - if (eph_cnav.ecc == 0) - { - // avoid warning - } - if (galileo_eph.ecc == 0) - { - // avoid warning - } - // -------- Line 1 - line = std::string(5, ' '); - line += "3.02"; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GPS/GALILEO)", Rinex_Printer::getLocalTime(), "3.02", constellation_legend); // -------- SYS / OBS TYPES @@ -5127,95 +4440,19 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation), d_TOW_first_observation); // -------- end of header out << get_end_of_header_line() << '\n'; } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph_cnav, const Galileo_Ephemeris& galileo_eph, double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris& eph_cnav, const Galileo_Ephemeris& /*galileo_eph*/, double d_TOW_first_observation, const std::string& gps_bands, const std::string& galileo_bands) { - std::string line; d_version = 3; - if (galileo_eph.ecc == 0) - { - // avoid warning - } - // -------- Line 1 - line = std::string(5, ' '); - line += "3.02"; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GPS/GALILEO)", Rinex_Printer::getLocalTime(), "3.02", constellation_legend); // -------- SYS / OBS TYPES @@ -5229,8 +4466,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation), d_TOW_first_observation); // -------- end of header out << get_end_of_header_line() << '\n'; @@ -5239,89 +4475,11 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& eph, double d_TOW_first_observation, const std::string& bands) { - std::string line; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - if (bands.find("E6") != std::string::npos) - { - line += "3.05"; - } - else - { - line += "3.02"; - } - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys = satelliteSystem.find("Galileo"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("GALILEO OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string version = bands.find("E6") != std::string::npos ? "3.05" : "3.02"; + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Galileo", "GALILEO", Rinex_Printer::getLocalTime(), version, constellation_legend); // -------- SYS / OBS TYPES @@ -5331,27 +4489,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); - const boost::posix_time::ptime p_galileo_time = Rinex_Printer::compute_Galileo_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_galileo_time); - const std::string year(timestring, 0, 4); - const std::string month(timestring, 4, 2); - const std::string day(timestring, 6, 2); - const std::string hour(timestring, 9, 2); - const std::string minutes(timestring, 11, 2); - const double galileo_t = d_TOW_first_observation; - const double seconds = fmod(galileo_t, 60); - line += rightJustify(year, 6); - line += rightJustify(month, 6); - line += rightJustify(day, 6); - line += rightJustify(hour, 6); - line += rightJustify(minutes, 6); - line += rightJustify(asString(seconds, 7), 13); - line += rightJustify(std::string("GAL"), 8); - line += std::string(9, ' '); - line += leftJustify("TIME OF FIRST OBS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, "GAL", Rinex_Printer::compute_Galileo_time(eph, d_TOW_first_observation), d_TOW_first_observation); // -------- SYS /PHASE SHIFTS @@ -5360,87 +4498,12 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } -void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& galileo_eph, double d_TOW_first_observation, const std::string& galileo_bands) +void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps_eph, const Galileo_Ephemeris& /*galileo_eph*/, double d_TOW_first_observation, const std::string& galileo_bands) { - if (galileo_eph.ecc > 0.0) - { - } // avoid warning, not needed - std::string line; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += "3.02"; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_mix = satelliteSystem.find("Mixed"); - if (satsys_mix != satelliteSystem.cend()) - { - line += satsys_mix->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER TYPE - // line.clear(); - // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property - // line += std::string(40, ' '); - // line += leftJustify("MARKER TYPE", 20); - // lengthCheck(line); - // out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED"; + add_observation_header_start(out, "Mixed", "MIXED (GPS/GALILEO)", Rinex_Printer::getLocalTime(), "3.02", constellation_legend); // -------- SYS / OBS TYPES @@ -5454,8 +4517,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + add_obs_time_first_obs(out, "GPS", Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation), d_TOW_first_observation); // -------- end of header out << get_end_of_header_line() << '\n'; @@ -5464,74 +4526,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Ephemeris& eph, double d_TOW_first_observation, const std::string& bands) { - std::string line; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += "3.02"; - line += std::string(11, ' '); - line += leftJustify("OBSERVATION DATA", 20); - const auto satsys_bds = satelliteSystem.find("Beidou"); - if (satsys_bds != satelliteSystem.cend()) - { - line += satsys_bds->second; - } - line += std::string(19, ' '); - line += std::string("RINEX VERSION / TYPE"); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += leftJustify("G = GPS R = GLONASS E = GALILEO C = BEIDOU S = GEO M = MIXED", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("BEIDOU OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += leftJustify(gnss_sdr_version, 43); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += leftJustify("See https://gnss-sdr.org", 60); - line += leftJustify("COMMENT", 20); - lengthCheck(line); - out << line << '\n'; - - // -------- Line MARKER NAME - line.clear(); - line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += leftJustify("MARKER NAME", 20); - lengthCheck(line); - out << line << '\n'; - - add_obs_observer_agency(out); - - add_obs_rec_type(out, std::move(gnss_sdr_version)); - - add_obs_antenna(out); + const std::string constellation_legend = "G = GPS R = GLONASS E = GALILEO C = BEIDOU M = MIXED"; + add_observation_header_start(out, "Beidou", "BEIDOU", Rinex_Printer::getLocalTime(), "3.02", constellation_legend); // -------- SYS / OBS TYPES add_obs_sys_obs_type_beidou(out, bands, observationType, observationCode); @@ -5540,27 +4538,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); - const boost::posix_time::ptime p_bds_time = Rinex_Printer::compute_BDS_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_bds_time); - const std::string year(timestring, 0, 4); - const std::string month(timestring, 4, 2); - const std::string day(timestring, 6, 2); - const std::string hour(timestring, 9, 2); - const std::string minutes(timestring, 11, 2); - double beidou_t = d_TOW_first_observation; - const double seconds = fmod(beidou_t, 60); - line += rightJustify(year, 6); - line += rightJustify(month, 6); - line += rightJustify(day, 6); - line += rightJustify(hour, 6); - line += rightJustify(minutes, 6); - line += rightJustify(asString(seconds, 7), 13); - line += rightJustify(std::string("BDT"), 8); - line += std::string(9, ' '); - line += leftJustify("TIME OF FIRST OBS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, "BDT", Rinex_Printer::compute_BDS_time(eph, d_TOW_first_observation), d_TOW_first_observation); // -------- SYS /PHASE SHIFTS @@ -5569,199 +4547,29 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme } -void Rinex_Printer::update_obs_header(std::fstream& out __attribute__((unused)), const Glonass_Gnav_Utc_Model& utc_model) const +void Rinex_Printer::update_obs_header(std::fstream& out, const std::string& leap_second_line) const { - if (utc_model.d_N_4 > 0.0) - { - // do nothing - } -} - - -void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& utc_model) const -{ - std::vector data; - std::string line_aux; - out.seekp(0); - data.clear(); + std::vector data; bool no_more_finds = false; std::string line_str; while (!out.eof()) { std::getline(out, line_str); + data.push_back(line_str); if (!no_more_finds) { - line_aux.clear(); - - if (d_version == 2) + if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) // TIME OF FIRST OBS last header annotation might change in the future { - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) // TIME OF FIRST OBS last header annotation might change in the future - { - data.push_back(line_str); - line_aux += rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += std::string(54, ' '); - line_aux += leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); - } - else if (line_str.find("END OF HEADER", 59) != std::string::npos) - { - data.push_back(line_str); - no_more_finds = true; - } - else - { - data.push_back(line_str); - } - } - - if (d_version == 3) - { - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) - { - data.push_back(line_str); - data.push_back(get_leap_second_line(utc_model)); - } - else if (line_str.find("END OF HEADER", 59) != std::string::npos) - { - data.push_back(line_str); - no_more_finds = true; - } - else - { - data.push_back(line_str); - } - } - } - else - { - data.push_back(line_str); - } - } - - override_stream_with_new_data(out, obsfilename, data, 0); -} - - -void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model) const -{ - std::vector data; - - out.seekp(0); - data.clear(); - - bool no_more_finds = false; - std::string line_str; - - while (!out.eof()) - { - std::getline(out, line_str); - - if (!no_more_finds) - { - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) - { - data.push_back(line_str); - data.push_back(get_leap_second_line(utc_model)); + data.push_back(leap_second_line); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { - data.push_back(line_str); no_more_finds = true; } - else - { - data.push_back(line_str); - } - } - else - { - data.push_back(line_str); - } - } - - override_stream_with_new_data(out, obsfilename, data, 0); -} - - -void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model& galileo_utc_model) const -{ - std::vector data; - - out.seekp(0); - data.clear(); - - bool no_more_finds = false; - std::string line_str; - - while (!out.eof()) - { - std::getline(out, line_str); - - if (!no_more_finds) - { - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) - { - data.push_back(line_str); - data.push_back(get_leap_second_line(galileo_utc_model)); - } - else if (line_str.find("END OF HEADER", 59) != std::string::npos) - { - data.push_back(line_str); - no_more_finds = true; - } - else - { - data.push_back(line_str); - } - } - else - { - data.push_back(line_str); - } - } - - override_stream_with_new_data(out, obsfilename, data, 0); -} - - -void Rinex_Printer::update_obs_header(std::fstream& out, const Beidou_Dnav_Utc_Model& utc_model) const -{ - std::vector data; - - out.seekp(0); - data.clear(); - - bool no_more_finds = false; - std::string line_str; - - while (!out.eof()) - { - std::getline(out, line_str); - - if (!no_more_finds) - { - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) - { - data.push_back(line_str); - data.push_back(get_leap_second_line(utc_model)); - } - else if (line_str.find("END OF HEADER", 59) != std::string::npos) - { - data.push_back(line_str); - no_more_finds = true; - } - else - { - data.push_back(line_str); - } - } - else - { - data.push_back(line_str); } } @@ -5844,11 +4652,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri observables_iter != observables.cend(); observables_iter++) { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } + line += satelliteSystem.at("GLONASS"); if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -5962,17 +4766,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri lengthCheck(line); out << line << '\n'; - const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - if (satsys != satelliteSystem.cend()) - { - lineObs += satsys->second; - } + lineObs += satelliteSystem.at("GLONASS"); if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -6185,15 +4985,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (d_version == 2) { // Add list of GPS satellites - const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observablesG1C.cbegin(); observables_iter != observablesG1C.cend(); observables_iter++) { - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } + line += satelliteSystem.at("GPS"); if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -6201,15 +4997,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L1 satellites - const auto satsys_glo = satelliteSystem.find("GLONASS"); for (observables_iter = observablesR1C.cbegin(); observables_iter != observablesR1C.cend(); observables_iter++) { - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } + line += satelliteSystem.at("GLONASS"); if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -6221,10 +5013,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter != observablesR2C.cend(); observables_iter++) { - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } + line += satelliteSystem.at("GLONASS"); if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -6251,19 +5040,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // Specify system only if in version 3 if (s == "G") { - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + line += satelliteSystem.at("GPS"); } if (s == "R") { - const auto satsys_glo = satelliteSystem.find("GLONASS"); - if (satsys_glo != satelliteSystem.cend()) - { - lineObs += satsys_glo->second; - } // should not happen + line += satelliteSystem.at("GLONASS"); } if (static_cast(observables_iter->second.PRN) < 10) { @@ -6332,11 +5113,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs.clear(); if (d_version == 3) { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - lineObs += satsys->second; - } + lineObs += satelliteSystem.at("GLONASS"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -6514,8 +5291,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // -------- OBSERVATION record std::string s; std::string lineObs; - const auto satsys_gps = satelliteSystem.find("GPS"); - const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observablesG2S.cbegin(); observables_iter != observablesG2S.cend(); observables_iter++) @@ -6526,17 +5301,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // Specify system only if in version 3 if (s == "G") { - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + line += satelliteSystem.at("GPS"); } if (s == "R") { - if (satsys != satelliteSystem.cend()) - { - lineObs += satsys->second; - } // should not happen + line += satelliteSystem.at("GLONASS"); } if (static_cast(observables_iter->second.PRN) < 10) { @@ -6602,10 +5371,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g it++) { lineObs.clear(); - if (satsys != satelliteSystem.cend()) - { - lineObs += satsys->second; - } + lineObs += satelliteSystem.at("GLONASS"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -6784,8 +5550,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga std::string s; std::string lineObs; - const auto satsys_gal = satelliteSystem.find("Galileo"); - const auto satsys = satelliteSystem.find("GLONASS"); for (observables_iter = observablesE1B.cbegin(); observables_iter != observablesE1B.cend(); observables_iter++) @@ -6795,17 +5559,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga s.assign(1, observables_iter->second.System); if (s == "E") { - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); } if (s == "R") { - if (satsys != satelliteSystem.cend()) - { - lineObs += satsys->second; - } // should not happen + line += satelliteSystem.at("GLONASS"); } if (static_cast(observables_iter->second.PRN) < 10) { @@ -6869,10 +5627,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga it++) { lineObs.clear(); - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -7005,11 +5760,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d observables_iter != observables.cend(); observables_iter++) { - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } + line += satelliteSystem.at("GPS"); if (static_cast(observables_iter->second.PRN) < 10) { line += std::string(1, '0'); @@ -7124,17 +5875,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d lengthCheck(line); out << line << '\n'; - const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -7255,17 +6002,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e lengthCheck(line); out << line << '\n'; - const auto satsys_gps = satelliteSystem.find("GPS"); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) { std::string lineObs; lineObs.clear(); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); if (static_cast(observables_iter->second.PRN) < 10) { lineObs += std::string(1, '0'); @@ -7483,17 +6226,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c out << line << '\n'; std::string lineObs; - const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -7741,16 +6480,12 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep std::string lineObs; std::pair::iterator, std::multimap::iterator> ret; - const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -7963,8 +6698,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep std::string s; std::string lineObs; - const auto satsys_gps = satelliteSystem.find("GPS"); - const auto satsys_gal = satelliteSystem.find("Galileo"); for (observables_iter = observablesG1C.cbegin(); observables_iter != observablesG1C.cend(); @@ -7975,17 +6708,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep s.assign(1, observables_iter->second.System); if (s == "G") { - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); } if (s == "E") { - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } // should not happen + lineObs += satelliteSystem.at("Galileo"); } if (static_cast(observables_iter->second.PRN) < 10) { @@ -8049,10 +6776,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep it++) { lineObs.clear(); - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -8299,17 +7023,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e std::string s; std::string lineObs; - const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_gps_prns.cbegin(); it != available_gps_prns.cend(); it++) { lineObs.clear(); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -8366,16 +7086,12 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e out << lineObs << '\n'; } - const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_gal_prns.cbegin(); it != available_gal_prns.cend(); it++) { lineObs.clear(); - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -8640,17 +7356,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep std::string s; std::string lineObs; - const auto satsys_gps = satelliteSystem.find("GPS"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_gps_prns.cbegin(); it != available_gps_prns.cend(); it++) { lineObs.clear(); - if (satsys_gps != satelliteSystem.cend()) - { - lineObs += satsys_gps->second; - } + lineObs += satelliteSystem.at("GPS"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -8718,16 +7430,12 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep out << lineObs << '\n'; } - const auto satsys_gal = satelliteSystem.find("Galileo"); for (it = available_gal_prns.cbegin(); it != available_gal_prns.cend(); it++) { lineObs.clear(); - if (satsys_gal != satelliteSystem.cend()) - { - lineObs += satsys_gal->second; - } + lineObs += satelliteSystem.at("Galileo"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); @@ -8906,17 +7614,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris out << line << '\n'; std::string lineObs; - const auto satsys_bds = satelliteSystem.find("Beidou"); std::pair::iterator, std::multimap::iterator> ret; for (it = available_prns.cbegin(); it != available_prns.cend(); it++) { lineObs.clear(); - if (satsys_bds != satelliteSystem.cend()) - { - lineObs += satsys_bds->second; - } + lineObs += satelliteSystem.at("Beidou"); if (static_cast(*it) < 10) { lineObs += std::string(1, '0'); diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 5d89e8c05..73b634301 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -704,20 +704,7 @@ private: const Beidou_Dnav_Utc_Model& utc_model, const Beidou_Dnav_Iono& beidou_dnav_iono) const; - void update_obs_header(std::fstream& out, - const Gps_Utc_Model& utc_model) const; - - void update_obs_header(std::fstream& out, - const Gps_CNAV_Utc_Model& utc_model) const; - - void update_obs_header(std::fstream& out, - const Galileo_Utc_Model& galileo_utc_model) const; - - void update_obs_header(std::fstream& out, - const Glonass_Gnav_Utc_Model& glonass_gnav_utc_model) const; - - void update_obs_header(std::fstream& out, - const Beidou_Dnav_Utc_Model& utc_model) const; + void update_obs_header(std::fstream& out, const std::string& leap_second_line) const; /* * Generation of RINEX signal strength indicators