From edc71fc8a606397bcb873819adade95caa143cb3 Mon Sep 17 00:00:00 2001 From: Mathieu Favreau Date: Wed, 6 Aug 2025 13:12:20 +0000 Subject: [PATCH] Cleanup rinex printer --- src/algorithms/PVT/libs/rinex_printer.cc | 8579 ++++++---------------- src/algorithms/PVT/libs/rinex_printer.h | 481 +- 2 files changed, 2356 insertions(+), 6704 deletions(-) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index c600ba294..4db4e9996 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -59,6 +59,14 @@ namespace { +const std::unordered_map satelliteSystem = { + {"GPS", "G"}, + {"GLONASS", "R"}, + {"SBAS payload", "S"}, + {"Galileo", "E"}, + {"Beidou", "C"}, + {"Mixed", "M"}}; // RINEX v3.02 codes + std::string enabled_signal_flags_to_string(const Signal_Enabled_Flags& flags) { std::vector signal_str_vector; @@ -121,93 +129,98 @@ std::string enabled_signal_flags_to_string(const Signal_Enabled_Flags& flags) return oss.str(); } -} // namespace - -Rinex_Printer::Rinex_Printer(int32_t conf_version, - const std::string& base_path, - const std::string& base_name) : d_fake_cnav_iode(1), - d_numberTypesObservations(4), - d_rinex_header_updated(false), - d_rinex_header_written(false), - d_pre_2009_file(false) +std::map getObservationCodes() { - observationCode["GPS_L1_CA"] = "1C"; // "1C" GPS L1 C/A - observationCode["GPS_L1_P"] = "1P"; // "1P" GPS L1 P - observationCode["GPS_L1_Z_TRACKING"] = "1W"; // "1W" GPS L1 Z-tracking and similar (AS on) - observationCode["GPS_L1_Y"] = "1Y"; // "1Y" GPS L1 Y - observationCode["GPS_L1_M "] = "1M"; // "1M" GPS L1 M - observationCode["GPS_L1_CODELESS"] = "1N"; // "1N" GPS L1 codeless - observationCode["GPS_L2_CA"] = "2C"; // "2C" GPS L2 C/A - observationCode["L2_SEMI_CODELESS"] = "2D"; // "2D" GPS L2 L1(C/A)+(P2-P1) semi-codeless - observationCode["GPS_L2_L2CM"] = "2S"; // "2S" GPS L2 L2C (M) - observationCode["GPS_L2_L2CL"] = "2L"; // "2L" GPS L2 L2C (L) - observationCode["GPS_L2_L2CML"] = "2X"; // "2X" GPS L2 L2C (M+L) - observationCode["GPS_L2_P"] = "2P"; // "2P" GPS L2 P - observationCode["GPS_L2_Z_TRACKING"] = "2W"; // "2W" GPS L2 Z-tracking and similar (AS on) - observationCode["GPS_L2_Y"] = "2Y"; // "2Y" GPS L2 Y - observationCode["GPS_L2_M"] = "2M"; // "2M" GPS GPS L2 M - observationCode["GPS_L2_codeless"] = "2N"; // "2N" GPS L2 codeless - observationCode["GPS_L5_I"] = "5I"; // "5I" GPS L5 I - observationCode["GPS_L5_Q"] = "5Q"; // "5Q" GPS L5 Q - observationCode["GPS_L5_IQ"] = "5X"; // "5X" GPS L5 I+Q - observationCode["GLONASS_G1_CA"] = "1C"; // "1C" GLONASS G1 C/A - observationCode["GLONASS_G1_P"] = "1P"; // "1P" GLONASS G1 P - observationCode["GLONASS_G2_CA"] = "2C"; // "2C" GLONASS G2 C/A (Glonass M) - observationCode["GLONASS_G2_P"] = "2P"; // "2P" GLONASS G2 P - observationCode["GALILEO_E1_A"] = "1A"; // "1A" GALILEO E1 A (PRS) - observationCode["GALILEO_E1_B"] = "1B"; // "1B" GALILEO E1 B (I/NAV OS/CS/SoL) - observationCode["GALILEO_E1_C"] = "1C"; // "1C" GALILEO E1 C (no data) - observationCode["GALILEO_E1_BC"] = "1X"; // "1X" GALILEO E1 B+C - observationCode["GALILEO_E1_ABC"] = "1Z"; // "1Z" GALILEO E1 A+B+C - observationCode["GALILEO_E5a_I"] = "5I"; // "5I" GALILEO E5a I (F/NAV OS) - observationCode["GALILEO_E5a_Q"] = "5Q"; // "5Q" GALILEO E5a Q (no data) - observationCode["GALILEO_E5a_IQ"] = "5X"; // "5X" GALILEO E5a I+Q - observationCode["GALILEO_E5b_I"] = "7I"; // "7I" GALILEO E5b I - observationCode["GALILEO_E5b_Q"] = "7Q"; // "7Q" GALILEO E5b Q - observationCode["GALILEO_E5b_IQ"] = "7X"; // "7X" GALILEO E5b I+Q - observationCode["GALILEO_E5_I"] = "8I"; // "8I" GALILEO E5 I - observationCode["GALILEO_E5_Q"] = "8Q"; // "8Q" GALILEO E5 Q - observationCode["GALILEO_E5_IQ"] = "8X"; // "8X" GALILEO E5 I+Q - observationCode["GALILEO_E56_A"] = "6A"; // "6A" GALILEO E6 A - observationCode["GALILEO_E56_B"] = "6B"; // "6B" GALILEO E6 B - observationCode["GALILEO_E56_C"] = "6C"; // "6C" GALILEO E6 C - observationCode["GALILEO_E56_BC"] = "6X"; // "6X" GALILEO E6 B+C - observationCode["GALILEO_E56_ABC"] = "6Z"; // "6Z" GALILEO E6 A+B+C - observationCode["SBAS_L1_CA"] = "1C"; // "1C" SBAS L1 C/A - observationCode["SBAS_L5_I"] = "5I"; // "5I" SBAS L5 I - observationCode["SBAS_L5_Q"] = "5Q"; // "5Q" SBAS L5 Q - observationCode["SBAS_L5_IQ"] = "5X"; // "5X" SBAS L5 I+Q - observationCode["COMPASS_E2_I"] = "2I"; - observationCode["COMPASS_E2_Q"] = "2Q"; - observationCode["COMPASS_E2_IQ"] = "2X"; - observationCode["COMPASS_E5b_I"] = "7I"; - observationCode["COMPASS_E5b_Q"] = "7Q"; - observationCode["COMPASS_E5b_IQ"] = "7X"; - observationCode["COMPASS_E6_I"] = "6I"; - observationCode["COMPASS_E6_Q"] = "6Q"; - observationCode["COMPASS_E6_IQ"] = "6X"; - observationCode["BEIDOU_B1_I"] = "1I"; - observationCode["BEIDOU_B1_Q"] = "1Q"; - observationCode["BEIDOU_B1_IQ"] = "1X"; - observationCode["BEIDOU_B3_I"] = "6I"; - observationCode["BEIDOU_B3_Q"] = "6Q"; - observationCode["BEIDOU_B3_IQ"] = "6X"; + return { + {"GPS_L1_CA", "1C"}, // "1C" GPS L1 C/A + {"GPS_L1_P", "1P"}, // "1P" GPS L1 P + {"GPS_L1_Z_TRACKING", "1W"}, // "1W" GPS L1 Z-tracking and similar (AS on) + {"GPS_L1_Y", "1Y"}, // "1Y" GPS L1 Y + {"GPS_L1_M ", "1M"}, // "1M" GPS L1 M + {"GPS_L1_CODELESS", "1N"}, // "1N" GPS L1 codeless + {"GPS_L2_CA", "2C"}, // "2C" GPS L2 C/A + {"L2_SEMI_CODELESS", "2D"}, // "2D" GPS L2 L1(C/A)+(P2-P1) semi-codeless + {"GPS_L2_L2CM", "2S"}, // "2S" GPS L2 L2C (M) + {"GPS_L2_L2CL", "2L"}, // "2L" GPS L2 L2C (L) + {"GPS_L2_L2CML", "2X"}, // "2X" GPS L2 L2C (M+L) + {"GPS_L2_P", "2P"}, // "2P" GPS L2 P + {"GPS_L2_Z_TRACKING", "2W"}, // "2W" GPS L2 Z-tracking and similar (AS on) + {"GPS_L2_Y", "2Y"}, // "2Y" GPS L2 Y + {"GPS_L2_M", "2M"}, // "2M" GPS GPS L2 M + {"GPS_L2_codeless", "2N"}, // "2N" GPS L2 codeless + {"GPS_L5_I", "5I"}, // "5I" GPS L5 I + {"GPS_L5_Q", "5Q"}, // "5Q" GPS L5 Q + {"GPS_L5_IQ", "5X"}, // "5X" GPS L5 I+Q + {"GLONASS_G1_CA", "1C"}, // "1C" GLONASS G1 C/A + {"GLONASS_G1_P", "1P"}, // "1P" GLONASS G1 P + {"GLONASS_G2_CA", "2C"}, // "2C" GLONASS G2 C/A (Glonass M) + {"GLONASS_G2_P", "2P"}, // "2P" GLONASS G2 P + {"GALILEO_E1_A", "1A"}, // "1A" GALILEO E1 A (PRS) + {"GALILEO_E1_B", "1B"}, // "1B" GALILEO E1 B (I/NAV OS/CS/SoL) + {"GALILEO_E1_C", "1C"}, // "1C" GALILEO E1 C (no data) + {"GALILEO_E1_BC", "1X"}, // "1X" GALILEO E1 B+C + {"GALILEO_E1_ABC", "1Z"}, // "1Z" GALILEO E1 A+B+C + {"GALILEO_E5a_I", "5I"}, // "5I" GALILEO E5a I (F/NAV OS) + {"GALILEO_E5a_Q", "5Q"}, // "5Q" GALILEO E5a Q (no data) + {"GALILEO_E5a_IQ", "5X"}, // "5X" GALILEO E5a I+Q + {"GALILEO_E5b_I", "7I"}, // "7I" GALILEO E5b I + {"GALILEO_E5b_Q", "7Q"}, // "7Q" GALILEO E5b Q + {"GALILEO_E5b_IQ", "7X"}, // "7X" GALILEO E5b I+Q + {"GALILEO_E5_I", "8I"}, // "8I" GALILEO E5 I + {"GALILEO_E5_Q", "8Q"}, // "8Q" GALILEO E5 Q + {"GALILEO_E5_IQ", "8X"}, // "8X" GALILEO E5 I+Q + {"GALILEO_E56_A", "6A"}, // "6A" GALILEO E6 A + {"GALILEO_E56_B", "6B"}, // "6B" GALILEO E6 B + {"GALILEO_E56_C", "6C"}, // "6C" GALILEO E6 C + {"GALILEO_E56_BC", "6X"}, // "6X" GALILEO E6 B+C + {"GALILEO_E56_ABC", "6Z"}, // "6Z" GALILEO E6 A+B+C + {"SBAS_L1_CA", "1C"}, // "1C" SBAS L1 C/A + {"SBAS_L5_I", "5I"}, // "5I" SBAS L5 I + {"SBAS_L5_Q", "5Q"}, // "5Q" SBAS L5 Q + {"SBAS_L5_IQ", "5X"}, // "5X" SBAS L5 I+Q + {"COMPASS_E2_I", "2I"}, + {"COMPASS_E2_Q", "2Q"}, + {"COMPASS_E2_IQ", "2X"}, + {"COMPASS_E5b_I", "7I"}, + {"COMPASS_E5b_Q", "7Q"}, + {"COMPASS_E5b_IQ", "7X"}, + {"COMPASS_E6_I", "6I"}, + {"COMPASS_E6_Q", "6Q"}, + {"COMPASS_E6_IQ", "6X"}, + {"BEIDOU_B1_I", "1I"}, + {"BEIDOU_B1_Q", "1Q"}, + {"BEIDOU_B1_IQ", "1X"}, + {"BEIDOU_B3_I", "6I"}, + {"BEIDOU_B3_Q", "6Q"}, + {"BEIDOU_B3_IQ", "6X"}, + {"PULSAR_X1", "X1"}, + {"PULSAR_X5", "X5"}, - observationType["PSEUDORANGE"] = "C"; - observationType["CARRIER_PHASE"] = "L"; - observationType["DOPPLER"] = "D"; - observationType["SIGNAL_STRENGTH"] = "S"; + // RINEX v2.10 and v2.11 codes + {"GPS_L1_CA_v2", "1"}, + {"GLONASS_G1_CA_v2", "1"}}; +} - // RINEX v2.10 and v2.11 codes - observationType["PSEUDORANGE_CA_v2"] = "C"; - observationType["PSEUDORANGE_P_v2"] = "P"; - observationType["CARRIER_PHASE_CA_v2"] = "L"; - observationType["DOPPLER_v2"] = "D"; - observationType["SIGNAL_STRENGTH_v2"] = "S"; - observationCode["GPS_L1_CA_v2"] = "1"; - observationCode["GLONASS_G1_CA_v2"] = "1"; +std::map getObservationTypes() +{ + return { + {"PSEUDORANGE", "C"}, + {"CARRIER_PHASE", "L"}, + {"DOPPLER", "D"}, + {"SIGNAL_STRENGTH", "S"}, + // RINEX v2.10 and v2.11 codes + {"PSEUDORANGE_CA_v2", "C"}, + {"PSEUDORANGE_P_v2", "P"}, + {"CARRIER_PHASE_CA_v2", "L"}, + {"DOPPLER_v2", "D"}, + {"SIGNAL_STRENGTH_v2", "S"}, + }; +} + +std::string getAndCreateBaseRinexPath(const std::string& base_path) +{ std::string base_rinex_path = base_path; fs::path full_path(fs::current_path()); const fs::path p(base_rinex_path); @@ -238,30 +251,1104 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, std::cout << "RINEX files will be stored at " << base_rinex_path << '\n'; } - navfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV", base_name); - obsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS", base_name); - sbsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS", base_name); - navGalfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV", base_name); - navMixfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV", base_name); - navGlofilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV", base_name); - navBdsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV", base_name); + return base_rinex_path; +} - Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::sbsFile.open(sbsfilename, std::ios::out | std::ios::app); - Rinex_Printer::navGalFile.open(navGalfilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::navMixFile.open(navMixfilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::navGloFile.open(navGlofilename, std::ios::out | std::ios::in | std::ios::app); - Rinex_Printer::navBdsFile.open(navBdsfilename, std::ios::out | std::ios::in | std::ios::app); +/* Creates RINEX file names according to the naming convention + * + * See ftp://igs.org/pub/data/format/rinex301.pdf + * Section 4, page 6 + * + * \param[in] type of RINEX file. Can be: + * "RINEX_FILE_TYPE_OBS" - Observation file. + * "RINEX_FILE_TYPE_GPS_NAV" - GPS navigation message file. + * "RINEX_FILE_TYPE_MET" - Meteorological data file. + * "RINEX_FILE_TYPE_GLO_NAV" - GLONASS navigation file. + * "RINEX_FILE_TYPE_GAL_NAV" - Galileo navigation message file. + * "RINEX_FILE_TYPE_MIXED_NAV" - Mixed GNSS navigation message file. + * "RINEX_FILE_TYPE_GEO_NAV" - SBAS Payload navigation message file. + * "RINEX_FILE_TYPE_SBAS" - SBAS broadcast data file. + * "RINEX_FILE_TYPE_CLK" - Clock file. + */ +std::string createFilename(const std::string& type, const std::string& base_name) +{ + const std::string stationName = "GSDR"; // 4-character station name designator + const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); + const int32_t dayOfTheYear = today.day_of_year(); + std::stringstream strm0; + if (dayOfTheYear < 100) + { + strm0 << "0"; // three digits for day of the year + } + if (dayOfTheYear < 10) + { + strm0 << "0"; // three digits for day of the year + } + strm0 << dayOfTheYear; + const std::string dayOfTheYearTag = strm0.str(); - if (!Rinex_Printer::navFile.is_open() || !Rinex_Printer::obsFile.is_open() or - !Rinex_Printer::sbsFile.is_open() || !Rinex_Printer::navGalFile.is_open() or - !Rinex_Printer::navMixFile.is_open() || !Rinex_Printer::navGloFile.is_open()) + const std::map fileType = { + {"RINEX_FILE_TYPE_OBS", "O"}, // O - Observation file. + {"RINEX_FILE_TYPE_GPS_NAV", "N"}, // N - GPS navigation message file. + {"RINEX_FILE_TYPE_MET", "M"}, // M - Meteorological data file. + {"RINEX_FILE_TYPE_GLO_NAV", "G"}, // G - GLONASS navigation file. + {"RINEX_FILE_TYPE_GAL_NAV", "L"}, // L - Galileo navigation message file. + {"RINEX_FILE_TYPE_MIXED_NAV", "P"}, // P - Mixed GNSS navigation message file. + {"RINEX_FILE_TYPE_GEO_NAV", "H"}, // H - SBAS Payload navigation message file. + {"RINEX_FILE_TYPE_SBAS", "B"}, // B - SBAS broadcast data file. + {"RINEX_FILE_TYPE_CLK", "C"}, // C - Clock file. + {"RINEX_FILE_TYPE_SUMMARY", "S"}, // S - Summary file (used e.g., by IGS, not a standard!). + {"RINEX_FILE_TYPE_BDS_NAV", "F"}, // F - BeiDou navigation file. + }; + + const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); + const tm pt_tm = boost::posix_time::to_tm(pt); + const int32_t local_hour = pt_tm.tm_hour; + std::stringstream strm; + strm << local_hour; + + const std::map Hmap = { + {"0", "a"}, + {"1", "b"}, + {"2", "c"}, + {"3", "d"}, + {"4", "e"}, + {"5", "f"}, + {"6", "g"}, + {"7", "h"}, + {"8", "i"}, + {"9", "j"}, + {"10", "k"}, + {"11", "l"}, + {"12", "m"}, + {"13", "n"}, + {"14", "o"}, + {"15", "p"}, + {"16", "q"}, + {"17", "r"}, + {"18", "s"}, + {"19", "t"}, + {"20", "u"}, + {"21", "v"}, + {"22", "w"}, + {"23", "x"}, + }; + + const std::string& hourTag = Hmap.at(strm.str()); + + const int32_t local_minute = pt_tm.tm_min; + std::stringstream strm2; + if (local_minute < 10) + { + strm2 << "0"; // at least two digits for minutes + } + strm2 << local_minute; + + const std::string minTag = strm2.str(); + + const int32_t local_year = pt_tm.tm_year - 100; // 2012 is 112 + std::stringstream strm3; + strm3 << local_year; + std::string yearTag = strm3.str(); + + const std::string& typeOfFile = fileType.at(type); + std::string filename; + if (base_name == "-") + { + filename = stationName + dayOfTheYearTag + hourTag + minTag + "." + yearTag + typeOfFile; + } + else + { + filename = base_name + "." + yearTag + typeOfFile; + } + return filename; +} + +std::string getFilePath(const std::string& type, const std::string& base_name, const std::string& base_rinex_path) +{ + return base_rinex_path + fs::path::preferred_separator + createFilename(type, base_name); +} + +/* + * (modified versions from GNSSTk https://github.com/SGL-UT/gnsstk) + * If the string is bigger than length, truncate it from the right. + * otherwise, add pad characters to its right. + * + * Left-justifies the input in a string of the specified + * length. If the new length (\a length) is larger than the + * current length, the string is extended by the pad + * character (\a pad). The default pad character is a + * blank. + * \param[in] s string to be modified. + * \param[in] length new desired length of string. + * \param[in] pad character to pad string with (blank by default). + * \return a reference to \a s. */ + +std::string& leftJustify(std::string& s, + std::string::size_type length, + char pad) +{ + if (length < s.length()) + { + s = s.substr(0, length); + } + else + { + s.append(length - s.length(), pad); + } + return s; +} + +/* + * If the string is bigger than length, truncate it from the right. + * otherwise, add pad characters to its right. + * + * Left-justifies the receiver in a string of the specified + * length (const version). If the new length (\a length) is larger + * than the current length, the string is extended by the pad + * character (\a pad). The default pad character is a + * blank. + * \param[in] s string to be modified. + * \param[in] length new desired length of string. + * \param[in] pad character to pad string with (blank by default). + * \return a reference to \a s. */ +std::string leftJustify(const std::string& s, + std::string::size_type length, + char pad = ' ') +{ + std::string t(s); + return leftJustify(t, length, pad); +} + +/* + * Right-justifies the receiver in a string of the specified + * length. If the receiver's data is shorter than the + * requested length (\a length), it is padded on the left with + * the pad character (\a pad). The default pad + * character is a blank. */ +std::string& rightJustify(std::string& s, + std::string::size_type length, + char pad) +{ + if (length < s.length()) + { + s = s.substr(s.length() - length, std::string::npos); + } + else + { + s.insert(static_cast(0), length - s.length(), pad); + } + return s; +} + +/* + * Right-justifies the receiver in a string of the specified + * length (const version). If the receiver's data is shorter than the + * requested length (\a length), it is padded on the left with + * the pad character (\a pad). The default pad + * character is a blank.*/ +std::string rightJustify(const std::string& s, + std::string::size_type length, + char pad = ' ') +{ + std::string t(s); + return rightJustify(t, length, pad); +} + +/* + * Convert a string to a double precision floating point number. + * @param s string containing a number. + * @return double representation of string. + */ +double asDouble(const std::string& s) +{ + return strtod(s.c_str(), nullptr); +} + +int toInt(const std::string& bitString, int sLength) +{ + int tempInt; + int num = 0; + for (int i = 0; i < sLength; i++) + { + tempInt = bitString[i] - '0'; + num |= (1 << (sLength - 1 - i)) * tempInt; + } + return num; +} + +/* + * Convert a string to an integer. + * @param s string containing a number. + * @return int64_t integer representation of string. + */ +int64_t asInt(const std::string& s) +{ + return strtol(s.c_str(), nullptr, 10); +} + + +/* + * Convert a double to a string in fixed notation. + * @param x double. + * @param precision the number of decimal places you want displayed. + * @return string representation of \a x. + */ +std::string asString(double x, std::string::size_type precision = 17) +{ + std::ostringstream ss; + ss << std::fixed << std::setprecision(precision) << x; + return ss.str(); +} + +/* + * Convert a long double to a string in fixed notation. + * @param x long double. + * @param precision the number of decimal places you want displayed. + * @return string representation of \a x. + */ +// std::string asString(long double x, std::string::size_type precision = 21) +// { +// std::ostringstream ss; +// ss << std::fixed << std::setprecision(precision) << x; +// return ss.str(); +// } + +/* + * Convert any old object to a string. + * The class must have stream operators defined. + * @param x object to turn into a string. + * @return string representation of \a x. + */ +template +std::string asString(const X x) +{ + std::ostringstream ss; + ss << x; + return ss.str(); +} + +// std::string asFixWidthString(int x, int width, char fill_digit) +// { +// std::ostringstream ss; +// ss << std::setfill(fill_digit) << std::setw(width) << x; +// return ss.str().substr(ss.str().size() - width); +// } + +/* + * Convert scientific notation to FORTRAN notation. + * As an example, the string "1.5636E5" becomes " .15636D6". + * Note that the first character of the string will be '-' if + * the number is negative or ' ' if the first character is positive. + * @param aStr string with number to convert + * @param startPos start position of number in string + * @param length length (in characters) of number, including exponent. + * @param expLen length (in characters of exponent, not including sign. + * @param checkSwitch will keep the method running as originally programmed + * when set to true. If false, the method will always resize exponentials, + * produce an exponential with an E instead of a D, and always have a leading + * zero. For example -> 0.87654E-0004 or -0.1234E00005. + */ +std::string& sci2for(std::string& aStr, + std::string::size_type startPos, + std::string::size_type length, + std::string::size_type expLen, + bool checkSwitch) +{ + std::string::size_type idx = aStr.find('.', startPos); + int expAdd = 0; + std::string exp; + int64_t iexp; + // If checkSwitch is false, always redo the exponential. Otherwise, + // set it to false. + bool redoexp = !checkSwitch; + + // Check for decimal place within specified boundaries + if ((idx <= 0) || (idx >= (startPos + length - expLen - 1))) + { + // Error: no decimal point in string + return aStr; + } + + // Here, account for the possibility that there are + // no numbers to the left of the decimal, but do not + // account for the possibility of non-scientific + // notation (more than one digit to the left of the + // decimal) + if (idx > startPos) + { + redoexp = true; + // Swap digit and decimal. + aStr[idx] = aStr[idx - 1]; + aStr[idx - 1] = '.'; + // Only add one to the exponent if the number is non-zero + if (asDouble(aStr.substr(startPos, length)) != 0.0) + { + expAdd = 1; + } + } + + idx = aStr.find('e', startPos); + if (idx == std::string::npos) + { + idx = aStr.find('E', startPos); + if (idx == std::string::npos) + { + // Error: no 'e' or 'E' in string"; + } + } + + // Change the exponent character to D normally, or E of checkSwitch is false. + if (checkSwitch) + { + aStr[idx] = 'D'; + } + else + { + aStr[idx] = 'E'; + } + + // Change the exponent itself + if (redoexp) + { + exp = aStr.substr(idx + 1, std::string::npos); + iexp = asInt(exp); + iexp += expAdd; + + aStr.erase(idx + 1); + if (iexp < 0) + { + aStr += "-"; + iexp -= iexp * 2; + } + else + { + aStr += "+"; + } + + aStr += rightJustify(asString(iexp), expLen, '0'); + } + + // if the number is positive, append a space + // (if it's negative, there's a leading '-' + if (aStr[0] == '.') + { + aStr.insert(static_cast(0), 1, ' '); + } + + // If checkSwitch is false, add on one leading zero to the string + if (!checkSwitch) + { + aStr.insert(static_cast(1), 1, '0'); + } + + return aStr; +} + +/* + * Convert a double to a scientific notation number. + * @param d the double to convert + * @param length length (in characters) of output, including exponent + * @param expLen length (in characters) of the exponent, with sign + * @param showSign if true, reserves 1 character for +/- sign + * @param checkSwitch if true, keeps the exponential sanity check for + * exponentials above three characters in length. If false, it removes + * that check. + */ +std::string doub2sci(double d, + std::string::size_type length, + std::string::size_type expLen, + bool showSign, + bool checkSwitch) +{ + std::string toReturn; + int16_t exponentLength = expLen; + + /* Validate the assumptions regarding the input arguments */ + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } + + std::stringstream c; + c.setf(std::ios::scientific, std::ios::floatfield); + + // length - 3 for special characters ('.', 'e', '+' or '-') + // - exponentlength (e04) + // - 1 for the digit before the decimal (2.) + // and if showSign == true, + // an extra -1 for '-' or ' ' if it's positive or negative + int expSize = 0; + if (showSign) + { + expSize = 1; + } + + c.precision(length - 3 - exponentLength - 1 - expSize); + c << d; + c >> toReturn; + return toReturn; +} + +/* + * Convert double precision floating point to a string + * containing the number in FORTRAN notation. + * As an example, the number 156360 becomes ".15636D6". + * @param d number to convert. + * @param length length (in characters) of number, including exponent. + * @param expLen length (in characters of exponent, including sign. + * @param checkSwitch if true, keeps the exponential sanity check for + * exponentials above three characters in length. If false, it removes + * that check. + * @return a string containing \a d in FORTRAN notation. + */ +std::string doub2for(double d, + std::string::size_type length, + std::string::size_type expLen, + bool checkSwitch = true) +{ + int16_t exponentLength = expLen; + + /* Validate the assumptions regarding the input arguments */ + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } + + std::string toReturn = doub2sci(d, length, exponentLength, true, checkSwitch); + sci2for(toReturn, 0, length, exponentLength, checkSwitch); + + return toReturn; +} + +/* + * Checks that the line is 80 characters length + */ +void lengthCheck(const std::string& line) +{ + if (line.length() != 80) + { + LOG(ERROR) << "Bad defined RINEX line: " + << line.length() << " characters (must be 80)" << '\n' + << line << '\n' + << "----|---1|0---|---2|0---|---3|0---|---4|0---|---5|0---|---6|0---|---7|0---|---8|\n"; + } +} + +void override_stream_with_new_data(std::fstream& out, const std::string& filename, const std::vector& data, int64_t seek_pos) +{ + out.close(); + out.open(filename, std::ios::out | std::ios::trunc); + out.seekp(0); + for (const auto& line : data) + { + out << line << '\n'; + } + out.close(); + out.open(filename, std::ios::out | std::ios::app); + out.seekp(seek_pos); +} + +void add_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; + + // -------- Line 1 + line = std::string(5, ' '); + line += version; + line += std::string(11, ' '); + line += std::string("N: GNSS NAV DATA"); + line += std::string(4, ' '); + line += type; + line += std::string(20 - type.size(), ' '); + line += std::string("RINEX VERSION / TYPE"); + lengthCheck(line); + 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'; + + // -------- Line COMMENT + line.clear(); + line += leftJustify(constellation + " NAVIGATION MESSAGE 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'; +} + +std::string get_iono_line(const std::string& identifier, double value0, double value1, double value2, double value3) +{ + std::string line; + + line += identifier; + line += std::string(1, ' '); + line += rightJustify(doub2for(value0, 10, 2), 12); + line += rightJustify(doub2for(value1, 10, 2), 12); + line += rightJustify(doub2for(value2, 10, 2), 12); + line += rightJustify(doub2for(value3, 10, 2), 12); + line += std::string(7, ' '); + line += leftJustify("IONOSPHERIC CORR", 20); + lengthCheck(line); + + return line; +} + +std::string get_time_corr_line(const std::string& identifier, double a0, double a1, std::optional tot = {}, std::optional wn = {}) +{ + std::string line; + + line += identifier; + line += rightJustify(doub2for(a0, 16, 2), 18); + line += rightJustify(doub2for(a1, 15, 2), 16); + + if (tot.has_value() && wn.has_value()) + { + line += rightJustify(std::to_string(tot.value()), 7); + line += rightJustify(std::to_string(wn.value()), 5); + line += std::string(10, ' '); + } + else + { + line += std::string(22, ' '); + } + + line += leftJustify("TIME SYSTEM CORR", 20); + lengthCheck(line); + + return line; +} + +// For leap second information, see https://endruntechnologies.com/support/leap-seconds +std::string get_leap_second_line(int32_t Delta_tLS, int32_t Delta_tLSF, int32_t WN_LSF, int32_t DN) +{ + std::string line; + + line += rightJustify(std::to_string(Delta_tLS), 6); + line += rightJustify(std::to_string(Delta_tLSF), 6); + line += rightJustify(std::to_string(WN_LSF), 6); + line += rightJustify(std::to_string(DN), 6); + line += std::string(36, ' '); + line += leftJustify("LEAP SECONDS", 20); + lengthCheck(line); + + return line; +} + +std::string get_end_of_header_line() +{ + std::string line; + + line += std::string(60, ' '); + line += leftJustify("END OF HEADER", 20); + lengthCheck(line); + + return line; +} + + +std::string get_gps_iono_alpha_line(const Gps_Iono& iono) +{ + return get_iono_line("GPSA", iono.alpha0, iono.alpha1, iono.alpha2, iono.alpha3); +} + +std::string get_gps_iono_beta_line(const Gps_Iono& iono) +{ + return get_iono_line("GPSB", iono.beta0, iono.beta1, iono.beta2, iono.beta3); +} + +std::string get_gps_iono_alpha_line(const Gps_CNAV_Iono& iono) +{ + return get_iono_line("GPSA", iono.alpha0, iono.alpha1, iono.alpha2, iono.alpha3); +} + +std::string get_gps_iono_beta_line(const Gps_CNAV_Iono& iono) +{ + return get_iono_line("GPSB", iono.beta0, iono.beta1, iono.beta2, iono.beta3); +} + +std::string get_galileo_iono_alpha_line(const Galileo_Iono& iono) +{ + return get_iono_line("GAL ", iono.ai0, iono.ai1, iono.ai2, 0.0); +} + +std::string get_beidou_iono_alpha_line(const Beidou_Dnav_Iono& iono) +{ + return get_iono_line("BDSA", iono.alpha0, iono.alpha1, iono.alpha2, iono.alpha3); +} + +std::string get_beidou_iono_beta_line(const Beidou_Dnav_Iono& iono) +{ + return get_iono_line("BDSB", iono.beta0, iono.beta1, iono.beta2, iono.beta3); +} + +std::string get_gps_time_corr_line(const Gps_Utc_Model& utc_model, const Gps_Ephemeris& gps_eph, bool pre_2009_file) +{ + int32_t WN_T = 0; + + if (!pre_2009_file && gps_eph.WN < 512) + { + if (utc_model.WN_T == 0) + { + WN_T = gps_eph.WN + 2048; // valid from 2019 to 2029 + } + else + { + WN_T = utc_model.WN_T + (gps_eph.WN / 256) * 256 + 2048; // valid from 2019 to 2029 + } + } + else + { + if (utc_model.WN_T == 0) + { + WN_T = gps_eph.WN + 1024; // valid from 2009 to 2019 + } + else + { + WN_T = utc_model.WN_T + (gps_eph.WN / 256) * 256 + 1024; // valid from 2009 to 2019 + } + } + + return get_time_corr_line("GPUT", utc_model.A0, utc_model.A1, utc_model.tot, WN_T); +} + +std::string get_gps_time_corr_line(const Gps_CNAV_Utc_Model& utc_model) +{ + return get_time_corr_line("GPUT", utc_model.A0, utc_model.A1, utc_model.tot, utc_model.WN_T); +} + +std::string get_galileo_time_corr_line(const Galileo_Utc_Model& utc_model) +{ + return get_time_corr_line("GAUT", utc_model.A0, utc_model.A1, utc_model.tot, utc_model.WNot); +} + +std::string get_beidou_time_corr_line(const Beidou_Dnav_Utc_Model& utc_model) +{ + return get_time_corr_line("BDUT", utc_model.A0_UTC, utc_model.A1_UTC); +} + +std::string get_glonass_time_corr_line(const Glonass_Gnav_Utc_Model& utc_model) +{ + return get_time_corr_line("GLUT", utc_model.d_tau_c, 0.0, 0, 0); +} + +std::string get_gps_to_galileo_time_corr_line(const Galileo_Utc_Model& utc_model) +{ + return get_time_corr_line("GPGA", utc_model.A_0G, utc_model.A_1G, utc_model.t_0G, utc_model.WN_0G); +} + +std::string get_glonass_to_gps_time_corr_line(const Glonass_Gnav_Utc_Model& utc_model) +{ + return get_time_corr_line("GLGP", utc_model.d_tau_gps, 0.0, 0, 0); +} + +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_CNAV_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 Galileo_Utc_Model& utc_model) +{ + return get_leap_second_line(utc_model.Delta_tLS, utc_model.Delta_tLSF, utc_model.WN_LSF, utc_model.DN); +} + +std::string get_leap_second_line(const Beidou_Dnav_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_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; + + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + 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 std::string seconds(timestring, 13, 2); + + if (!sys_char.empty()) + { + line += sys_char; + } + if (prn < 10) + { + line += std::string("0"); + } + line += std::to_string(prn); + const std::string year(timestring, 0, 4); + line += std::string(1, ' '); + line += year; + line += std::string(1, ' '); + line += month; + line += std::string(1, ' '); + line += day; + line += std::string(1, ' '); + line += hour; + line += std::string(1, ' '); + line += minutes; + line += std::string(1, ' '); + line += seconds; + line += std::string(1, ' '); + line += doub2for(value0, 18, 2); + line += std::string(1, ' '); + line += doub2for(value1, 18, 2); + line += std::string(1, ' '); + line += doub2for(value2, 18, 2); + + lengthCheck(line); + + return line; +} + +std::string get_nav_broadcast_orbit(std::optional value0, std::optional value1, std::optional value2, std::optional value3, uint32_t version = 3) +{ + std::string line; + + line += std::string(version + 2, ' '); + line += value0.has_value() ? doub2for(value0.value(), 18, 2) : std::string(18, ' '); + line += std::string(1, ' '); + line += value1.has_value() ? doub2for(value1.value(), 18, 2) : std::string(18, ' '); + line += std::string(1, ' '); + line += value2.has_value() ? doub2for(value2.value(), 18, 2) : std::string(18, ' '); + line += std::string(1, ' '); + line += value3.has_value() ? doub2for(value3.value(), 18, 2) : std::string(18, ' '); + + if (version == 2) + { + line += std::string(1, ' '); + } + + lengthCheck(line); + + return line; +} + +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); + lengthCheck(line); + out << line << '\n'; +} + +void add_obs_time_first_obs(std::fstream& out, const boost::posix_time::ptime& p_gps_time, double gps_tow) +{ + const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 seconds = fmod(gps_tow, 60); + std::string line; + 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("GPS"), 8); + line += std::string(9, ' '); + line += leftJustify("TIME OF FIRST OBS", 20); + lengthCheck(line); + out << line << '\n'; +} + +void add_obs_sys_obs_type(std::fstream& out, + const std::string& sys_char, + int numberTypesObservations, + const std::map& observationType, + const std::vector& obsCodes) +{ + // one line per available system + std::string line; + if (!sys_char.empty()) + { + line += sys_char; + } + line += std::string(2, ' '); + std::stringstream strm; + strm << numberTypesObservations; + line += rightJustify(strm.str(), 3); + + for (const auto& obsCode : obsCodes) + { + line += std::string(1, ' '); + line += observationType.at("PSEUDORANGE"); + line += obsCode; + line += std::string(1, ' '); + line += observationType.at("CARRIER_PHASE"); + line += obsCode; + line += std::string(1, ' '); + line += observationType.at("DOPPLER"); + line += obsCode; + line += std::string(1, ' '); + line += observationType.at("SIGNAL_STRENGTH"); + line += obsCode; + } + + line += std::string(60 - line.size(), ' '); + line += leftJustify("SYS / # / OBS TYPES", 20); + lengthCheck(line); + out << line << '\n'; +} + +void add_obs_sys_obs_type(std::fstream& out, + const std::string& constellation, + const std::string& bands, + const std::map& observationType, + const std::map& observationCode, + const std::map& band_to_code_map) +{ + std::vector obsCodes; + uint32_t number_of_observations = 0; + + for (const auto& it : band_to_code_map) + { + if (bands.find(it.first)) + { + obsCodes.emplace_back(observationCode.at(it.second)); + number_of_observations += 4; + } + } + + const auto satsys = satelliteSystem.find(constellation); + const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; + + add_obs_sys_obs_type(out, sys_char, number_of_observations, observationType, obsCodes); +} + +void add_obs_sys_obs_type_gps(std::fstream& out, + const std::string& bands, + const std::map& observationType, + const std::map& observationCode) +{ + const std::map band_to_code_map = { + {"1C", "GPS_L1_CA"}, + {"2S", "GPS_L2_L2CM"}, + {"L5", "GPS_L5_Q"}, + }; + + add_obs_sys_obs_type(out, "GPS", bands, observationType, observationCode, band_to_code_map); +} + +void add_obs_sys_obs_type_galileo(std::fstream& out, + const std::string& bands, + const std::map& observationType, + const std::map& observationCode) +{ + const std::map band_to_code_map = { + {"1B", "GALILEO_E1_B"}, + {"5X", "GALILEO_E5a_IQ"}, + {"7X", "GALILEO_E5b_IQ"}, + {"E6", "GALILEO_E56_B"}, + }; + + add_obs_sys_obs_type(out, "Galileo", bands, observationType, observationCode, band_to_code_map); +} + +void add_obs_sys_obs_type_glonass(std::fstream& out, + const std::string& bands, + const std::map& observationType, + const std::map& observationCode) +{ + const std::map band_to_code_map = { + {"1G", "GLONASS_G1_CA"}, + {"2G", "GLONASS_G2_CA"}, + }; + + add_obs_sys_obs_type(out, "GLONASS", bands, observationType, observationCode, band_to_code_map); +} + +void add_obs_sys_obs_type_beidou(std::fstream& out, + const std::string& bands, + const std::map& observationType, + const std::map& observationCode) +{ + const std::map band_to_code_map = { + {"B1", "BEIDOU_B1_I"}, + {"B3", "BEIDOU_B3_I"}, + }; + + add_obs_sys_obs_type(out, "Beidou", bands, observationType, observationCode, band_to_code_map); +} + +} // namespace + +Rinex_Printer::Rinex_Printer(int version, + const std::string& base_path, + const std::string& base_name) : Rinex_Printer(base_name, getAndCreateBaseRinexPath(base_path), version) +{ +} + +Rinex_Printer::Rinex_Printer(const std::string& base_name, + const std::string& base_rinex_path, + int version) : observationType(getObservationTypes()), + observationCode(getObservationCodes()), + navfilename(getFilePath("RINEX_FILE_TYPE_GPS_NAV", base_name, base_rinex_path)), + obsfilename(getFilePath("RINEX_FILE_TYPE_OBS", base_name, base_rinex_path)), + sbsfilename(getFilePath("RINEX_FILE_TYPE_SBAS", base_name, base_rinex_path)), + navGalfilename(getFilePath("RINEX_FILE_TYPE_GAL_NAV", base_name, base_rinex_path)), + navGlofilename(getFilePath("RINEX_FILE_TYPE_GLO_NAV", base_name, base_rinex_path)), + navBdsfilename(getFilePath("RINEX_FILE_TYPE_BDS_NAV", base_name, base_rinex_path)), + navMixfilename(getFilePath("RINEX_FILE_TYPE_MIXED_NAV", base_name, base_rinex_path)), + d_fake_cnav_iode(1), + d_rinex_header_updated(false), + d_rinex_header_written(false), + d_pre_2009_file(false) + +{ + std::map fileMap = { + {navfilename, navFile}, + {obsfilename, obsFile}, + {sbsfilename, sbsFile}, + {navGalfilename, navGalFile}, + {navMixfilename, navMixFile}, + {navGlofilename, navGloFile}, + {navBdsfilename, navBdsFile}, + }; + + bool all_open = true; + + for (auto& it : fileMap) + { + it.second.open(it.first, std::ios::out | std::ios::in | std::ios::app); + all_open = all_open && it.second.is_open(); + } + + if (!all_open) { std::cout << "RINEX files cannot be saved. Wrong permissions?\n"; } - if (conf_version == 2) + if (version == 2) { d_version = 2; d_stringVersion = "2.11"; @@ -277,84 +1364,45 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, Rinex_Printer::~Rinex_Printer() { DLOG(INFO) << "RINEX printer destructor called."; - // close RINEX files - const auto posn = navFile.tellp(); - const auto poso = obsFile.tellp(); - const auto poss = sbsFile.tellp(); - const auto posng = navGalFile.tellp(); - const auto posmn = navMixFile.tellp(); - const auto posnr = navGloFile.tellp(); - const auto posnc = navBdsFile.tellp(); + + std::map fileMap = { + {navfilename, navFile}, + {obsfilename, obsFile}, + {sbsfilename, sbsFile}, + {navGalfilename, navGalFile}, + {navMixfilename, navMixFile}, + {navGlofilename, navGloFile}, + {navBdsfilename, navBdsFile}, + }; + + std::map filePosMap; + + for (const auto& it : fileMap) + { + filePosMap[it.first] = it.second.tellp(); + } try { - Rinex_Printer::navFile.close(); - Rinex_Printer::obsFile.close(); - Rinex_Printer::sbsFile.close(); - Rinex_Printer::navGalFile.close(); - Rinex_Printer::navGloFile.close(); - Rinex_Printer::navBdsFile.close(); + for (auto& it : fileMap) + { + it.second.close(); + } } catch (const std::exception& e) { std::cerr << e.what() << '\n'; } - // If nothing written, erase the files. - if (posn == 0) + for (const auto& it : filePosMap) { - errorlib::error_code ec; - if (!fs::remove(fs::path(navfilename), ec)) + if (it.second == 0) { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (poso == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(obsfilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (poss == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(sbsfilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (posng == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(navGalfilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (posmn == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(navMixfilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (posnr == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(navGlofilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; - } - } - if (posnc == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(navBdsfilename), ec)) - { - LOG(INFO) << "Error deleting temporary file"; + errorlib::error_code ec; + if (!fs::remove(fs::path(it.first), ec)) + { + LOG(INFO) << "Error deleting temporary file"; + } } } } @@ -973,111 +2021,6 @@ void Rinex_Printer::log_rinex_nav_bds_dnav(uint32_t signal_enabled_flags, const } -void Rinex_Printer::lengthCheck(const std::string& line) const -{ - if (line.length() != 80) - { - LOG(ERROR) << "Bad defined RINEX line: " - << line.length() << " characters (must be 80)" << '\n' - << line << '\n' - << "----|---1|0---|---2|0---|---3|0---|---4|0---|---5|0---|---6|0---|---7|0---|---8|\n"; - } -} - - -std::string Rinex_Printer::createFilename(const std::string& type, const std::string& base_name) const -{ - const std::string stationName = "GSDR"; // 4-character station name designator - const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); - const int32_t dayOfTheYear = today.day_of_year(); - std::stringstream strm0; - if (dayOfTheYear < 100) - { - strm0 << "0"; // three digits for day of the year - } - if (dayOfTheYear < 10) - { - strm0 << "0"; // three digits for day of the year - } - strm0 << dayOfTheYear; - const std::string dayOfTheYearTag = strm0.str(); - - std::map fileType; - fileType.insert(std::pair("RINEX_FILE_TYPE_OBS", "O")); // O - Observation file. - fileType.insert(std::pair("RINEX_FILE_TYPE_GPS_NAV", "N")); // N - GPS navigation message file. - fileType.insert(std::pair("RINEX_FILE_TYPE_MET", "M")); // M - Meteorological data file. - fileType.insert(std::pair("RINEX_FILE_TYPE_GLO_NAV", "G")); // G - GLONASS navigation file. - fileType.insert(std::pair("RINEX_FILE_TYPE_GAL_NAV", "L")); // L - Galileo navigation message file. - fileType.insert(std::pair("RINEX_FILE_TYPE_MIXED_NAV", "P")); // P - Mixed GNSS navigation message file. - fileType.insert(std::pair("RINEX_FILE_TYPE_GEO_NAV", "H")); // H - SBAS Payload navigation message file. - fileType.insert(std::pair("RINEX_FILE_TYPE_SBAS", "B")); // B - SBAS broadcast data file. - fileType.insert(std::pair("RINEX_FILE_TYPE_CLK", "C")); // C - Clock file. - fileType.insert(std::pair("RINEX_FILE_TYPE_SUMMARY", "S")); // S - Summary file (used e.g., by IGS, not a standard!). - fileType.insert(std::pair("RINEX_FILE_TYPE_BDS_NAV", "F")); // F - BeiDou navigation file. - - const boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time(); - const tm pt_tm = boost::posix_time::to_tm(pt); - const int32_t local_hour = pt_tm.tm_hour; - std::stringstream strm; - strm << local_hour; - - std::map Hmap; - Hmap.insert(std::pair("0", "a")); - Hmap.insert(std::pair("1", "b")); - Hmap.insert(std::pair("2", "c")); - Hmap.insert(std::pair("3", "d")); - Hmap.insert(std::pair("4", "e")); - Hmap.insert(std::pair("5", "f")); - Hmap.insert(std::pair("6", "g")); - Hmap.insert(std::pair("7", "h")); - Hmap.insert(std::pair("8", "i")); - Hmap.insert(std::pair("9", "j")); - Hmap.insert(std::pair("10", "k")); - Hmap.insert(std::pair("11", "l")); - Hmap.insert(std::pair("12", "m")); - Hmap.insert(std::pair("13", "n")); - Hmap.insert(std::pair("14", "o")); - Hmap.insert(std::pair("15", "p")); - Hmap.insert(std::pair("16", "q")); - Hmap.insert(std::pair("17", "r")); - Hmap.insert(std::pair("18", "s")); - Hmap.insert(std::pair("19", "t")); - Hmap.insert(std::pair("20", "u")); - Hmap.insert(std::pair("21", "v")); - Hmap.insert(std::pair("22", "w")); - Hmap.insert(std::pair("23", "x")); - - const std::string hourTag = Hmap[strm.str()]; - - const int32_t local_minute = pt_tm.tm_min; - std::stringstream strm2; - if (local_minute < 10) - { - strm2 << "0"; // at least two digits for minutes - } - strm2 << local_minute; - - const std::string minTag = strm2.str(); - - const int32_t local_year = pt_tm.tm_year - 100; // 2012 is 112 - std::stringstream strm3; - strm3 << local_year; - std::string yearTag = strm3.str(); - - const std::string typeOfFile = fileType[type]; - std::string filename; - if (base_name == "-") - { - filename = stationName + dayOfTheYearTag + hourTag + minTag + "." + yearTag + typeOfFile; - } - else - { - filename = base_name + "." + yearTag + typeOfFile; - } - return filename; -} - - std::string Rinex_Printer::getLocalTime() const { std::string line; @@ -1099,7 +2042,7 @@ std::string Rinex_Printer::getLocalTime() const } #endif - line += Rinex_Printer::leftJustify(username, 20); + line += leftJustify(username, 20); const boost::gregorian::date today = boost::gregorian::day_clock::local_day(); const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); @@ -1125,7 +2068,7 @@ std::string Rinex_Printer::getLocalTime() const if (d_version == 2) { const int32_t day = pt_tm.tm_mday; - line += Rinex_Printer::rightJustify(std::to_string(day), 2); + line += rightJustify(std::to_string(day), 2); line += std::string("-"); std::map months; @@ -1177,78 +2120,17 @@ 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); + std::string line; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("R: GLONASS"); - line += std::string(10, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GLONASS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - // -------- Line system time correction if (d_version == 3) { - line.clear(); - line += std::string("GLUT"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GLGP"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model) << '\n'; } if (d_version == 2) { @@ -1260,23 +2142,19 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Glonass_Gnav_Utc_M const std::string day(timestring, 6, 2); line.clear(); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); + line += rightJustify(year, 6); + line += rightJustify(month, 6); + line += rightJustify(day, 6); line += std::string(3, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 19, 2), 19); + line += rightJustify(doub2for(glonass_gnav_utc_model.d_tau_c, 19, 2), 19); line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("CORR TO SYSTEM TIME", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("CORR TO SYSTEM TIME", 20); + lengthCheck(line); out << line << '\n'; } // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -1285,158 +2163,29 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& gps_iono if (glonass_gnav_almanac.i_satellite_freq_channel) { } // Avoid compiler warning - std::string line; + d_stringVersion = "3.02"; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(gps_iono) << '\n'; // -------- Line system time correction 1 - line.clear(); - line += std::string("GLUT"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GLGP"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line system time correction 3 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 2048), 5); // valid from 2019 to 2029 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - } - else - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - } - else - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(gps_utc_model, eph, d_pre_2009_file) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(gps_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -1445,122 +2194,28 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps if (glonass_gnav_almanac.i_satellite_freq_channel) { } // Avoid compiler warning - std::string line; d_stringVersion = "3.02"; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(gps_iono) << '\n'; // -------- Line system time correction 1 - line.clear(); - line += std::string("GLUT"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GLGP"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line system time correction 3 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(gps_utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(gps_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -1569,466 +2224,92 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& gali if (glonass_gnav_almanac.i_satellite_freq_channel) { } // Avoid compiler warning - // Avoid compiler warning, there is not time system correction between Galileo and GLONASS - if (galileo_utc_model.A_0G > 0.0) - { - } - std::string line; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GAL "); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; // -------- Line system time correction - line.clear(); - line += std::string("GAUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_time_corr_line(galileo_utc_model) << '\n'; // -------- Line system time correction 1 - line.clear(); - line += std::string("GLUT"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_time_corr_line(glonass_gnav_utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(galileo_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } void Rinex_Printer::rinex_nav_header(std::fstream& out, const Galileo_Iono& iono, const Galileo_Utc_Model& utc_model) const { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("E: GALILEO"); - line += std::string(10, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GALILEO NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "E: GALILEO", "GALILEO", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GAL "); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.ai2, 10, 2), 12); - const double zero = 0.0; - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_iono_alpha_line(iono) << '\n'; // -------- Line system time correction - line.clear(); - line += std::string("GAUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WNot), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_time_corr_line(utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GPGA"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_0G, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_1G, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.t_0G), 7); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_0G), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_to_galileo_time_corr_line(utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLS), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& iono, const Gps_CNAV_Utc_Model& utc_model) const { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("G: GPS"); - line += std::string(14, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::leftJustify("GPS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "G: GPS", "GPS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("GPSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_beta_line(iono) << '\n'; // -------- Line 5 system time correction - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T), 5); - /* if ( SBAS ) - { - line += string(1, ' '); - line += leftJustify(asString(tot_SBAS),5); - line += string(1, ' '); - line += leftJustify(asString(d_WN_T_SBAS),2); - line += string(1, ' '); - } - else - */ - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } 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 { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GAL "); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(iono) << '\n'; // -------- Line ionospheric info 3 - line.clear(); - line += std::string("GPSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_beta_line(iono) << '\n'; // -------- Line system time correction - line.clear(); - line += std::string("GAUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_time_corr_line(galileo_utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -2058,7 +2339,7 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co } line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 @@ -2066,30 +2347,30 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 3 line.clear(); - line += Rinex_Printer::leftJustify("GPS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GPS NAVIGATION MESSAGE 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line ionospheric info 1 @@ -2097,84 +2378,70 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co if (d_version == 2) { line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); + line += rightJustify(doub2for(iono.alpha0, 10, 2), 12); + line += rightJustify(doub2for(iono.alpha1, 10, 2), 12); + line += rightJustify(doub2for(iono.alpha2, 10, 2), 12); + line += rightJustify(doub2for(iono.alpha3, 10, 2), 12); line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("ION ALPHA", 20); + line += leftJustify("ION ALPHA", 20); + lengthCheck(line); + out << line << '\n'; } if (d_version == 3) { - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + out << get_gps_iono_alpha_line(iono) << '\n'; } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; // -------- Line ionospheric info 2 line.clear(); if (d_version == 2) { line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); + line += rightJustify(doub2for(iono.beta0, 10, 2), 12); + line += rightJustify(doub2for(iono.beta1, 10, 2), 12); + line += rightJustify(doub2for(iono.beta2, 10, 2), 12); + line += rightJustify(doub2for(iono.beta3, 10, 2), 12); line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("ION BETA", 20); + line += leftJustify("ION BETA", 20); + lengthCheck(line); + out << line << '\n'; } if (d_version == 3) { - line += std::string("GPSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); + out << get_gps_iono_beta_line(iono) << '\n'; } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; // -------- Line 5 system time correction line.clear(); if (d_version == 2) { line += std::string(3, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 18, 2), 19); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 18, 2), 19); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 9); + line += rightJustify(doub2for(utc_model.A0, 18, 2), 19); + line += rightJustify(doub2for(utc_model.A1, 18, 2), 19); + line += rightJustify(std::to_string(utc_model.tot), 9); if (d_pre_2009_file == false) { if (eph.WN < 512) { if (utc_model.WN_T == 0) { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 2048), 9); // valid from 2019 to 2029 + line += rightJustify(std::to_string(eph.WN + 2048), 9); // valid from 2019 to 2029 } else { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2019 to 2029 + line += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2019 to 2029 } } else { if (utc_model.WN_T == 0) { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 9); // valid from 2019 to 2029 + line += rightJustify(std::to_string(eph.WN + 1024), 9); // valid from 2019 to 2029 } else { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 + line += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 } } } @@ -2182,907 +2449,202 @@ void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_Iono& iono, co { if (utc_model.WN_T == 0) { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 9); // valid from 2019 to 2029 + line += rightJustify(std::to_string(eph.WN + 1024), 9); // valid from 2019 to 2029 } else { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 + line += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 } } line += std::string(1, ' '); - line += Rinex_Printer::leftJustify("DELTA-UTC: A0,A1,T,W", 20); + line += leftJustify("DELTA-UTC: A0,A1,T,W", 20); } if (d_version == 3) { - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - if (utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 2048), 5); // valid from 2019 to 2029 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - } - else - { - if (utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - } - else - { - if (utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - /* if ( SBAS ) - { - line += string(1, ' '); - line += leftJustify(asString(tot_SBAS),5); - line += string(1, ' '); - line += leftJustify(asString(d_WN_T_SBAS),2); - line += string(1, ' '); - } - else - */ - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); + out << get_gps_time_corr_line(utc_model, eph, d_pre_2009_file) << '\n'; } - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 6 leap seconds // For leap second information, see https://endruntechnologies.com/support/leap-seconds line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); + line += rightJustify(std::to_string(utc_model.DeltaT_LS), 6); if (d_version == 2) { line += std::string(54, ' '); } if (d_version == 3) { - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); + line += rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); + line += rightJustify(std::to_string(utc_model.WN_LSF), 6); + line += rightJustify(std::to_string(utc_model.DN), 6); line += std::string(36, ' '); } - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("LEAP SECONDS", 20); + lengthCheck(line); out << line << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } 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 { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GAL "); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(gps_iono) << '\n'; // -------- Line system time correction - line.clear(); - line += std::string("GAUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_time_corr_line(galileo_utc_model) << '\n'; // -------- Line system time correction 2 - line.clear(); - line += std::string("GPGA"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G), 7); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_to_galileo_time_corr_line(galileo_utc_model) << '\n'; // -------- Line system time correction 3 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 2048), 5); // valid from 2019 to 2029 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - } - else - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - } - else - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(gps_utc_model, eph, d_pre_2009_file) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(gps_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } void Rinex_Printer::rinex_nav_header(std::fstream& out, const Beidou_Dnav_Iono& iono, const Beidou_Dnav_Utc_Model& utc_model) const { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - - if (d_version == 3) - { - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - // todo: Add here other systems... - line += std::string("F: BDS"); - line += std::string(14, ' '); - // ... - } - - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 3 - line.clear(); - line += Rinex_Printer::leftJustify("BDS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "F: BDS", "BDS", Rinex_Printer::getLocalTime(), d_stringVersion); // TODO version handling // -------- Line ionospheric info 1, only version 3 supported - line.clear(); - line += std::string("BDSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_alpha_line(iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("BDSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_beta_line(iono) << '\n'; // -------- Line 5 system time correction - line.clear(); - line += std::string("BDUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0_UTC, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1_UTC, 15, 2), 16); - line += std::string(22, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_time_corr_line(utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } 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 { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported - line.clear(); - line += std::string("BDSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("BDSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_beta_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(gps_iono) << '\n'; // -------- Line 5 system time correction - line.clear(); - line += std::string("BDUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A0_UTC, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A1_UTC, 15, 2), 16); - line += std::string(22, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_time_corr_line(bds_dnav_utc_model) << '\n'; // -------- Line system time correction 3 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - if (gps_eph.WN < 512) - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(gps_eph.WN + 2048), 5); // valid from 2019 to 2029 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (gps_eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - } - else - { - if (gps_utc_model.WN_T == 0) - { - line += Rinex_Printer::rightJustify(std::to_string(gps_eph.WN + 1024), 5); // valid from 2009 to 2019 - } - else - { - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (gps_eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(gps_utc_model, gps_eph, d_pre_2009_file) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(gps_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } void Rinex_Printer::rinex_nav_header(std::fstream& out, const Gps_CNAV_Iono& gps_cnav_iono, const Gps_CNAV_Utc_Model& gps_cnav_utc_model, const Beidou_Dnav_Iono& bds_dnav_iono, const Beidou_Dnav_Utc_Model& bds_dnav_utc_model) { - std::string line; d_stringVersion = "3.02"; d_version = 3; - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported - line.clear(); - line += std::string("BDSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("BDSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_beta_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GPSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_iono_alpha_line(gps_cnav_iono) << '\n'; // -------- Line 5 system time correction - line.clear(); - line += std::string("BDUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A0_UTC, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A1_UTC, 15, 2), 16); - line += std::string(22, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_time_corr_line(bds_dnav_utc_model) << '\n'; // -------- Line system time correction 3 - line.clear(); - line += std::string("GPUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_cnav_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.WN_T), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_gps_time_corr_line(gps_cnav_utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(gps_cnav_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(gps_cnav_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } 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 { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1, only version 3 supported - line.clear(); - line += std::string("BDSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("BDSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_beta_line(bds_dnav_iono) << '\n'; // -------- Line 5 system time correction - line.clear(); - line += std::string("BDUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A0_UTC, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A1_UTC, 15, 2), 16); - line += std::string(22, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_time_corr_line(bds_dnav_utc_model) << '\n'; // -------- Line system time correction 1 - line.clear(); - line += std::string("GLUT"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glo_gnav_utc_model.d_tau_c, 16, 2), 17); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_glonass_time_corr_line(glo_gnav_utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.DeltaT_LS), 6); - line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.DeltaT_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(bds_dnav_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(bds_dnav_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } 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 { - std::string line; - - // -------- Line 1 - line = std::string(5, ' '); - line += d_stringVersion; - line += std::string(11, ' '); - line += std::string("N: GNSS NAV DATA"); - line += std::string(4, ' '); - line += std::string("M: MIXED"); - line += std::string(12, ' '); - line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line 2 - line.clear(); - line += Rinex_Printer::getLocalTime(); - line += std::string("PGM / RUN BY / DATE"); - line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("GNSS NAVIGATION MESSAGE FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - std::string gnss_sdr_version(GNSS_SDR_VERSION); - line += "GNSS-SDR VERSION "; - line += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line COMMENT - line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_header_start(out, "M: MIXED", "GNSS", Rinex_Printer::getLocalTime(), d_stringVersion); // -------- Line ionospheric info 1 - line.clear(); - line += std::string("GAL "); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_iono_alpha_line(galileo_iono) << '\n'; // -------- Line ionospheric info 1, only version 3 supported - line.clear(); - line += std::string("BDSA"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.alpha3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_alpha_line(bds_dnav_iono) << '\n'; // -------- Line ionospheric info 2 - line.clear(); - line += std::string("BDSB"); - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta0, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta1, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta2, 10, 2), 12); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_iono.beta3, 10, 2), 12); - line += std::string(7, ' '); - line += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_iono_beta_line(bds_dnav_iono) << '\n'; // -------- Line system time correction - line.clear(); - line += std::string("GAUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line += std::string(10, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_galileo_time_corr_line(galileo_utc_model) << '\n'; // -------- Line system time correction 1 // -------- Line 5 system time correction - line.clear(); - line += std::string("BDUT"); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A0_UTC, 16, 2), 18); - line += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(bds_dnav_utc_model.A1_UTC, 15, 2), 16); - line += std::string(22, ' '); - line += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_beidou_time_corr_line(bds_dnav_utc_model) << '\n'; // -------- Line 6 leap seconds - // For leap second information, see https://endruntechnologies.com/support/leap-seconds - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF), 6); - line += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN), 6); - line += std::string(36, ' '); - line += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_leap_second_line(galileo_utc_model) << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -3095,16 +2657,16 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const line = std::string(5, ' '); line += std::string("2.10"); line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("B SBAS DATA", 20); + line += leftJustify("B SBAS DATA", 20); line += std::string(20, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); + line += leftJustify("GNSS-SDR", 20); std::string username; #if ANDROID username = "ANDROID USER"; @@ -3120,7 +2682,7 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const username = "UNKNOWN USER"; } #endif - line += Rinex_Printer::leftJustify(username, 20); + line += leftJustify(username, 20); // Date of file creation (dd-mmm-yy hhmm) const boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("UTC")); const boost::local_time::local_date_time pt = boost::local_time::local_sec_clock::local_time(zone); @@ -3166,47 +2728,43 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) const time_str += " "; time_str += strmHour.str(); time_str += strmMin.str(); - line += Rinex_Printer::leftJustify(time_str, 20); - line += Rinex_Printer::leftJustify("PGM / RUN BY / DATE", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(time_str, 20); + line += leftJustify("PGM / RUN BY / DATE", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 line.clear(); line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("REC INDEX/TYPE/VERS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("REC INDEX/TYPE/VERS", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT 1 line.clear(); - line += Rinex_Printer::leftJustify("BROADCAST DATA FILE FOR GEO SV, GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("BROADCAST DATA FILE FOR GEO SV, 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT 2 line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- End of Header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -3216,7 +2774,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ { } // Avoid compiler warning std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3231,29 +2788,13 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ if (!no_more_finds) { - line_aux.clear(); - if ((line_str.find("GLUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_time_corr_line(glonass_gnav_utc_model)); } else if ((line_str.find("GLGP", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLGP"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3271,16 +2812,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ } } - out.close(); - out.open(navGlofilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navGlofilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navGlofilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC info.\n"; } @@ -3288,7 +2820,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Glonass_Gnav_Utc_ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& utc_model) const { std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3303,52 +2834,21 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal if (!no_more_finds) { - line_aux.clear(); - if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GAL "); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_iono_alpha_line(galileo_iono)); } else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GAUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WNot), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_time_corr_line(utc_model)); } else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPGA"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_0G, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A_1G, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.t_0G), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_0G), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_to_galileo_time_corr_line(utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.Delta_tLSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3366,16 +2866,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal } } - out.close(); - out.open(navGalfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navGalfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navGalfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -3405,55 +2896,55 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut if (line_str.find("ION ALPHA", 59) != std::string::npos) { line_aux += std::string(2, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.alpha0, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.alpha1, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.alpha2, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.alpha3, 10, 2), 12); line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("ION ALPHA", 20); + line_aux += leftJustify("ION ALPHA", 20); data.push_back(line_aux); } else if (line_str.find("ION BETA", 59) != std::string::npos) { line_aux += std::string(2, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.beta0, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.beta1, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.beta2, 10, 2), 12); + line_aux += rightJustify(doub2for(iono.beta3, 10, 2), 12); line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("ION BETA", 20); + line_aux += leftJustify("ION BETA", 20); data.push_back(line_aux); } else if (line_str.find("DELTA-UTC", 59) != std::string::npos) { line_aux += std::string(3, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 18, 2), 19); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 18, 2), 19); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 9); + line_aux += rightJustify(doub2for(utc_model.A0, 18, 2), 19); + line_aux += rightJustify(doub2for(utc_model.A1, 18, 2), 19); + line_aux += rightJustify(std::to_string(utc_model.tot), 9); if (d_pre_2009_file == false) { if (eph.WN < 512) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 9); // valid from 2019 to 2029 + line_aux += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 9); // valid from 2019 to 2029 } else { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 + line_aux += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 9); // valid from 2009 to 2019 } } else { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256), 9); + line_aux += rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256), 9); } line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::leftJustify("DELTA-UTC: A0,A1,T,W", 20); + line_aux += leftJustify("DELTA-UTC: A0,A1,T,W", 20); data.push_back(line_aux); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); + line_aux += rightJustify(std::to_string(utc_model.DeltaT_LS), 6); line_aux += std::string(54, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + line_aux += leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) @@ -3471,62 +2962,19 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut { if (line_str.find("GPSA", 0) != std::string::npos) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(iono)); } else if (line_str.find("GPSB", 0) != std::string::npos) { - line_aux += std::string("GPSB"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_beta_line(iono)); } else if (line_str.find("GPUT", 0) != std::string::npos) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 1999 to 2008 - } - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(utc_model, eph, d_pre_2009_file)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3545,16 +2993,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut } } - out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -3562,7 +3001,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Utc_Model& ut void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model, const Gps_CNAV_Iono& iono) const { std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3577,52 +3015,21 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("GPSA", 0) != std::string::npos) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(iono)); } else if (line_str.find("GPSB", 0) != std::string::npos) { - line_aux += std::string("GPSB"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_beta_line(iono)); } else if (line_str.find("GPUT", 0) != std::string::npos) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3640,16 +3047,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode } } - out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -3657,7 +3055,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Model& utc_model, const Gps_CNAV_Iono& iono, const Galileo_Iono& galileo_iono, const Galileo_Utc_Model& galileo_utc_model) const { std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3672,87 +3069,33 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode if (!no_more_finds) { - line_aux.clear(); if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GAL "); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_iono_alpha_line(galileo_iono)); } else if ((line_str.find("GPSA", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(iono)); } else if ((line_str.find("GPSB", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GPSB"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_beta_line(iono)); } - else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GAUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_time_corr_line(galileo_utc_model)); } else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPGA"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_to_galileo_time_corr_line(galileo_utc_model)); } else if (line_str.find("GPUT", 0) != std::string::npos) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_T), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3769,16 +3112,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode data.push_back(line_str); } } - out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -3786,7 +3120,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Utc_Mode void Rinex_Printer::update_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 { std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3801,101 +3134,33 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("GPSA", 0) != std::string::npos) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(gps_iono)); } else if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GAL "); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_iono_alpha_line(galileo_iono)); } else if ((line_str.find("GPSB", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GPSB"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.beta3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_beta_line(gps_iono)); } else if ((line_str.find("GPUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 1999 to 2008 - } - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(gps_utc_model, eph, d_pre_2009_file)); } else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GAUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_time_corr_line(galileo_utc_model)); } else if ((line_str.find("GPGA", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPGA"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_0G, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A_1G, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.t_0G), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_0G), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_to_galileo_time_corr_line(galileo_utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(galileo_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -3913,16 +3178,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion } } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navMixfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -3933,7 +3189,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion { } // Avoid compiler warning std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -3948,76 +3203,25 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("GPSA", 0) != std::string::npos) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(gps_iono)); } else if ((line_str.find("GPUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - if (d_pre_2009_file == false) - { - if (eph.WN < 512) - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 2048), 5); // valid from 2019 to 2029 - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256 + 1024), 5); // valid from 2009 to 2019 - } - } - else - { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T + (eph.WN / 256) * 256), 5); - } - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(gps_utc_model, eph, d_pre_2009_file)); } else if ((line_str.find("GLUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_time_corr_line(glonass_gnav_utc_model)); } else if ((line_str.find("GLGP", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLGP"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(gps_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -4035,16 +3239,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_Iono& gps_ion } } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navMixfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -4055,7 +3250,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp { } // Avoid compiler warning std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -4070,62 +3264,25 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("GPSA", 0) != std::string::npos) { - line_aux += std::string("GPSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_iono_alpha_line(gps_iono)); } else if ((line_str.find("GPUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GPUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(gps_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_T), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_gps_time_corr_line(gps_utc_model)); } else if ((line_str.find("GLUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_time_corr_line(glonass_gnav_utc_model)); } else if ((line_str.find("GLGP", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLGP"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_gps, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_to_gps_time_corr_line(glonass_gnav_utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(gps_utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(gps_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -4143,16 +3300,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Gps_CNAV_Iono& gp } } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navMixfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -4167,7 +3315,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal { } std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -4182,52 +3329,21 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal if (!no_more_finds) { - line_aux.clear(); - if ((line_str.find("GAL", 0) != std::string::npos) && (line_str.find("IONOSPHERIC CORR", 59) != std::string::npos)) { - line_aux += std::string("GAL "); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_iono.ai2, 10, 2), 12); - const double zero = 0.0; - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(zero, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_iono_alpha_line(galileo_iono)); } else if ((line_str.find("GAUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GAUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A0, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(galileo_utc_model.A1, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.tot), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WNot), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_galileo_time_corr_line(galileo_utc_model)); } else if ((line_str.find("GLUT", 0) != std::string::npos) && (line_str.find("TIME SYSTEM CORR", 59) != std::string::npos)) { - line_aux += std::string("GLUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(glonass_gnav_utc_model.d_tau_c, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(0.0, 15, 2), 16); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 7); - line_aux += Rinex_Printer::rightJustify(std::to_string(0.0), 5); - line_aux += std::string(10, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_glonass_time_corr_line(glonass_gnav_utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(galileo_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -4245,16 +3361,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal } } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navMixfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navMixfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -4262,7 +3369,6 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Galileo_Iono& gal void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_Model& utc_model, const Beidou_Dnav_Iono& iono) const { std::vector data; - std::string line_aux; const int64_t pos = out.tellp(); out.seekp(0); @@ -4277,50 +3383,21 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_M if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("BDSA", 0) != std::string::npos) { - line_aux += std::string("BDSA"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.alpha3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_beidou_iono_alpha_line(iono)); } else if (line_str.find("BDSB", 0) != std::string::npos) { - line_aux += std::string("BDSB"); - line_aux += std::string(1, ' '); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta0, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta1, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta2, 10, 2), 12); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(iono.beta3, 10, 2), 12); - line_aux += std::string(7, ' '); - line_aux += Rinex_Printer::leftJustify("IONOSPHERIC CORR", 20); - data.push_back(line_aux); + data.push_back(get_beidou_iono_beta_line(iono)); } else if (line_str.find("BDUT", 0) != std::string::npos) { - line_aux += std::string("BDUT"); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A0_UTC, 16, 2), 18); - line_aux += Rinex_Printer::rightJustify(Rinex_Printer::doub2for(utc_model.A1_UTC, 15, 2), 16); - line_aux += std::string(22, ' '); - line_aux += Rinex_Printer::leftJustify("TIME SYSTEM CORR", 20); - data.push_back(line_aux); + data.push_back(get_beidou_time_corr_line(utc_model)); } else if (line_str.find("LEAP SECONDS", 59) != std::string::npos) { - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -4338,16 +3415,7 @@ void Rinex_Printer::update_nav_header(std::fstream& out, const Beidou_Dnav_Utc_M } } - out.close(); - out.open(navfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(navfilename, std::ios::out | std::ios::app); - out.seekp(pos); + override_stream_with_new_data(out, navfilename, data, pos); std::cout << "The RINEX Navigation file header has been updated with UTC and IONO info.\n"; } @@ -4355,23 +3423,25 @@ 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; - std::map::const_iterator gps_ephemeris_iter; + const auto satsys = satelliteSystem.find("GPS"); + const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; - for (gps_ephemeris_iter = eph_map.cbegin(); - gps_ephemeris_iter != eph_map.cend(); - gps_ephemeris_iter++) + for (const auto& gps_ephemeris_iter : eph_map) { + const auto& eph = gps_ephemeris_iter.second; + // -------- SV / EPOCH / SV CLK - const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(gps_ephemeris_iter->second, gps_ephemeris_iter->second.toc); - const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - 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 std::string seconds(timestring, 13, 2); + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(eph, eph.toc); + if (d_version == 2) { - line += Rinex_Printer::rightJustify(std::to_string(gps_ephemeris_iter->second.PRN), 2); + const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); + 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 std::string seconds(timestring, 13, 2); + line += rightJustify(std::to_string(eph.PRN), 2); line += std::string(1, ' '); const std::string year(timestring, 2, 2); line += year; @@ -4433,368 +3503,151 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.af0, 18, 2); + line += doub2for(eph.af0, 18, 2); line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af1, 18, 2); + line += doub2for(eph.af1, 18, 2); line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af2, 18, 2); + line += doub2for(eph.af2, 18, 2); line += std::string(1, ' '); + lengthCheck(line); + out << line << '\n'; + line.clear(); } if (d_version == 3) { - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - if (gps_ephemeris_iter->second.PRN < 10) - { - line += std::string("0"); - } - line += std::to_string(gps_ephemeris_iter->second.PRN); - const std::string year(timestring, 0, 4); - line += std::string(1, ' '); - line += year; - line += std::string(1, ' '); - line += month; - line += std::string(1, ' '); - line += day; - line += std::string(1, ' '); - line += hour; - line += std::string(1, ' '); - line += minutes; - line += std::string(1, ' '); - line += seconds; - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af1, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af2, 18, 2); + out << get_nav_sv_epoch_svclk_line(p_utc_time, sys_char, eph.PRN, eph.af0, eph.af1, eph.af2) << '\n'; } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; // -------- BROADCAST ORBIT - 1 - line.clear(); + const bool discontinued_reception = eph.IODE_SF2 != eph.IODE_SF3; + out << get_nav_broadcast_orbit(discontinued_reception ? std::optional{} : eph.IODE_SF2, eph.Crs, eph.delta_n, eph.M_0, d_version) << '\n'; - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } // If there is a discontinued reception the ephemeris is not validated - if (gps_ephemeris_iter->second.IODE_SF2 == gps_ephemeris_iter->second.IODE_SF3) - { - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.IODE_SF2, 18, 2); - } - else + if (discontinued_reception) { LOG(WARNING) << "Discontinued reception of Frame 2 and 3"; } - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Crs, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.delta_n, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.M_0, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; // -------- BROADCAST ORBIT - 2 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cuc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.ecc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cus, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.sqrtA, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.Cuc, eph.ecc, eph.Cus, eph.sqrtA, d_version) << '\n'; // -------- BROADCAST ORBIT - 3 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.toe, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cic, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.OMEGA_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cis, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.toe, eph.Cic, eph.OMEGA_0, eph.Cis, d_version) << '\n'; // -------- BROADCAST ORBIT - 4 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.i_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Crc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.omega, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.OMEGAdot, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.i_0, eph.Crc, eph.omega, eph.OMEGAdot, d_version) << '\n'; // -------- BROADCAST ORBIT - 5 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.idot, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.code_on_L2), 18, 2); - line += std::string(1, ' '); + double GPS_week_continuous_number; if (d_pre_2009_file == false) { - if (gps_ephemeris_iter->second.WN < 512) + if (eph.WN < 512) { - GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.WN + 2048); // valid until 2029 + GPS_week_continuous_number = static_cast(eph.WN + 2048); // valid until 2029 } else { - GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.WN + 1024); // valid until April 7, 2019 + GPS_week_continuous_number = static_cast(eph.WN + 1024); // valid until April 7, 2019 } } else { - GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.WN + 1024); + GPS_week_continuous_number = static_cast(eph.WN + 1024); } // This week goes with Toe. This is different from the GPS week in the original satellite message! - if (gps_ephemeris_iter->second.toe < 7200.0) + if (eph.toe < 7200.0) { GPS_week_continuous_number += 1.0; } - line += Rinex_Printer::doub2for(GPS_week_continuous_number, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.code_on_L2), 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + + out << get_nav_broadcast_orbit(eph.idot, static_cast(eph.code_on_L2), GPS_week_continuous_number, static_cast(eph.code_on_L2), d_version) << '\n'; // -------- BROADCAST ORBIT - 6 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.SV_accuracy), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.SV_health), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.TGD, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.IODC, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(static_cast(eph.SV_accuracy), static_cast(eph.SV_health), eph.TGD, eph.IODC, d_version) << '\n'; // -------- BROADCAST ORBIT - 7 - line.clear(); - if (d_version == 2) - { - line += std::string(4, ' '); - } - if (d_version == 3) - { - line += std::string(5, ' '); - } - double tx_time_of_message = gps_ephemeris_iter->second.tow; - if (gps_ephemeris_iter->second.toe < 7200.0) + double tx_time_of_message = eph.tow; + if (eph.toe < 7200.0) { tx_time_of_message -= 604800.0; // see RINEX 3.03 section 6.13 } - line += Rinex_Printer::doub2for(tx_time_of_message, 18, 2); - line += std::string(1, ' '); + int curve_fit_interval = 4; - if (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.PRN) == "IIA") + if (eph.satelliteBlock.at(eph.PRN) == "IIA") { // Block II/IIA (Table 20-XI IS-GPS-200M) - if ((gps_ephemeris_iter->second.IODC > 239) && (gps_ephemeris_iter->second.IODC < 248)) + if ((eph.IODC > 239) && (eph.IODC < 248)) { curve_fit_interval = 8; } - if (((gps_ephemeris_iter->second.IODC > 247) && (gps_ephemeris_iter->second.IODC < 256)) || (gps_ephemeris_iter->second.IODC == 496)) + if (((eph.IODC > 247) && (eph.IODC < 256)) || (eph.IODC == 496)) { curve_fit_interval = 14; } - if ((gps_ephemeris_iter->second.IODC > 496) && (gps_ephemeris_iter->second.IODC < 504)) + if ((eph.IODC > 496) && (eph.IODC < 504)) { curve_fit_interval = 26; } - if ((gps_ephemeris_iter->second.IODC > 503) && (gps_ephemeris_iter->second.IODC < 511)) + if ((eph.IODC > 503) && (eph.IODC < 511)) { curve_fit_interval = 50; } - if (((gps_ephemeris_iter->second.IODC > 751) && (gps_ephemeris_iter->second.IODC < 757)) || (gps_ephemeris_iter->second.IODC == 511)) + if (((eph.IODC > 751) && (eph.IODC < 757)) || (eph.IODC == 511)) { curve_fit_interval = 74; } - if (gps_ephemeris_iter->second.IODC == 757) + if (eph.IODC == 757) { curve_fit_interval = 98; } } - if ((gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.PRN) == "IIR") || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.PRN) == "IIR-M") || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.PRN) == "IIF") || - (gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.PRN) == "III")) + if ((eph.satelliteBlock.at(eph.PRN) == "IIR") || + (eph.satelliteBlock.at(eph.PRN) == "IIR-M") || + (eph.satelliteBlock.at(eph.PRN) == "IIF") || + (eph.satelliteBlock.at(eph.PRN) == "III")) { // Block IIR/IIR-M/IIF/III/IIIF (Table 20-XII IS-GPS-200M) - if ((gps_ephemeris_iter->second.IODC > 239) && (gps_ephemeris_iter->second.IODC < 248)) + if ((eph.IODC > 239) && (eph.IODC < 248)) { curve_fit_interval = 8; } - if (((gps_ephemeris_iter->second.IODC > 247) && (gps_ephemeris_iter->second.IODC < 256)) || (gps_ephemeris_iter->second.IODC == 496)) + if (((eph.IODC > 247) && (eph.IODC < 256)) || (eph.IODC == 496)) { curve_fit_interval = 14; } - if (((gps_ephemeris_iter->second.IODC > 496) && (gps_ephemeris_iter->second.IODC < 504)) || ((gps_ephemeris_iter->second.IODC > 1020) && (gps_ephemeris_iter->second.IODC < 1024))) + if (((eph.IODC > 496) && (eph.IODC < 504)) || ((eph.IODC > 1020) && (eph.IODC < 1024))) { curve_fit_interval = 26; } } - if (curve_fit_interval == 4) - { - line += Rinex_Printer::doub2for(0.0, 18, 2); - } - else - { - line += Rinex_Printer::doub2for(1.0, 18, 2); - } - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); + + out << get_nav_broadcast_orbit(tx_time_of_message, curve_fit_interval == 4 ? 0.0 : 1.0, {}, {}, d_version) << '\n'; } } void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) { - std::string line; - std::map::const_iterator gps_ephemeris_iter; + const auto satsys = satelliteSystem.find("GPS"); + const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; - for (gps_ephemeris_iter = eph_map.cbegin(); - gps_ephemeris_iter != eph_map.cend(); - gps_ephemeris_iter++) + for (const auto& gps_ephemeris_iter : eph_map) { + const auto& eph = gps_ephemeris_iter.second; + // -------- SV / EPOCH / SV CLK - const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(gps_ephemeris_iter->second, gps_ephemeris_iter->second.toc); - const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - 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 std::string seconds(timestring, 13, 2); - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - if (gps_ephemeris_iter->second.PRN < 10) - { - line += std::string("0"); - } - line += std::to_string(gps_ephemeris_iter->second.PRN); - const std::string year(timestring, 0, 4); - line += std::string(1, ' '); - line += year; - line += std::string(1, ' '); - line += month; - line += std::string(1, ' '); - line += day; - line += std::string(1, ' '); - line += hour; - line += std::string(1, ' '); - line += minutes; - line += std::string(1, ' '); - line += seconds; - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af1, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.af2, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_GPS_time(eph, eph.toc); + out << get_nav_sv_epoch_svclk_line(p_utc_time, sys_char, eph.PRN, eph.af0, eph.af1, eph.af2) << '\n'; // -------- BROADCAST ORBIT - 1 - line.clear(); - line += std::string(5, ' '); + // If there is no IODE in CNAV, so we check if Toe in message Type 10, Toe in Message type 11 and Toc in message types 30-37. // Whenever these three terms do not match, a data set cutover has occurred and new data must be collected. // See IS-GPS-200M, paragraph 20.3.3.4.1 - if (!((gps_ephemeris_iter->second.toe1 == gps_ephemeris_iter->second.toe2) && (gps_ephemeris_iter->second.toe1 == gps_ephemeris_iter->second.toc))) // Toe1: Toe in message type 10, Toe2: Toe in message type 11 + if (!((eph.toe1 == eph.toe2) && (eph.toe1 == eph.toc))) // Toe1: Toe in message type 10, Toe2: Toe in message type 11 { // Toe1: Toe in message type 10, Toe2: Toe in message type 11, d_fake_cnav_iode = d_fake_cnav_iode + 1; @@ -4804,296 +3657,115 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.Crs, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.delta_n, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.M_0, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(d_fake_cnav_iode, eph.Crs, eph.delta_n, eph.M_0) << '\n'; // -------- BROADCAST ORBIT - 2 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cuc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.ecc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cus, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.sqrtA, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.Cuc, eph.ecc, eph.Cus, eph.sqrtA) << '\n'; // -------- BROADCAST ORBIT - 3 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(std::max(gps_ephemeris_iter->second.toe1, gps_ephemeris_iter->second.toe2), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cic, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.OMEGA_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Cis, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(std::max(eph.toe1, eph.toe2), eph.Cic, eph.OMEGA_0, eph.Cis) << '\n'; // -------- BROADCAST ORBIT - 4 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.i_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.Crc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.omega, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.OMEGAdot, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.i_0, eph.Crc, eph.omega, eph.OMEGAdot) << '\n'; // -------- BROADCAST ORBIT - 5 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.idot, 18, 2); - line += std::string(1, ' '); - // No data flag for L2 P code - double my_zero = 0.0; - line += Rinex_Printer::doub2for(my_zero, 18, 2); - line += std::string(1, ' '); - auto GPS_week_continuous_number = static_cast(gps_ephemeris_iter->second.WN); + + auto GPS_week_continuous_number = static_cast(eph.WN); // This week goes with Toe. This is different from the GPS week in the original satellite message! - if (gps_ephemeris_iter->second.toe1 < 7200.0) + if (eph.toe1 < 7200.0) { GPS_week_continuous_number += 1.0; } - line += Rinex_Printer::doub2for(GPS_week_continuous_number, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(my_zero, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + + out << get_nav_broadcast_orbit(eph.idot, 0.0, GPS_week_continuous_number, 0.0) << '\n'; // No data flag for L2 P code // -------- BROADCAST ORBIT - 6 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.URA), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(static_cast(gps_ephemeris_iter->second.signal_health), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.TGD, 18, 2); - line += std::string(1, ' '); - // no IODC in CNAV, so we fake it (see above) - line += Rinex_Printer::doub2for(d_fake_cnav_iode, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(static_cast(eph.URA), static_cast(eph.signal_health), eph.TGD, d_fake_cnav_iode) << '\n'; // no IODC in CNAV, so we fake it (see above) // -------- BROADCAST ORBIT - 7 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(gps_ephemeris_iter->second.tow, 18, 2); - line += std::string(1, ' '); - double curve_fit_interval = 0.0; /// ?? Not defined in CNAV - line += Rinex_Printer::doub2for(curve_fit_interval, 18, 2); - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); + out << get_nav_broadcast_orbit(eph.tow, 0.0, {}, {}) << '\n'; // ?? Curve fit interval not defined in CNAV } } void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - std::string line; const auto satsys_gal = satelliteSystem.find("Galileo"); - std::map::const_iterator galileo_ephemeris_iter; - line.clear(); - for (galileo_ephemeris_iter = eph_map.cbegin(); - galileo_ephemeris_iter != eph_map.cend(); - galileo_ephemeris_iter++) + const auto sys_char = satsys_gal != satelliteSystem.cend() ? satsys_gal->second : ""; + + for (const auto& galileo_ephemeris_iter : eph_map) { + const auto& eph = galileo_ephemeris_iter.second; + // -------- SV / EPOCH / SV CLK - const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_Galileo_time(galileo_ephemeris_iter->second, galileo_ephemeris_iter->second.toe); - const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - 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 std::string seconds(timestring, 13, 2); - - if (satsys_gal != satelliteSystem.cend()) - { - line += satsys_gal->second; - } - if (galileo_ephemeris_iter->second.PRN < 10) - { - line += std::string("0"); - } - line += std::to_string(galileo_ephemeris_iter->second.PRN); - const std::string year(timestring, 0, 4); - line += std::string(1, ' '); - line += year; - line += std::string(1, ' '); - line += month; - line += std::string(1, ' '); - line += day; - line += std::string(1, ' '); - line += hour; - line += std::string(1, ' '); - line += minutes; - line += std::string(1, ' '); - line += seconds; - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.af0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.af1, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.af2, 18, 2); - - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_Galileo_time(eph, eph.toe); + out << get_nav_sv_epoch_svclk_line(p_utc_time, sys_char, eph.PRN, eph.af0, eph.af1, eph.af2) << '\n'; // -------- BROADCAST ORBIT - 1 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(static_cast(galileo_ephemeris_iter->second.IOD_ephemeris), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Crs, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.delta_n, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.M_0, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(static_cast(eph.IOD_ephemeris), eph.Crs, eph.delta_n, eph.M_0) << '\n'; // -------- BROADCAST ORBIT - 2 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Cuc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.ecc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Cus, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.sqrtA, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.Cuc, eph.ecc, eph.Cus, eph.sqrtA) << '\n'; // -------- BROADCAST ORBIT - 3 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.toe, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Cic, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.OMEGA_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Cis, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.toe, eph.Cic, eph.OMEGA_0, eph.Cis) << '\n'; // -------- BROADCAST ORBIT - 4 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.i_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.Crc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.omega, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.OMEGAdot, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.i_0, eph.Crc, eph.omega, eph.OMEGAdot) << '\n'; // -------- BROADCAST ORBIT - 5 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.idot, 18, 2); - line += std::string(1, ' '); - // double one = 1.0; // INAV E1-B - std::string iNAVE1B("1000000001"); - int32_t data_source_INAV = Rinex_Printer::toInt(iNAVE1B, 10); - line += Rinex_Printer::doub2for(static_cast(data_source_INAV), 18, 2); - line += std::string(1, ' '); - auto GST_week = static_cast(galileo_ephemeris_iter->second.WN); - double num_GST_rollovers = floor((GST_week + 1024.0) / 4096.0); - double Galileo_week_continuous_number = GST_week + 1024.0 + num_GST_rollovers * 4096.0; - line += Rinex_Printer::doub2for(Galileo_week_continuous_number, 18, 2); - line += std::string(1, ' '); - const double zero = 0.0; - line += Rinex_Printer::doub2for(zero, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + const std::string iNAVE1B("1000000001"); + const int32_t data_source_INAV = static_cast(toInt(iNAVE1B, 10)); + + const auto GST_week = static_cast(eph.WN); + const double num_GST_rollovers = floor((GST_week + 1024.0) / 4096.0); + const double Galileo_week_continuous_number = GST_week + 1024.0 + num_GST_rollovers * 4096.0; + + out << get_nav_broadcast_orbit(eph.idot, data_source_INAV, Galileo_week_continuous_number, 0.0) << '\n'; // -------- BROADCAST ORBIT - 6 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.SISA, 18, 2); - line += std::string(1, ' '); std::string E1B_HS; std::string E5B_HS; - if (galileo_ephemeris_iter->second.E1B_HS == 0) + if (eph.E1B_HS == 0) { E1B_HS = "00"; } - if (galileo_ephemeris_iter->second.E1B_HS == 1) + if (eph.E1B_HS == 1) { E1B_HS = "01"; } - if (galileo_ephemeris_iter->second.E1B_HS == 2) + if (eph.E1B_HS == 2) { E1B_HS = "10"; } - if (galileo_ephemeris_iter->second.E1B_HS == 3) + if (eph.E1B_HS == 3) { E1B_HS = "11"; } - if (galileo_ephemeris_iter->second.E5b_HS == 0) + if (eph.E5b_HS == 0) { E5B_HS = "00"; } - if (galileo_ephemeris_iter->second.E5b_HS == 1) + if (eph.E5b_HS == 1) { E5B_HS = "01"; } - if (galileo_ephemeris_iter->second.E5b_HS == 2) + if (eph.E5b_HS == 2) { E5B_HS = "10"; } - if (galileo_ephemeris_iter->second.E5b_HS == 3) + if (eph.E5b_HS == 3) { E5B_HS = "11"; } - std::string E1B_DVS = std::to_string(galileo_ephemeris_iter->second.E1B_DVS); - - std::string SVhealth_str = std::move(E5B_HS) + std::to_string(galileo_ephemeris_iter->second.E5b_DVS) + "11" + "1" + std::move(E1B_DVS) + std::move(E1B_HS) + std::to_string(galileo_ephemeris_iter->second.E1B_DVS); - int32_t SVhealth = Rinex_Printer::toInt(SVhealth_str, 9); - line += Rinex_Printer::doub2for(static_cast(SVhealth), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.BGD_E1E5a, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.BGD_E1E5b, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + std::string E1B_DVS = std::to_string(eph.E1B_DVS); + const std::string SVhealth_str = std::move(E5B_HS) + std::to_string(eph.E5b_DVS) + "11" + "1" + std::move(E1B_DVS) + std::move(E1B_HS) + std::to_string(eph.E1B_DVS); + const auto SVhealth = static_cast(toInt(SVhealth_str, 9)); + out << get_nav_broadcast_orbit(eph.SISA, SVhealth, eph.BGD_E1E5a, eph.BGD_E1E5b) << '\n'; // -------- BROADCAST ORBIT - 7 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(galileo_ephemeris_iter->second.tow, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(zero, 18, 2); - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); + out << get_nav_broadcast_orbit(eph.tow, 0.0, {}, {}) << '\n'; } } @@ -5101,14 +3773,15 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { std::string line; - std::map::const_iterator glonass_gnav_ephemeris_iter; + const auto satsys = satelliteSystem.find("GLONASS"); + const auto sys_char = satsys != satelliteSystem.cend() ? satsys->second : ""; - for (glonass_gnav_ephemeris_iter = eph_map.cbegin(); - glonass_gnav_ephemeris_iter != eph_map.cend(); - glonass_gnav_ephemeris_iter++) + for (const auto& glonass_gnav_ephemeris_iter : eph_map) { + const auto& eph = glonass_gnav_ephemeris_iter.second; + // -------- SV / EPOCH / SV CLK - const boost::posix_time::ptime p_utc_time = glonass_gnav_ephemeris_iter->second.glot_to_utc(glonass_gnav_ephemeris_iter->second.d_t_b, 0.0); + const boost::posix_time::ptime p_utc_time = eph.glot_to_utc(eph.d_t_b, 0.0); const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); const std::string month(timestring, 4, 2); const std::string day(timestring, 6, 2); @@ -5117,7 +3790,7 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.PRN), 2); + line += rightJustify(std::to_string(eph.PRN), 2); line += std::string(1, ' '); const std::string year(timestring, 2, 2); line += year; @@ -5179,125 +3852,29 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.d_tau_c, 18, 2); + line += doub2for(-eph.d_tau_c, 18, 2); line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_gamma_n, 18, 2); + line += doub2for(eph.d_gamma_n, 18, 2); line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_t_k, 18, 2); + line += doub2for(eph.d_t_k, 18, 2); line += std::string(1, ' '); } if (d_version == 3) { - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - if (glonass_gnav_ephemeris_iter->second.PRN < 10) - { - line += std::string("0"); - } - line += std::to_string(glonass_gnav_ephemeris_iter->second.PRN); - const std::string year(timestring, 0, 4); - line += std::string(1, ' '); - line += year; - line += std::string(1, ' '); - line += month; - line += std::string(1, ' '); - line += day; - line += std::string(1, ' '); - line += hour; - line += std::string(1, ' '); - line += minutes; - line += std::string(1, ' '); - line += seconds; - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(-glonass_gnav_ephemeris_iter->second.d_tau_n, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(+glonass_gnav_ephemeris_iter->second.d_gamma_n, 18, 2); - line += std::string(1, ' '); - // TODO need to define this here. what is nd - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_t_k + p_utc_time.date().day_of_week() * 86400, 18, 2); + out << get_nav_sv_epoch_svclk_line(p_utc_time, sys_char, eph.PRN, -eph.d_tau_n, +eph.d_gamma_n, eph.d_t_k + p_utc_time.date().day_of_week() * 86400) << '\n'; } - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; + line.clear(); // -------- BROADCAST ORBIT - 1 - line.clear(); - // TODO Why is this happening here?. The extra space maybe is intended to help with readability - if (d_version == 2) - { - line += std::string(3, ' '); - } - if (d_version == 3) - { - line += std::string(4, ' '); - } - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_Xn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_VXn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_AXn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_B_n, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.d_Xn, eph.d_VXn, eph.d_AXn, eph.d_B_n, d_version) << '\n'; // -------- BROADCAST ORBIT - 2 - line.clear(); - if (d_version == 2) - { - line += std::string(3, ' '); - } - if (d_version == 3) - { - line += std::string(4, ' '); - } - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_Yn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_VYn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_AYn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.i_satellite_freq_channel, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.d_Yn, eph.d_VYn, eph.d_AYn, eph.i_satellite_freq_channel, d_version) << '\n'; // -------- BROADCAST ORBIT - 3 - line.clear(); - if (d_version == 2) - { - line += std::string(3, ' '); - } - if (d_version == 3) - { - line += std::string(4, ' '); - } - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_Zn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_VZn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_AZn, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(glonass_gnav_ephemeris_iter->second.d_E_n, 18, 2); - if (d_version == 2) - { - line += std::string(1, ' '); - } - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); + out << get_nav_broadcast_orbit(eph.d_Zn, eph.d_VZn, eph.d_AZn, eph.d_E_n, d_version) << '\n'; } } @@ -5345,147 +3922,37 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::map& eph_map) const { - std::string line; - std::map::const_iterator bds_ephemeris_iter; + const auto satsys_bds = satelliteSystem.find("Beidou"); + const auto sys_char = satsys_bds != satelliteSystem.cend() ? satsys_bds->second : ""; - for (bds_ephemeris_iter = eph_map.cbegin(); - bds_ephemeris_iter != eph_map.cend(); - bds_ephemeris_iter++) + for (const auto& bds_ephemeris_iter : eph_map) { - // -------- SV / EPOCH / SV CLK - const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_BDS_time(bds_ephemeris_iter->second, bds_ephemeris_iter->second.toc); - const std::string timestring = boost::posix_time::to_iso_string(p_utc_time); - 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 std::string seconds(timestring, 13, 2); + const auto& eph = bds_ephemeris_iter.second; - const auto satsys_bds = satelliteSystem.find("Beidou"); - if (satsys_bds != satelliteSystem.cend()) - { - line += satsys_bds->second; - } - if (bds_ephemeris_iter->second.PRN < 10) - { - line += std::string("0"); - } - line += std::to_string(bds_ephemeris_iter->second.PRN); - const std::string year(timestring, 0, 4); - line += std::string(1, ' '); - line += year; - line += std::string(1, ' '); - line += month; - line += std::string(1, ' '); - line += day; - line += std::string(1, ' '); - line += hour; - line += std::string(1, ' '); - line += minutes; - line += std::string(1, ' '); - line += seconds; - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.af0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.af1, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.af2, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // -------- SV / EPOCH / SV CLK + const boost::posix_time::ptime p_utc_time = Rinex_Printer::compute_BDS_time(eph, eph.toc); + out << get_nav_sv_epoch_svclk_line(p_utc_time, sys_char, eph.PRN, eph.af0, eph.af1, eph.af2) << '\n'; // -------- BROADCAST ORBIT - 1 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.AODE, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Crs, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.delta_n, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.M_0, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.AODE, eph.Crs, eph.delta_n, eph.M_0) << '\n'; // -------- BROADCAST ORBIT - 2 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Cuc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.ecc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Cus, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.sqrtA, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.Cuc, eph.ecc, eph.Cus, eph.sqrtA) << '\n'; // -------- BROADCAST ORBIT - 3 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.toe, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Cic, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.OMEGA_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Cis, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.toe, eph.Cic, eph.OMEGA_0, eph.Cis) << '\n'; // -------- BROADCAST ORBIT - 4 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.i_0, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.Crc, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.omega, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.OMEGAdot, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(eph.i_0, eph.Crc, eph.omega, eph.OMEGAdot) << '\n'; // -------- BROADCAST ORBIT - 5 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.idot, 18, 2); - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - line += std::string(1, ' '); - auto BDS_week_continuous_number = static_cast(bds_ephemeris_iter->second.WN); - line += Rinex_Printer::doub2for(BDS_week_continuous_number, 18, 2); - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - + out << get_nav_broadcast_orbit(eph.idot, {}, static_cast(eph.WN), {}) << '\n'; // -------- BROADCAST ORBIT - 6 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(static_cast(bds_ephemeris_iter->second.SV_accuracy), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(static_cast(bds_ephemeris_iter->second.SV_health), 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.TGD1, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.TGD2, 18, 2); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_nav_broadcast_orbit(static_cast(eph.SV_accuracy), static_cast(eph.SV_health), eph.TGD1, eph.TGD2) << '\n'; // -------- BROADCAST ORBIT - 7 - line.clear(); - line += std::string(5, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.tow, 18, 2); - line += std::string(1, ' '); - line += Rinex_Printer::doub2for(bds_ephemeris_iter->second.AODC, 18, 2); - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - line += std::string(1, ' '); - line += std::string(18, ' '); // spare - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); + out << get_nav_broadcast_orbit(eph.tow, eph.AODC, {}, {}) << '\n'; } } @@ -5502,7 +3969,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_glo = satelliteSystem.find("GLONASS"); if (satsys_glo != satelliteSystem.cend()) { @@ -5510,21 +3977,21 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); if (d_version == 2) { - line += Rinex_Printer::leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); + line += leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); } if (d_version == 3) { - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); } - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -5532,228 +3999,101 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("GLONASS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER NUMBER", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER NUMBER", 20); + lengthCheck(line); out << line << '\n'; } if (d_version == 3) { line.clear(); - line += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER TYPE", 20); + lengthCheck(line); out << line << '\n'; } - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES if (d_version == 3) { // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - const auto satsys = satelliteSystem.find("GLONASS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = 4; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - - std::string signal_ = "1G"; - const std::size_t found_1G = glonass_bands.find(signal_); - signal_ = "2G"; - const std::size_t found_2G = glonass_bands.find(signal_); - - if (found_1G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G1_CA"]; - } - - if (found_2G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G2_CA"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_glonass(out, glonass_bands, observationType, observationCode); } if (d_version == 2) { // -------- SYS / OBS TYPES line.clear(); std::stringstream strm; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 6); + strm << 4; + line += rightJustify(strm.str(), 6); // per type of observation // GLONASS L1 C/A PSEUDORANGE - line += Rinex_Printer::rightJustify(observationType["PSEUDORANGE_CA_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS L1 PHASE - line += Rinex_Printer::rightJustify(observationType["CARRIER_PHASE_CA_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS DOPPLER L1 - line += Rinex_Printer::rightJustify(observationType["DOPPLER_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("DOPPLER_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS L1 SIGNAL STRENGTH - line += Rinex_Printer::rightJustify(observationType["SIGNAL_STRENGTH_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("# / TYPES OF OBSERV", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("# / TYPES OF OBSERV", 20); + lengthCheck(line); out << line << '\n'; } // -------- Signal Strength units (Only version 3) if (d_version == 3) { - // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); } // -------- TIME OF FIRST OBS @@ -5767,16 +4107,16 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem double intpart = 0; const double seconds = p_utc_time.time_of_day().seconds() + modf(d_TOW_first_observation, &intpart); line.clear(); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GLO"), 8); + 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 += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("TIME OF FIRST OBS", 20); + lengthCheck(line); out << line << '\n'; // -------- GLONASS SLOT / FRQ # (On;y d_version 3) @@ -5785,57 +4125,53 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem // -------- GLONASS SLOT / FRQ # // TODO Need to provide system with list of all satellites and update this accordingly line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list + 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 += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number + line += rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number + line += rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS SLOT / FRQ #", 20); + lengthCheck(line); out << line << '\n'; // -------- GLONASS CODE/PHS/BIS // No GLONASS Phase bias correction used to align code and phase observations. line.clear(); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS COD/PHS/BIS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS COD/PHS/BIS", 20); + lengthCheck(line); out << line << '\n'; } // -------- END OF HEADER - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -5850,7 +4186,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -5858,14 +4194,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -5873,287 +4209,110 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GPS/GLO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER NUMBER", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER NUMBER", 20); + lengthCheck(line); out << line << '\n'; } if (d_version == 3) { line.clear(); - line += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER TYPE", 20); + lengthCheck(line); out << line << '\n'; } // -------- Line MARKER TYPE line.clear(); - line += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + line += leftJustify("NON_GEODETIC", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + line += leftJustify("MARKER TYPE", 20); lengthCheck(line); out << line << '\n'; - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES if (d_version == 3) { - // one line per available system - line.clear(); - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = 4; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // GPS line + add_obs_sys_obs_type_gps(out, "1C", observationType, observationCode); - // Find GLONASS Signal in Mixed file - uint32_t number_of_observations_glo = 0; - std::string signal_("1G"); - const std::size_t found_1G = glonass_bands.find(signal_); - if (found_1G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } - signal_ = "2G"; - const std::size_t found_2G = glonass_bands.find(signal_); - if (found_2G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } - line.clear(); - const auto satsys_glo = satelliteSystem.find("GLONASS"); - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); - if (found_1G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G1_CA"]; - } - if (found_2G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G2_CA"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // Glonass line + add_obs_sys_obs_type_glonass(out, glonass_bands, observationType, observationCode); } if (d_version == 2) { // -------- SYS / OBS TYPES line.clear(); std::stringstream strm; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 6); + strm << 4; + line += rightJustify(strm.str(), 6); // per type of observation // GLONASS L1 C/A PSEUDORANGE - line += Rinex_Printer::rightJustify(observationType["PSEUDORANGE_CA_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS L1 PHASE - line += Rinex_Printer::rightJustify(observationType["CARRIER_PHASE_CA_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS DOPPLER L1 - line += Rinex_Printer::rightJustify(observationType["DOPPLER_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("DOPPLER_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); // GLONASS L1 SIGNAL STRENGTH - line += Rinex_Printer::rightJustify(observationType["SIGNAL_STRENGTH_v2"], 5); - line += observationCode["GLONASS_G1_CA_v2"]; + line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); + line += observationCode.at("GLONASS_G1_CA_v2"); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("# / TYPES OF OBSERV", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("# / TYPES OF OBSERV", 20); + lengthCheck(line); out << line << '\n'; } // -------- Signal Strength units (only version 3) if (d_version == 3) { - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); } // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); // -------- GLONASS SLOT / FRQ # (On;y version 3) if (d_version == 3) @@ -6161,57 +4320,53 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps // -------- GLONASS SLOT / FRQ # // TODO Need to provide system with list of all satellites and update this accordingly line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list + 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 += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number + line += rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number + line += rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS SLOT / FRQ #", 20); + lengthCheck(line); out << line << '\n'; // -------- GLONASS CODE/PHS/BIS // No GLONASS Phase bias correction used to align code and phase observations. line.clear(); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS COD/PHS/BIS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS COD/PHS/BIS", 20); + lengthCheck(line); out << line << '\n'; } // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -6226,7 +4381,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -6234,14 +4389,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -6249,308 +4404,130 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GPS/GLO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER NUMBER", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER NUMBER", 20); + lengthCheck(line); out << line << '\n'; } if (d_version == 3) { line.clear(); - line += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("MARKER TYPE", 20); + lengthCheck(line); out << line << '\n'; } - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = 4; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - // Find GLONASS Signal in Mixed file - uint32_t number_of_observations_glo = 0; - std::string signal_("1G"); - const std::size_t found_1G = glonass_bands.find(signal_); - if (found_1G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } - signal_ = "2G"; - const std::size_t found_2G = glonass_bands.find(signal_); - if (found_2G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } + // GPS line + add_obs_sys_obs_type_gps(out, "2S", observationType, observationCode); + + // Glonass line + add_obs_sys_obs_type_glonass(out, glonass_bands, observationType, observationCode); + + // -------- Signal Strength units (only version 3) + 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); + + + // -------- 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 += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); - if (found_1G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G1_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G1_CA"]; - } - if (found_2G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_G2_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_G2_CA"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Signal Strength units (only version 3) - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- TIME OF FIRST OBS - line.clear(); - const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_cnav_eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- GLONASS SLOT / FRQ # - // TODO Need to provide system with list of all satellites and update this accordingly - line.clear(); - line += Rinex_Printer::rightJustify(std::to_string(0), 3); // Number of satellites in list + line += rightJustify(std::to_string(0), 2); // Slot Number line += std::string(1, ' '); - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } - line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Slot Number - line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(std::to_string(0), 2); // Frequency Number + line += rightJustify(std::to_string(0), 2); // Frequency Number line += std::string(1, ' '); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS SLOT / FRQ #", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS SLOT / FRQ #", 20); + lengthCheck(line); out << line << '\n'; // -------- GLONASS CODE/PHS/BIS // No GLONASS Phase bias correction used to align code and phase observations. line.clear(); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G1_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G1_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_CA"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_CA"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_G2_P"]; + line += observationType.at("PSEUDORANGE"); + line += observationCode.at("GLONASS_G2_P"); line += std::string(1, ' '); - line += Rinex_Printer::rightJustify(asString(0.0, 3), 8); + line += rightJustify(asString(0.0, 3), 8); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("GLONASS COD/PHS/BIS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("GLONASS COD/PHS/BIS", 20); + lengthCheck(line); out << line << '\n'; // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -6566,7 +4543,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line = std::string(5, ' '); line += "3.02"; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -6574,14 +4551,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -6589,296 +4566,63 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GALILEO/GLONASS) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + line += leftJustify("NON_GEODETIC", 20); // put a flag or a property line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + line += leftJustify("MARKER TYPE", 20); lengthCheck(line); out << line << '\n'; - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - line.clear(); - uint32_t number_of_observations_gal = 0; - std::string signal_("1B"); - const std::size_t found_1B = galileo_bands.find(signal_); - if (found_1B != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "5X"; - const std::size_t found_5X = galileo_bands.find(signal_); - if (found_5X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - line.clear(); - signal_ = "7X"; - const std::size_t found_7X = galileo_bands.find(signal_); - if (found_7X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } + // Galileo line + add_obs_sys_obs_type_galileo(out, galileo_bands, observationType, observationCode); - signal_ = "E6"; - const std::size_t found_E6 = galileo_bands.find(signal_); - if (found_E6 != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - - const auto satsys = satelliteSystem.find("Galileo"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); - - if (found_1B != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E1_B"]; - } - - if (found_5X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5a_IQ"]; - } - - if (found_7X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5b_IQ"]; - } - - if (found_E6 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E56_B"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - line.clear(); - uint32_t number_of_observations_glo = 0; - signal_ = "1G"; - const std::size_t found_1G = glonass_bands.find(signal_); - if (found_1G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } - signal_ = "2G"; - const std::size_t found_2G = glonass_bands.find(signal_); - if (found_2G != std::string::npos) - { - number_of_observations_glo = number_of_observations_glo + 4; - } - - const auto satsys_glo = satelliteSystem.find("GLONASS"); - if (satsys_glo != satelliteSystem.cend()) - { - line += satsys_glo->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_glo), 3); - - if (found_1G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_L1_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_L1_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_L1_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_L1_CA"]; - } - - if (found_2G != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GLONASS_L2_CA"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GLONASS_L2_CA"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GLONASS_L2_CA"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GLONASS_L2_CA"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // Glonass line + add_obs_sys_obs_type_glonass(out, glonass_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS line.clear(); @@ -6891,24 +4635,20 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& const std::string minutes(timestring, 11, 2); const double galileo_t = d_TOW_first_observation; const double seconds = fmod(galileo_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("Galileo"), 8); + 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 += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("TIME OF FIRST OBS", 20); + lengthCheck(line); out << line << '\n'; // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -6920,7 +4660,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { @@ -6928,21 +4668,21 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); if (d_version == 2) { - line += Rinex_Printer::leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); + line += leftJustify("BLANK OR G = GPS, R = GLONASS, E = GALILEO, M = MIXED", 60); } if (d_version == 3) { - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); } - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -6950,171 +4690,70 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); if (d_version == 2) { // --------- WAVELENGTH FACTOR // put here real data! line.clear(); - line += Rinex_Printer::rightJustify("1", 6); - line += Rinex_Printer::rightJustify("1", 6); + line += rightJustify("1", 6); + line += rightJustify("1", 6); line += std::string(48, ' '); - line += Rinex_Printer::leftJustify("WAVELENGTH FACT L1/2", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("WAVELENGTH FACT L1/2", 20); + lengthCheck(line); out << line << '\n'; } if (d_version == 3) { // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - const auto satsys = satelliteSystem.find("GPS"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = 4; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_gps(out, "1C", observationType, observationCode); } if (d_version == 2) @@ -7122,69 +4761,42 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph // -------- SYS / OBS TYPES line.clear(); std::stringstream strm; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 6); + strm << 4; + line += rightJustify(strm.str(), 6); // per type of observation // GPS L1 PSEUDORANGE - line += Rinex_Printer::rightJustify(observationType["PSEUDORANGE_CA_v2"], 5); - line += observationCode["GPS_L1_CA_v2"]; + line += rightJustify(observationType.at("PSEUDORANGE_CA_v2"), 5); + line += observationCode.at("GPS_L1_CA_v2"); // GPS L1 PHASE - line += Rinex_Printer::rightJustify(observationType["CARRIER_PHASE_CA_v2"], 5); - line += observationCode["GPS_L1_CA_v2"]; + line += rightJustify(observationType.at("CARRIER_PHASE_CA_v2"), 5); + line += observationCode.at("GPS_L1_CA_v2"); // GPS DOPPLER L1 - line += Rinex_Printer::rightJustify(observationType["DOPPLER_v2"], 5); - line += observationCode["GPS_L1_CA_v2"]; + line += rightJustify(observationType.at("DOPPLER_v2"), 5); + line += observationCode.at("GPS_L1_CA_v2"); // GPS L1 SIGNAL STRENGTH - line += Rinex_Printer::rightJustify(observationType["SIGNAL_STRENGTH_v2"], 5); - line += observationCode["GPS_L1_CA_v2"]; + line += rightJustify(observationType.at("SIGNAL_STRENGTH_v2"), 5); + line += observationCode.at("GPS_L1_CA_v2"); line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("# / TYPES OF OBSERV", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("# / TYPES OF OBSERV", 20); + lengthCheck(line); out << line << '\n'; } if (d_version == 3) { // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); } // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + // -------- SYS /PHASE SHIFTS // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -7196,7 +4808,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { @@ -7204,14 +4816,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -7219,231 +4831,68 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - uint32_t number_of_observations_gps = 0; - std::string signal_("2S"); - const std::size_t found_2S = gps_bands.find(signal_); - if (found_2S != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "L5"; - const std::size_t found_L5 = gps_bands.find(signal_); - if (found_L5 != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = number_of_observations_gps; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - - if (found_2S != std::string::npos) - { - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; - } - - if (found_L5 != std::string::npos) - { - // GPS L5 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L5_Q"]; - // GPS DOPPLER L5 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L5_Q"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); + // -------- SYS /PHASE SHIFTS // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -7458,7 +4907,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line = std::string(5, ' '); line += d_stringVersion; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_gps = satelliteSystem.find("GPS"); if (satsys_gps != satelliteSystem.cend()) { @@ -7466,14 +4915,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -7481,255 +4930,67 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("GPS OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("GROUND_CRAFT", 20); // put a flag or a property + // line += leftJustify("GROUND_CRAFT", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - uint32_t number_of_observations_gps = 0; - std::string signal_("1C"); - const std::size_t found_1C = gps_bands.find(signal_); - if (found_1C != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "2S"; - const std::size_t found_2S = gps_bands.find(signal_); - if (found_2S != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "L5"; - const std::size_t found_L5 = gps_bands.find(signal_); - if (found_L5 != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = number_of_observations_gps; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - if (found_1C != std::string::npos) - { - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - } - if (found_2S != std::string::npos) - { - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; - } - - if (found_L5 != std::string::npos) - { - // GPS L5 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L5_Q"]; - // GPS DOPPLER L5 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L5_Q"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); // -------- SYS /PHASE SHIFTS // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -7750,7 +5011,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line = std::string(5, ' '); line += "3.02"; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -7758,14 +5019,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -7773,352 +5034,70 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - uint32_t number_of_observations_gps = 0; - std::string signal_("1C"); - const std::size_t found_1C = gps_bands.find(signal_); - if (found_1C != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "2S"; - const std::size_t found_2S = gps_bands.find(signal_); - if (found_2S != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "L5"; - const std::size_t found_L5 = gps_bands.find(signal_); - if (found_L5 != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = number_of_observations_gps; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - if (found_1C != std::string::npos) - { - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - } - if (found_2S != std::string::npos) - { - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; - } - if (found_L5 != std::string::npos) - { - // GPS L5 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L5_Q"]; - // GPS DOPPLER L5 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L5_Q"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); - uint32_t number_of_observations_gal = 0; - signal_ = "1B"; - const std::size_t found_1B = galileo_bands.find(signal_); - if (found_1B != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "5X"; - const std::size_t found_5X = galileo_bands.find(signal_); - if (found_5X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "7X"; - const std::size_t found_7X = galileo_bands.find(signal_); - if (found_7X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } + // GPS line + add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); - signal_ = "E6"; - const std::size_t found_E6 = galileo_bands.find(signal_); - if (found_E6 != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - const auto satsys = satelliteSystem.find("Galileo"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); - if (found_1B != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E1_B"]; - } - if (found_5X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5a_IQ"]; - } - if (found_7X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5b_IQ"]; - } - if (found_E6 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E56_B"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // Galileo line + add_obs_sys_obs_type_galileo(out, galileo_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -8134,7 +5113,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line = std::string(5, ' '); line += "3.02"; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -8142,14 +5121,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -8157,327 +5136,70 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - uint32_t number_of_observations_gps = 0; - std::string signal_("2S"); - const std::size_t found_2S = gps_bands.find(signal_); - if (found_2S != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - signal_ = "L5"; - const std::size_t found_L5 = gps_bands.find(signal_); - if (found_L5 != std::string::npos) - { - number_of_observations_gps = number_of_observations_gps + 4; - } - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = number_of_observations_gps; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - if (found_2S != std::string::npos) - { - // GPS L2 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS DOPPLER L2 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L2_L2CM"]; - // GPS L2 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L2_L2CM"]; - } - if (found_L5 != std::string::npos) - { - // GPS L5 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L5_Q"]; - // GPS DOPPLER L5 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L5_Q"]; - // GPS L5 SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L5_Q"]; - } - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); - uint32_t number_of_observations_gal = 0; - signal_ = "1B"; - const std::size_t found_1B = galileo_bands.find(signal_); - if (found_1B != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "5X"; - const std::size_t found_5X = galileo_bands.find(signal_); - if (found_5X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "7X"; - const std::size_t found_7X = galileo_bands.find(signal_); - if (found_7X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "E6"; - const std::size_t found_E6 = galileo_bands.find(signal_); - if (found_E6 != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - const auto satsys = satelliteSystem.find("Galileo"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); - if (found_1B != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E1_B"]; - } - if (found_5X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5a_IQ"]; - } - if (found_7X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5b_IQ"]; - } - if (found_E6 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E56_B"]; - } + // GPS line + add_obs_sys_obs_type_gps(out, gps_bands, observationType, observationCode); - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // Galileo line + add_obs_sys_obs_type_galileo(out, galileo_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(eph_cnav, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -8497,7 +5219,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += "3.02"; } line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys = satelliteSystem.find("Galileo"); if (satsys != satelliteSystem.cend()) { @@ -8505,14 +5227,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -8520,237 +5242,59 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("GALILEO OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - uint32_t number_of_observations = 0; - std::string signal_("1B"); - const std::size_t found_1B = bands.find(signal_); - if (found_1B != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - signal_ = "5X"; - const std::size_t found_5X = bands.find(signal_); - if (found_5X != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - signal_ = "7X"; - const std::size_t found_7X = bands.find(signal_); - if (found_7X != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - - signal_ = "E6"; - const std::size_t found_E6 = bands.find(signal_); - if (found_E6 != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - - line.clear(); - - const auto satsys_gal = satelliteSystem.find("Galileo"); - if (satsys_gal != satelliteSystem.cend()) - { - line += satsys_gal->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); - - if (found_1B != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E1_B"]; - } - - if (found_5X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5a_IQ"]; - } - - if (found_7X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5b_IQ"]; - } - - if (found_E6 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E56_B"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_galileo(out, bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS line.clear(); @@ -8763,26 +5307,22 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& const std::string minutes(timestring, 11, 2); const double galileo_t = d_TOW_first_observation; const double seconds = fmod(galileo_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GAL"), 8); + 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 += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("TIME OF FIRST OBS", 20); + lengthCheck(line); out << line << '\n'; // -------- SYS /PHASE SHIFTS // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -8798,7 +5338,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line = std::string(5, ' '); line += "3.02"; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_mix = satelliteSystem.find("Mixed"); if (satsys_mix != satelliteSystem.cend()) { @@ -8806,14 +5346,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("G = GPS R = GLONASS E = GALILEO S = GEO M = MIXED", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line 3 @@ -8821,300 +5361,70 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("MIXED (GPS/GALILEO) OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify("NON_GEODETIC", 20); // put a flag or a property + // line += leftJustify("NON_GEODETIC", 20); // put a flag or a property // line += std::string(40, ' '); - // line += Rinex_Printer::leftJustify("MARKER TYPE", 20); - // Rinex_Printer::lengthCheck(line); + // line += leftJustify("MARKER TYPE", 20); + // lengthCheck(line); // out << line << '\n'; - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); - lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - line.clear(); - const auto satsys_gps = satelliteSystem.find("GPS"); - if (satsys_gps != satelliteSystem.cend()) - { - line += satsys_gps->second; - } - line += std::string(2, ' '); - std::stringstream strm; - d_numberTypesObservations = 4; - strm << d_numberTypesObservations; - line += Rinex_Printer::rightJustify(strm.str(), 3); - // per type of observation - // GPS L1 PSEUDORANGE - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 PHASE - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GPS_L1_CA"]; - // GPS DOPPLER L1 - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GPS_L1_CA"]; - // GPS L1 CA SIGNAL STRENGTH - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GPS_L1_CA"]; - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - line.clear(); - uint32_t number_of_observations_gal = 0; - std::string signal_("1B"); - const std::size_t found_1B = galileo_bands.find(signal_); - if (found_1B != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - signal_ = "5X"; - const std::size_t found_5X = galileo_bands.find(signal_); - if (found_5X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } + // GPS line + add_obs_sys_obs_type_gps(out, "1C", observationType, observationCode); - signal_ = "7X"; - const std::size_t found_7X = galileo_bands.find(signal_); - if (found_7X != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - - signal_ = "E6"; - const std::size_t found_E6 = galileo_bands.find(signal_); - if (found_E6 != std::string::npos) - { - number_of_observations_gal = number_of_observations_gal + 4; - } - - line.clear(); - const auto satsys = satelliteSystem.find("Galileo"); - if (satsys != satelliteSystem.cend()) - { - line += satsys->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations_gal), 3); - - if (found_1B != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E1_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E1_B"]; - } - - if (found_5X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5a_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5a_IQ"]; - } - - if (found_7X != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E5b_IQ"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E5b_IQ"]; - } - - if (found_E6 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["GALILEO_E56_B"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["GALILEO_E56_B"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + // Galileo line + add_obs_sys_obs_type_galileo(out, galileo_bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS - line.clear(); const boost::posix_time::ptime p_gps_time = Rinex_Printer::compute_GPS_time(gps_eph, d_TOW_first_observation); - const std::string timestring = boost::posix_time::to_iso_string(p_gps_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 gps_t = d_TOW_first_observation; - const double seconds = fmod(gps_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("GPS"), 8); - line += std::string(9, ' '); - line += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_time_first_obs(out, p_gps_time, d_TOW_first_observation); // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -9127,7 +5437,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line = std::string(5, ' '); line += "3.02"; line += std::string(11, ' '); - line += Rinex_Printer::leftJustify("OBSERVATION DATA", 20); + line += leftJustify("OBSERVATION DATA", 20); const auto satsys_bds = satelliteSystem.find("Beidou"); if (satsys_bds != satelliteSystem.cend()) { @@ -9135,14 +5445,14 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme } line += std::string(19, ' '); line += std::string("RINEX VERSION / TYPE"); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line 2 line.clear(); - line += Rinex_Printer::leftJustify("G = GPS R = GLONASS E = GALILEO C = BEIDOU S = GEO M = MIXED", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 @@ -9150,182 +5460,50 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line += Rinex_Printer::getLocalTime(); line += std::string("PGM / RUN BY / DATE"); line += std::string(1, ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("BEIDOU OBSERVATION DATA FILE GENERATED BY GNSS-SDR", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + 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 += Rinex_Printer::leftJustify(gnss_sdr_version, 43); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify(gnss_sdr_version, 43); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line COMMENT line.clear(); - line += Rinex_Printer::leftJustify("See https://gnss-sdr.org", 60); - line += Rinex_Printer::leftJustify("COMMENT", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("See https://gnss-sdr.org", 60); + line += leftJustify("COMMENT", 20); + lengthCheck(line); out << line << '\n'; // -------- Line MARKER NAME line.clear(); - line += Rinex_Printer::leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, - line += Rinex_Printer::leftJustify("MARKER NAME", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line OBSERVER / AGENCY - line.clear(); - 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 += Rinex_Printer::leftJustify("CTTC", 40); // add flag and property - line += Rinex_Printer::leftJustify("OBSERVER / AGENCY", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; - - // -------- Line REC / TYPE VERS - line.clear(); - line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property - line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property - // line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) - { - gnss_sdr_version.resize(9, ' '); - } - line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); - line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); + line += leftJustify("DEFAULT MARKER NAME", 60); // put a flag or a property, + line += leftJustify("MARKER NAME", 20); lengthCheck(line); out << line << '\n'; - // -------- ANTENNA TYPE - line.clear(); - line += Rinex_Printer::leftJustify("Antenna number", 20); // add flag and property - line += Rinex_Printer::leftJustify("Antenna type", 20); // add flag and property - line += std::string(20, ' '); - line += Rinex_Printer::leftJustify("ANT # / TYPE", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_observer_agency(out); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_x, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_y, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_z, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("APPROX POSITION XYZ", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_rec_type(out, gnss_sdr_version); - // -------- 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 += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_h, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_e, 4), 14); - line += Rinex_Printer::rightJustify(Rinex_Printer::asString(antena_n, 4), 14); - line += std::string(18, ' '); - line += Rinex_Printer::leftJustify("ANTENNA: DELTA H/E/N", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_antenna(out); // -------- SYS / OBS TYPES - // one line per available system - uint32_t number_of_observations = 0; - std::string signal_("B1"); - const std::size_t found_B1 = bands.find(signal_); - if (found_B1 != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - signal_ = "B3"; - const std::size_t found_B3 = bands.find(signal_); - if (found_B3 != std::string::npos) - { - number_of_observations = number_of_observations + 4; - } - - line.clear(); - - if (satsys_bds != satelliteSystem.cend()) - { - line += satsys_bds->second; - } - line += std::string(2, ' '); - line += Rinex_Printer::rightJustify(std::to_string(number_of_observations), 3); - - if (found_B1 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["BEIDOU_B1_I"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["BEIDOU_B1_I"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["BEIDOU_B1_I"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["BEIDOU_B1_I"]; - } - - if (found_B3 != std::string::npos) - { - line += std::string(1, ' '); - line += observationType["PSEUDORANGE"]; - line += observationCode["BEIDOU_B3_I"]; - line += std::string(1, ' '); - line += observationType["CARRIER_PHASE"]; - line += observationCode["BEIDOU_B3_I"]; - line += std::string(1, ' '); - line += observationType["DOPPLER"]; - line += observationCode["BEIDOU_B3_I"]; - line += std::string(1, ' '); - line += observationType["SIGNAL_STRENGTH"]; - line += observationCode["BEIDOU_B3_I"]; - } - - line += std::string(60 - line.size(), ' '); - line += Rinex_Printer::leftJustify("SYS / # / OBS TYPES", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_sys_obs_type_beidou(out, bands, observationType, observationCode); // -------- Signal Strength units - line.clear(); - line += Rinex_Printer::leftJustify("DBHZ", 20); - line += std::string(40, ' '); - line += Rinex_Printer::leftJustify("SIGNAL STRENGTH UNIT", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + add_obs_signal_strength(out); // -------- TIME OF FIRST OBS line.clear(); @@ -9338,26 +5516,22 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme const std::string minutes(timestring, 11, 2); double beidou_t = d_TOW_first_observation; const double seconds = fmod(beidou_t, 60); - line += Rinex_Printer::rightJustify(year, 6); - line += Rinex_Printer::rightJustify(month, 6); - line += Rinex_Printer::rightJustify(day, 6); - line += Rinex_Printer::rightJustify(hour, 6); - line += Rinex_Printer::rightJustify(minutes, 6); - line += Rinex_Printer::rightJustify(asString(seconds, 7), 13); - line += Rinex_Printer::rightJustify(std::string("BDT"), 8); + 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 += Rinex_Printer::leftJustify("TIME OF FIRST OBS", 20); - Rinex_Printer::lengthCheck(line); + line += leftJustify("TIME OF FIRST OBS", 20); + lengthCheck(line); out << line << '\n'; // -------- SYS /PHASE SHIFTS // -------- end of header - line.clear(); - line += std::string(60, ' '); - line += Rinex_Printer::leftJustify("END OF HEADER", 20); - Rinex_Printer::lengthCheck(line); - out << line << '\n'; + out << get_end_of_header_line() << '\n'; } @@ -9394,9 +5568,9 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut 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 += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); + line_aux += rightJustify(std::to_string(utc_model.DeltaT_LS), 6); line_aux += std::string(54, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); + line_aux += leftJustify("LEAP SECONDS", 20); data.push_back(line_aux); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) @@ -9415,13 +5589,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -9440,23 +5608,13 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_Utc_Model& ut } } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); - out.seekp(0, std::ios_base::end); + 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; - std::string line_aux; out.seekp(0); data.clear(); @@ -9470,17 +5628,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_CNAV_Utc_Mode if (!no_more_finds) { - line_aux.clear(); if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -9498,23 +5649,13 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Gps_CNAV_Utc_Mode } } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); - out.seekp(0, std::ios_base::end); + 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; - std::string line_aux; out.seekp(0); data.clear(); @@ -9528,18 +5669,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.Delta_tLSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(galileo_utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(galileo_utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -9557,23 +5690,13 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Galileo_Utc_Model } } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); - out.seekp(0, std::ios_base::end); + 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; - std::string line_aux; out.seekp(0); data.clear(); @@ -9587,18 +5710,10 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Beidou_Dnav_Utc_M if (!no_more_finds) { - line_aux.clear(); - if (line_str.find("TIME OF FIRST OBS", 59) != std::string::npos) { data.push_back(line_str); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LS), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DeltaT_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.WN_LSF), 6); - line_aux += Rinex_Printer::rightJustify(std::to_string(utc_model.DN), 6); - line_aux += std::string(36, ' '); - line_aux += Rinex_Printer::leftJustify("LEAP SECONDS", 20); - data.push_back(line_aux); + data.push_back(get_leap_second_line(utc_model)); } else if (line_str.find("END OF HEADER", 59) != std::string::npos) { @@ -9616,16 +5731,7 @@ void Rinex_Printer::update_obs_header(std::fstream& out, const Beidou_Dnav_Utc_M } } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::trunc); - out.seekp(0); - for (int32_t i = 0; i < static_cast(data.size()) - 1; i++) - { - out << data[i] << '\n'; - } - out.close(); - out.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); - out.seekp(0, std::ios_base::end); + override_stream_with_new_data(out, obsfilename, data, 0); } @@ -9686,7 +5792,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { line += std::string(1, ' '); } - line += Rinex_Printer::asString(utc_sec, 7); + line += asString(utc_sec, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -9699,7 +5805,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) @@ -9718,7 +5824,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; for (observables_iter = observables.cbegin(); @@ -9730,7 +5836,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri line.clear(); // GLONASS L1 PSEUDORANGE line += std::string(2, ' '); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -9740,36 +5846,36 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 CA PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 CA DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { lineObs += std::string(80 - lineObs.size(), ' '); @@ -9799,7 +5905,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { line += std::string(1, '0'); } - line += Rinex_Printer::asString(utc_sec, 7); + line += asString(utc_sec, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -9813,13 +5919,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; const auto satsys = satelliteSystem.find("GLONASS"); @@ -9839,7 +5945,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // lineObs += std::string(2, ' '); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -9849,40 +5955,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 CA PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 CA DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS L1 SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -9949,7 +6055,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { line += std::string(1, ' '); } - line += Rinex_Printer::asString(second_, 7); + line += asString(second_, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -9976,7 +6082,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -10041,7 +6147,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep const int32_t numGloSatellitesObserved = available_glo_prns.size(); const int32_t numGpsSatellitesObserved = observablesG1C.size(); const int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); if (d_version == 2) { // Add list of GPS satellites @@ -10093,7 +6199,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } } line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- OBSERVATION record @@ -10133,7 +6239,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // Pseudorange Measurements - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10143,39 +6249,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -10208,7 +6314,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { /// \todo Need to account for pseudorange correction for glonass // double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time); - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10218,39 +6324,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -10301,7 +6407,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -10365,10 +6471,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g const int32_t numGloSatellitesObserved = available_glo_prns.size(); const int32_t numGpsSatellitesObserved = observablesG2S.size(); const int32_t numSatellitesObserved = numGloSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; // -------- OBSERVATION record @@ -10405,7 +6511,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // Pseudorange Measurements - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10415,39 +6521,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -10477,7 +6583,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g { /// \todo Need to account for pseudorange correction for glonass // double leap_seconds = Rinex_Printer::get_leap_second(glonass_gnav_eph, gps_obs_time); - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10487,39 +6593,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -10569,7 +6675,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -10633,13 +6739,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga const int32_t numGloSatellitesObserved = available_glo_prns.size(); const int32_t numGalSatellitesObserved = observablesE1B.size(); const int32_t numSatellitesObserved = numGalSatellitesObserved + numGloSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string s; @@ -10672,7 +6778,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga lineObs += std::string(1, '0'); } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10682,39 +6788,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -10741,7 +6847,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga ret = total_glo_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10751,39 +6857,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GLONASS SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -10847,7 +6953,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { line += std::string(1, ' '); } - line += Rinex_Printer::asString(second_, 7); + line += asString(second_, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -10860,7 +6966,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); for (observables_iter = observables.cbegin(); observables_iter != observables.cend(); observables_iter++) @@ -10879,7 +6985,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; for (observables_iter = observables.cbegin(); @@ -10891,7 +6997,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d line.clear(); // GPS L1 PSEUDORANGE line += std::string(2, ' '); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -10901,36 +7007,36 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 CA PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 CA DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { lineObs += std::string(80 - lineObs.size(), ' '); @@ -10961,7 +7067,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -10975,13 +7081,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; const auto satsys_gps = satelliteSystem.find("GPS"); @@ -11001,7 +7107,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // lineObs += std::string(2, ' '); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11011,40 +7117,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, d } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 CA PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 CA DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L1 SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -11092,7 +7198,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -11106,13 +7212,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { numSatellitesObserved++; } - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; const auto satsys_gps = satelliteSystem.find("GPS"); @@ -11133,7 +7239,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // lineObs += std::string(2, ' '); // GPS L2 PSEUDORANGE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11143,40 +7249,40 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L2 PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L2 DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS L2 SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -11226,7 +7332,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -11335,11 +7441,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c } const int32_t numSatellitesObserved = available_prns.size(); - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string lineObs; @@ -11373,7 +7479,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c lineObs += std::string(62, ' '); } - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11383,39 +7489,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // GPS SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -11464,7 +7570,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -11592,11 +7698,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep } const int32_t numSatellitesObserved = available_prns.size(); - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string lineObs; @@ -11619,7 +7725,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep ret = total_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11629,39 +7735,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -11711,7 +7817,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -11812,13 +7918,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep const int32_t numGalSatellitesObserved = available_gal_prns.size(); const int32_t numGpsSatellitesObserved = observablesG1C.size(); const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string s; @@ -11852,7 +7958,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs += std::string(1, '0'); } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11862,39 +7968,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(observables_iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // PHASE - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_phase_rads / TWO_PI, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); if (lineObs.size() < 80) { @@ -11921,7 +8027,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -11931,39 +8037,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -12013,7 +8119,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -12147,13 +8253,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e const int32_t numGalSatellitesObserved = available_gal_prns.size(); const int32_t numGpsSatellitesObserved = available_gps_prns.size(); const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string s; @@ -12178,7 +8284,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e ret = total_gps_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -12188,39 +8294,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } out << lineObs << '\n'; @@ -12244,7 +8350,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -12254,39 +8360,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } // if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); @@ -12336,7 +8442,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -12488,13 +8594,13 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep const int32_t numGalSatellitesObserved = available_gal_prns.size(); const int32_t numGpsSatellitesObserved = available_gps_prns.size(); const int32_t numSatellitesObserved = numGalSatellitesObserved + numGpsSatellitesObserved; - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string s; @@ -12530,7 +8636,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs += std::string(62, ' '); } - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -12540,39 +8646,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } out << lineObs << '\n'; @@ -12596,7 +8702,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -12606,39 +8712,39 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } // else // { - // lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(lli), 1); + // lineObs += rightJustify(asString(lli), 1); // } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // Galileo SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } // if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); @@ -12682,7 +8788,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris { line += std::string(1, '0'); } - line += Rinex_Printer::asString(seconds, 7); + line += asString(seconds, 7); line += std::string(2, ' '); // Epoch flag 0: OK 1: power failure between previous and current epoch <1: Special event line += std::string(1, '0'); @@ -12758,11 +8864,11 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris } const int32_t numSatellitesObserved = available_prns.size(); - line += Rinex_Printer::rightJustify(std::to_string(numSatellitesObserved), 3); + line += rightJustify(std::to_string(numSatellitesObserved), 3); // Receiver clock offset (optional) // line += rightJustify(asString(clockOffset, 12), 15); line += std::string(80 - line.size(), ' '); - Rinex_Printer::lengthCheck(line); + lengthCheck(line); out << line << '\n'; std::string lineObs; @@ -12785,7 +8891,7 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris ret = total_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) { - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Pseudorange_m, 3), 14); + lineObs += rightJustify(asString(iter->second.Pseudorange_m, 3), 14); // Loss of lock indicator (LLI) int32_t lli = 0; // Include in the observation!! @@ -12796,26 +8902,26 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris // Signal Strength Indicator (SSI) const int32_t ssi = Rinex_Printer::signalStrength(iter->second.CN0_dB_hz); - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // CARRIER PHASE - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_phase_rads / (TWO_PI), 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // DOPPLER - lineObs += Rinex_Printer::rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.Carrier_Doppler_hz, 3), 14); if (lli == 0) { lineObs += std::string(1, ' '); } - lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); + lineObs += rightJustify(asString(ssi), 1); // SIGNAL STRENGTH - lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); + lineObs += rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } if (lineObs.size() < 80) @@ -12986,7 +9092,6 @@ int32_t Rinex_Printer::signalStrength(double snr) const return ss; } - boost::posix_time::ptime Rinex_Printer::compute_UTC_time(const Gps_Navigation_Message& nav_msg) const { // if we are processing a file -> wait to leap second to resolve the ambiguity else take the week from the local system time diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index 4b45bbb67..5d89e8c05 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -170,13 +170,10 @@ public: private: - const std::unordered_map satelliteSystem = { - {"GPS", "G"}, - {"GLONASS", "R"}, - {"SBAS payload", "S"}, - {"Galileo", "E"}, - {"Beidou", "C"}, - {"Mixed", "M"}}; // RINEX v3.02 codes + // Not the best, but reorder params to select the correct constructor + explicit Rinex_Printer(const std::string& base_name, + const std::string& base_rinex_path, + int version); /* * Generates the GPS Observation data header @@ -727,211 +724,13 @@ private: */ int signalStrength(double snr) const; - /* Creates RINEX file names according to the naming convention - * - * See ftp://igs.org/pub/data/format/rinex301.pdf - * Section 4, page 6 - * - * \param[in] type of RINEX file. Can be: - * "RINEX_FILE_TYPE_OBS" - Observation file. - * "RINEX_FILE_TYPE_GPS_NAV" - GPS navigation message file. - * "RINEX_FILE_TYPE_MET" - Meteorological data file. - * "RINEX_FILE_TYPE_GLO_NAV" - GLONASS navigation file. - * "RINEX_FILE_TYPE_GAL_NAV" - Galileo navigation message file. - * "RINEX_FILE_TYPE_MIXED_NAV" - Mixed GNSS navigation message file. - * "RINEX_FILE_TYPE_GEO_NAV" - SBAS Payload navigation message file. - * "RINEX_FILE_TYPE_SBAS" - SBAS broadcast data file. - * "RINEX_FILE_TYPE_CLK" - Clock file. - */ - std::string createFilename(const std::string& type, const std::string& base_name) const; - /* * Generates the data for the PGM / RUN BY / DATE line */ std::string getLocalTime() const; - /* - * Checks that the line is 80 characters length - */ - void lengthCheck(const std::string& line) const; - - /* - * If the string is bigger than length, truncate it from the right. - * otherwise, add pad characters to its right. - * - * Left-justifies the input in a string of the specified - * length. If the new length (\a length) is larger than the - * current length, the string is extended by the pad - * character (\a pad). The default pad character is a - * blank. - * \param[in] s string to be modified. - * \param[in] length new desired length of string. - * \param[in] pad character to pad string with (blank by default). - * \return a reference to \a s. */ - inline std::string& leftJustify(std::string& s, - std::string::size_type length, - char pad = ' ') const; - - /* - * If the string is bigger than length, truncate it from the right. - * otherwise, add pad characters to its right. - * - * Left-justifies the receiver in a string of the specified - * length (const version). If the new length (\a length) is larger - * than the current length, the string is extended by the pad - * character (\a pad). The default pad character is a - * blank. - * \param[in] s string to be modified. - * \param[in] length new desired length of string. - * \param[in] pad character to pad string with (blank by default). - * \return a reference to \a s. */ - inline std::string leftJustify(const std::string& s, - std::string::size_type length, - char pad = ' ') const - { - std::string t(s); - return leftJustify(t, length, pad); - } - - - /* - * Right-justifies the receiver in a string of the specified - * length. If the receiver's data is shorter than the - * requested length (\a length), it is padded on the left with - * the pad character (\a pad). The default pad - * character is a blank. */ - inline std::string& rightJustify(std::string& s, - std::string::size_type length, - char pad = ' ') const; - - /* - * Right-justifies the receiver in a string of the specified - * length (const version). If the receiver's data is shorter than the - * requested length (\a length), it is padded on the left with - * the pad character (\a pad). The default pad - * character is a blank.*/ - inline std::string rightJustify(const std::string& s, - std::string::size_type length, - char pad = ' ') const - { - std::string t(s); - return rightJustify(t, length, pad); - } - - - /* - * Convert a double to a scientific notation number. - * @param d the double to convert - * @param length length (in characters) of output, including exponent - * @param expLen length (in characters) of the exponent, with sign - * @param showSign if true, reserves 1 character for +/- sign - * @param checkSwitch if true, keeps the exponential sanity check for - * exponentials above three characters in length. If false, it removes - * that check. - */ - inline std::string doub2sci(double d, - std::string::size_type length, - std::string::size_type expLen, - bool showSign = true, - bool checkSwitch = true) const; - - - /* - * Convert scientific notation to FORTRAN notation. - * As an example, the string "1.5636E5" becomes " .15636D6". - * Note that the first character of the string will be '-' if - * the number is negative or ' ' if the first character is positive. - * @param aStr string with number to convert - * @param startPos start position of number in string - * @param length length (in characters) of number, including exponent. - * @param expLen length (in characters of exponent, not including sign. - * @param checkSwitch will keep the method running as originally programmed - * when set to true. If false, the method will always resize exponentials, - * produce an exponential with an E instead of a D, and always have a leading - * zero. For example -> 0.87654E-0004 or -0.1234E00005. - */ - inline std::string& sci2for(std::string& aStr, - std::string::size_type startPos = 0, - std::string::size_type length = std::string::npos, - std::string::size_type expLen = 3, - bool checkSwitch = true) const; - - - /* - * Convert double precision floating point to a string - * containing the number in FORTRAN notation. - * As an example, the number 156360 becomes ".15636D6". - * @param d number to convert. - * @param length length (in characters) of number, including exponent. - * @param expLen length (in characters of exponent, including sign. - * @param checkSwitch if true, keeps the exponential sanity check for - * exponentials above three characters in length. If false, it removes - * that check. - * @return a string containing \a d in FORTRAN notation. - */ - inline std::string doub2for(double d, - std::string::size_type length, - std::string::size_type expLen, - bool checkSwitch = true) const; - - - /* - * Convert a string to a double precision floating point number. - * @param s string containing a number. - * @return double representation of string. - */ - inline double asDouble(const std::string& s) const - { - return strtod(s.c_str(), nullptr); - } - - - inline int toInt(const std::string& bitString, int sLength) const; - - /* - * Convert a string to an integer. - * @param s string containing a number. - * @return int64_t integer representation of string. - */ - inline int64_t asInt(const std::string& s) const - { - return strtol(s.c_str(), nullptr, 10); - } - - - /* - * Convert a double to a string in fixed notation. - * @param x double. - * @param precision the number of decimal places you want displayed. - * @return string representation of \a x. - */ - inline std::string asString(double x, - std::string::size_type precision = 17) const; - - - /* - * Convert a long double to a string in fixed notation. - * @param x long double. - * @param precision the number of decimal places you want displayed. - * @return string representation of \a x. - */ - inline std::string asString(long double x, - std::string::size_type precision = 21) const; - - - /* - * Convert any old object to a string. - * The class must have stream operators defined. - * @param x object to turn into a string. - * @return string representation of \a x. - */ - template - inline std::string asString(const X x) const; - - inline std::string asFixWidthString(int x, int width, char fill_digit) const; - - std::map observationType; // PSEUDORANGE, CARRIER_PHASE, DOPPLER, SIGNAL_STRENGTH - std::map observationCode; // GNSS observation descriptors + const std::map observationType; // PSEUDORANGE, CARRIER_PHASE, DOPPLER, SIGNAL_STRENGTH + const std::map observationCode; // GNSS observation descriptors std::fstream obsFile; // Output file stream for RINEX observation file std::fstream navFile; // Output file stream for RINEX navigation data file @@ -941,277 +740,25 @@ private: std::fstream navBdsFile; // Output file stream for RINEX Beidou navigation data file std::fstream navMixFile; // Output file stream for RINEX Mixed navigation data file - std::string navfilename; // Name of RINEX navigation file for GPS L1 - std::string obsfilename; // Name of RINEX observation file - std::string sbsfilename; // Name of RINEX SBAS file - std::string navGalfilename; // Name of RINEX navigation file for Galileo - std::string navGlofilename; // Name of RINEX navigation file for Glonass - std::string navBdsfilename; // Name of RINEX navigation file for BeiDou - std::string navMixfilename; // Name of RINEX navigation file for fixed signals + const std::string navfilename; // Name of RINEX navigation file for GPS L1 + const std::string obsfilename; // Name of RINEX observation file + const std::string sbsfilename; // Name of RINEX SBAS file + const std::string navGalfilename; // Name of RINEX navigation file for Galileo + const std::string navGlofilename; // Name of RINEX navigation file for Glonass + const std::string navBdsfilename; // Name of RINEX navigation file for BeiDou + const std::string navMixfilename; // Name of RINEX navigation file for fixed signals std::vector output_navfilename; // Name of output RINEX navigation file(s) std::string d_stringVersion; // RINEX version (2.10/2.11 or 3.01/3.02) double d_fake_cnav_iode; - int d_version; // RINEX version (2 for 2.10/2.11 and 3 for 3.01) - int d_numberTypesObservations; // Number of available types of observable in the system. Should be public? + int d_version; // RINEX version (2 for 2.10/2.11 and 3 for 3.01) bool d_rinex_header_updated; bool d_rinex_header_written; bool d_pre_2009_file; }; -// Implementation of inline functions (modified versions from GNSSTk https://github.com/SGL-UT/gnsstk) - -inline std::string& Rinex_Printer::leftJustify(std::string& s, - std::string::size_type length, - char pad) const -{ - if (length < s.length()) - { - s = s.substr(0, length); - } - else - { - s.append(length - s.length(), pad); - } - return s; -} - - -// if the string is bigger than length, truncate it from the left. -// otherwise, add pad characters to its left. -inline std::string& Rinex_Printer::rightJustify(std::string& s, - std::string::size_type length, - char pad) const -{ - if (length < s.length()) - { - s = s.substr(s.length() - length, std::string::npos); - } - else - { - s.insert(static_cast(0), length - s.length(), pad); - } - return s; -} - - -inline std::string Rinex_Printer::doub2for(double d, - std::string::size_type length, - std::string::size_type expLen, - bool checkSwitch) const -{ - int16_t exponentLength = expLen; - - /* Validate the assumptions regarding the input arguments */ - if (exponentLength < 0) - { - exponentLength = 1; - } - - if (exponentLength > 3 && checkSwitch) - { - exponentLength = 3; - } - - std::string toReturn = doub2sci(d, length, exponentLength, true, checkSwitch); - sci2for(toReturn, 0, length, exponentLength, checkSwitch); - - return toReturn; -} - - -inline std::string Rinex_Printer::doub2sci(double d, - std::string::size_type length, - std::string::size_type expLen, - bool showSign, - bool checkSwitch) const -{ - std::string toReturn; - int16_t exponentLength = expLen; - - /* Validate the assumptions regarding the input arguments */ - if (exponentLength < 0) - { - exponentLength = 1; - } - - if (exponentLength > 3 && checkSwitch) - { - exponentLength = 3; - } - - std::stringstream c; - c.setf(std::ios::scientific, std::ios::floatfield); - - // length - 3 for special characters ('.', 'e', '+' or '-') - // - exponentlength (e04) - // - 1 for the digit before the decimal (2.) - // and if showSign == true, - // an extra -1 for '-' or ' ' if it's positive or negative - int expSize = 0; - if (showSign) - { - expSize = 1; - } - - c.precision(length - 3 - exponentLength - 1 - expSize); - c << d; - c >> toReturn; - return toReturn; -} - - -inline std::string& Rinex_Printer::sci2for(std::string& aStr, - std::string::size_type startPos, - std::string::size_type length, - std::string::size_type expLen, - bool checkSwitch) const -{ - std::string::size_type idx = aStr.find('.', startPos); - int expAdd = 0; - std::string exp; - int64_t iexp; - // If checkSwitch is false, always redo the exponential. Otherwise, - // set it to false. - bool redoexp = !checkSwitch; - - // Check for decimal place within specified boundaries - if ((idx <= 0) || (idx >= (startPos + length - expLen - 1))) - { - // Error: no decimal point in string - return aStr; - } - - // Here, account for the possibility that there are - // no numbers to the left of the decimal, but do not - // account for the possibility of non-scientific - // notation (more than one digit to the left of the - // decimal) - if (idx > startPos) - { - redoexp = true; - // Swap digit and decimal. - aStr[idx] = aStr[idx - 1]; - aStr[idx - 1] = '.'; - // Only add one to the exponent if the number is non-zero - if (asDouble(aStr.substr(startPos, length)) != 0.0) - { - expAdd = 1; - } - } - - idx = aStr.find('e', startPos); - if (idx == std::string::npos) - { - idx = aStr.find('E', startPos); - if (idx == std::string::npos) - { - // Error: no 'e' or 'E' in string"; - } - } - - // Change the exponent character to D normally, or E of checkSwitch is false. - if (checkSwitch) - { - aStr[idx] = 'D'; - } - else - { - aStr[idx] = 'E'; - } - - // Change the exponent itself - if (redoexp) - { - exp = aStr.substr(idx + 1, std::string::npos); - iexp = asInt(exp); - iexp += expAdd; - - aStr.erase(idx + 1); - if (iexp < 0) - { - aStr += "-"; - iexp -= iexp * 2; - } - else - { - aStr += "+"; - } - - aStr += Rinex_Printer::rightJustify(asString(iexp), expLen, '0'); - } - - // if the number is positive, append a space - // (if it's negative, there's a leading '-' - if (aStr[0] == '.') - { - aStr.insert(static_cast(0), 1, ' '); - } - - // If checkSwitch is false, add on one leading zero to the string - if (!checkSwitch) - { - aStr.insert(static_cast(1), 1, '0'); - } - - return aStr; -} // end sci2for - - -inline std::string asString(long double x, std::string::size_type precision) -{ - std::ostringstream ss; - ss << std::fixed << std::setprecision(precision) << x; - return ss.str(); -} - - -inline std::string Rinex_Printer::asString(double x, std::string::size_type precision) const -{ - std::ostringstream ss; - ss << std::fixed << std::setprecision(precision) << x; - return ss.str(); -} - - -inline std::string Rinex_Printer::asFixWidthString(int x, int width, char fill_digit) const -{ - std::ostringstream ss; - ss << std::setfill(fill_digit) << std::setw(width) << x; - return ss.str().substr(ss.str().size() - width); -} - - -inline int64_t asInt(const std::string& s) -{ - return strtol(s.c_str(), nullptr, 10); -} - - -inline int Rinex_Printer::toInt(const std::string& bitString, int sLength) const -{ - int tempInt; - int num = 0; - for (int i = 0; i < sLength; i++) - { - tempInt = bitString[i] - '0'; - num |= (1 << (sLength - 1 - i)) * tempInt; - } - return num; -} - - -template -inline std::string Rinex_Printer::asString(const X x) const -{ - std::ostringstream ss; - ss << x; - return ss.str(); -} - - /** \} */ /** \} */ #endif // GNSS_SDR_RINEX_PRINTER_H