mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2026-05-02 11:41:26 +00:00
Remove more duplicate code
This commit is contained in:
@@ -1302,6 +1302,36 @@ void add_obs_sat_record_line(const Gnss_Synchro& synchro, std::string& line, boo
|
||||
}
|
||||
}
|
||||
|
||||
void add_constellation_obs_sat_record_lines(const std::string& system, const std::set<uint32_t>& available_prns, const std::multimap<uint32_t, Gnss_Synchro>& prn_to_synchro, std::fstream& out, bool log_system_and_prn = true)
|
||||
{
|
||||
for (const auto& prn : available_prns)
|
||||
{
|
||||
std::string line;
|
||||
|
||||
if (log_system_and_prn)
|
||||
{
|
||||
line += satelliteSystem.at(system);
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
line += std::string(1, '0');
|
||||
}
|
||||
line += std::to_string(static_cast<int32_t>(prn));
|
||||
}
|
||||
|
||||
const auto ret = prn_to_synchro.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, line, false);
|
||||
}
|
||||
|
||||
if (line.size() < 80)
|
||||
{
|
||||
line += std::string(80 - line.size(), ' ');
|
||||
}
|
||||
out << line << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
std::string get_nav_sv_epoch_svclk_line(const boost::posix_time::ptime& p_utc_time, const std::string& sys_char, uint32_t prn, double value0, double value1, double value2)
|
||||
{
|
||||
std::string line;
|
||||
@@ -4971,32 +5001,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
for (const auto& available_glo_prn : available_glo_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
if (d_version == 3)
|
||||
{
|
||||
lineObs += satelliteSystem.at("GLONASS");
|
||||
if (static_cast<int32_t>(available_glo_prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(available_glo_prn));
|
||||
}
|
||||
const auto ret = total_glo_map.equal_range(available_glo_prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
/// \todo Need to account for pseudorange correction for glonass
|
||||
// double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time);
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("GLONASS", available_glo_prns, total_glo_map, out, d_version == 3);
|
||||
}
|
||||
|
||||
|
||||
@@ -5091,31 +5096,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
std::pair<std::multimap<uint32_t, Gnss_Synchro>::iterator, std::multimap<uint32_t, Gnss_Synchro>::iterator> ret;
|
||||
for (const auto& prn : available_glo_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("GLONASS");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
|
||||
ret = total_glo_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
/// \todo Need to account for pseudorange correction for glonass
|
||||
// double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time);
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("GLONASS", available_glo_prns, total_glo_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -5209,28 +5190,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
std::pair<std::multimap<uint32_t, Gnss_Synchro>::iterator, std::multimap<uint32_t, Gnss_Synchro>::iterator> ret;
|
||||
for (const auto& prn : available_glo_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Galileo");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
ret = total_glo_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("GLONASS", available_glo_prns, total_glo_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -5665,28 +5625,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep
|
||||
lengthCheck(line);
|
||||
out << line << '\n';
|
||||
|
||||
std::string lineObs;
|
||||
for (const auto& available_prn : available_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Galileo");
|
||||
if (static_cast<int32_t>(available_prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(available_prn));
|
||||
const auto ret = total_map.equal_range(available_prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("Galileo", available_prns, total_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -5811,28 +5750,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
std::pair<std::multimap<uint32_t, Gnss_Synchro>::iterator, std::multimap<uint32_t, Gnss_Synchro>::iterator> ret;
|
||||
for (const auto& prn : available_gal_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Galileo");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
ret = total_gal_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("Galileo", available_gal_prns, total_gal_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -5961,55 +5879,8 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e
|
||||
lengthCheck(line);
|
||||
out << line << '\n';
|
||||
|
||||
std::string s;
|
||||
std::string lineObs;
|
||||
|
||||
std::pair<std::multimap<uint32_t, Gnss_Synchro>::iterator, std::multimap<uint32_t, Gnss_Synchro>::iterator> ret;
|
||||
for (const auto& prn : available_gps_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("GPS");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
ret = total_gps_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
for (const auto& prn : available_gal_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Galileo");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
ret = total_gal_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("GPS", available_gps_prns, total_gps_map, out);
|
||||
add_constellation_obs_sat_record_lines("Galileo", available_gal_prns, total_gal_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -6192,28 +6063,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
|
||||
for (const auto& prn : available_gal_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Galileo");
|
||||
if (static_cast<int32_t>(prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(prn));
|
||||
ret = total_gal_map.equal_range(prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("Galileo", available_gal_prns, total_gal_map, out);
|
||||
}
|
||||
|
||||
|
||||
@@ -6289,28 +6139,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris
|
||||
lengthCheck(line);
|
||||
out << line << '\n';
|
||||
|
||||
std::string lineObs;
|
||||
for (const auto& available_prn : available_prns)
|
||||
{
|
||||
lineObs.clear();
|
||||
lineObs += satelliteSystem.at("Beidou");
|
||||
if (static_cast<int32_t>(available_prn) < 10)
|
||||
{
|
||||
lineObs += std::string(1, '0');
|
||||
}
|
||||
lineObs += std::to_string(static_cast<int32_t>(available_prn));
|
||||
const auto ret = total_map.equal_range(available_prn);
|
||||
for (auto iter = ret.first; iter != ret.second; ++iter)
|
||||
{
|
||||
add_obs_sat_record_line(iter->second, lineObs, false);
|
||||
}
|
||||
|
||||
if (lineObs.size() < 80)
|
||||
{
|
||||
lineObs += std::string(80 - lineObs.size(), ' ');
|
||||
}
|
||||
out << lineObs << '\n';
|
||||
}
|
||||
add_constellation_obs_sat_record_lines("Beidou", available_prns, total_map, out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user