40 #ifndef GNSS_SDR_RINEX_PRINTER_H 41 #define GNSS_SDR_RINEX_PRINTER_H 43 #include <boost/date_time/posix_time/posix_time.hpp> 81 explicit Rinex_Printer(
int version = 0,
const std::string& base_path =
".",
const std::string& base_name =
"-");
271 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_Ephemeris>& eph_map)
const;
276 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_CNAV_Ephemeris>& eph_map);
281 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Galileo_Ephemeris>& eph_map)
const;
286 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_Ephemeris>& gps_eph_map,
const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map);
291 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_CNAV_Ephemeris>& gps_cnav_eph_map,
const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map);
296 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Glonass_Gnav_Ephemeris>& eph_map)
const;
301 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_Ephemeris>& gps_eph_map,
const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map)
const;
306 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Gps_CNAV_Ephemeris>& gps_cnav_eph_map,
const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map);
311 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map,
const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map);
316 void log_rinex_nav(std::fstream& out,
const std::map<int32_t, Beidou_Dnav_Ephemeris>& eph_map)
const;
321 void log_rinex_obs(std::fstream& out,
const Gps_Ephemeris& eph,
double obs_time,
const std::map<int32_t, Gnss_Synchro>& observables)
const;
336 void log_rinex_obs(std::fstream& out,
const Galileo_Ephemeris& eph,
double obs_time,
const std::map<int32_t, Gnss_Synchro>& observables,
const std::string& galileo_bands =
"1B")
const;
356 void log_rinex_obs(std::fstream& out,
const Glonass_Gnav_Ephemeris& eph,
double obs_time,
const std::map<int32_t, Gnss_Synchro>& observables,
const std::string& glonass_bands =
"1C")
const;
376 void log_rinex_obs(std::fstream& out,
const Beidou_Dnav_Ephemeris& eph,
double obs_time,
const std::map<int32_t, Gnss_Synchro>& observables,
const std::string& bds_bands)
const;
382 void to_date_time(
int gps_week,
int gps_tow,
int& year,
int& month,
int& day,
int& hour,
int& minute,
int& second)
const;
409 void update_obs_header(std::fstream& out,
const Gps_Utc_Model& utc_model)
const;
413 void update_obs_header(std::fstream& out,
const Galileo_Utc_Model& galileo_utc_model)
const;
419 void set_pre_2009_file(
bool pre_2009_file);
429 std::string navfilename;
430 std::string obsfilename;
431 std::string sbsfilename;
432 std::string navGalfilename;
433 std::string navGlofilename;
434 std::string navBdsfilename;
435 std::string navMixfilename;
441 int signalStrength(
double snr)
const;
459 std::string createFilename(
const std::string& type,
const std::string& base_name)
const;
464 std::string getLocalTime()
const;
469 void lengthCheck(
const std::string& line)
const;
484 inline std::string& leftJustify(std::string& s,
485 std::string::size_type length,
486 char pad =
' ')
const;
501 inline std::string leftJustify(
const std::string& s,
502 std::string::size_type length,
503 char pad =
' ')
const 506 return leftJustify(t, length, pad);
516 inline std::string& rightJustify(std::string& s,
517 std::string::size_type length,
518 char pad =
' ')
const;
526 inline std::string rightJustify(
const std::string& s,
527 std::string::size_type length,
528 char pad =
' ')
const 531 return rightJustify(t, length, pad);
545 inline std::string doub2sci(
double d,
546 std::string::size_type length,
547 std::string::size_type expLen,
548 bool showSign =
true,
549 bool checkSwitch =
true)
const;
566 inline std::string& sci2for(std::string& aStr,
567 std::string::size_type startPos = 0,
568 std::string::size_type length = std::string::npos,
569 std::string::size_type expLen = 3,
570 bool checkSwitch =
true)
const;
585 inline std::string doub2for(
double d,
586 std::string::size_type length,
587 std::string::size_type expLen,
588 bool checkSwitch =
true)
const;
596 inline double asDouble(
const std::string& s)
const 598 return strtod(s.c_str(),
nullptr);
602 inline int toInt(
const std::string& bitString,
int sLength)
const;
609 inline int64_t asInt(
const std::string& s)
const 611 return strtol(s.c_str(),
nullptr, 10);
621 inline std::string asString(
double x,
622 std::string::size_type precision = 17)
const;
631 inline std::string asString(
long double x,
632 std::string::size_type precision = 21)
const;
642 inline std::string asString(
const X x)
const;
644 inline std::string asFixWidthString(
int x,
int width,
char fill_digit)
const;
646 std::map<std::string, std::string> satelliteSystem;
647 std::map<std::string, std::string> observationType;
648 std::map<std::string, std::string> observationCode;
649 std::string stringVersion;
651 double fake_cnav_iode;
653 int numberTypesObservations;
660 inline std::string& Rinex_Printer::leftJustify(std::string& s,
661 std::string::size_type length,
664 if (length < s.length())
666 s = s.substr(0, length);
670 s.append(length - s.length(), pad);
678 inline std::string& Rinex_Printer::rightJustify(std::string& s,
679 std::string::size_type length,
682 if (length < s.length())
684 s = s.substr(s.length() - length, std::string::npos);
688 s.insert(static_cast<std::string::size_type>(0), length - s.length(), pad);
694 inline std::string Rinex_Printer::doub2for(
double d,
695 std::string::size_type length,
696 std::string::size_type expLen,
697 bool checkSwitch)
const 699 int16_t exponentLength = expLen;
702 if (exponentLength < 0)
707 if (exponentLength > 3 && checkSwitch)
712 std::string toReturn = doub2sci(d, length, exponentLength,
true, checkSwitch);
713 sci2for(toReturn, 0, length, exponentLength, checkSwitch);
719 inline std::string Rinex_Printer::doub2sci(
double d,
720 std::string::size_type length,
721 std::string::size_type expLen,
723 bool checkSwitch)
const 725 std::string toReturn;
726 int16_t exponentLength = expLen;
729 if (exponentLength < 0)
734 if (exponentLength > 3 && checkSwitch)
740 c.setf(std::ios::scientific, std::ios::floatfield);
753 c.precision(length - 3 - exponentLength - 1 - expSize);
760 inline std::string& Rinex_Printer::sci2for(std::string& aStr,
761 std::string::size_type startPos,
762 std::string::size_type length,
763 std::string::size_type expLen,
764 bool checkSwitch)
const 766 std::string::size_type idx = aStr.find(
'.', startPos);
772 bool redoexp = !checkSwitch;
775 if ((idx <= 0) || (idx >= (startPos + length - expLen - 1)))
790 aStr[idx] = aStr[idx - 1];
793 if (asDouble(aStr.substr(startPos, length)) != 0.0)
799 idx = aStr.find(
'e', startPos);
800 if (idx == std::string::npos)
802 idx = aStr.find(
'E', startPos);
803 if (idx == std::string::npos)
822 exp = aStr.substr(idx + 1, std::string::npos);
837 aStr += Rinex_Printer::rightJustify(asString(iexp), expLen,
'0');
844 aStr.insert(static_cast<std::string::size_type>(0), 1,
' ');
850 aStr.insert(static_cast<std::string::size_type>(1), 1,
'0');
857 inline std::string asString(
long double x, std::string::size_type precision)
859 std::ostringstream ss;
860 ss << std::fixed << std::setprecision(precision) << x;
865 inline std::string Rinex_Printer::asString(
double x, std::string::size_type precision)
const 867 std::ostringstream ss;
868 ss << std::fixed << std::setprecision(precision) << x;
873 inline std::string Rinex_Printer::asFixWidthString(
int x,
int width,
char fill_digit)
const 875 std::ostringstream ss;
876 ss << std::setfill(fill_digit) << std::setw(width) << x;
877 return ss.str().substr(ss.str().size() - width);
881 inline int64_t asInt(
const std::string& s)
883 return strtol(s.c_str(),
nullptr, 10);
887 inline int Rinex_Printer::toInt(
const std::string& bitString,
int sLength)
const 891 for (
int i = 0; i < sLength; i++)
893 tempInt = bitString[i] -
'0';
894 num |= (1 << (sLength - 1 - i)) * tempInt;
901 inline std::string Rinex_Printer::asString(
const X x)
const 903 std::ostringstream ss;
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200K. ...
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
This class is a storage for the BeiDou DNAV UTC Model.
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in IS-...
void log_rinex_obs(std::fstream &out, const Gps_Ephemeris &eph, double obs_time, const std::map< int32_t, Gnss_Synchro > &observables) const
Writes GPS L1 observables into the RINEX file.
void log_rinex_nav(std::fstream &out, const std::map< int32_t, Gps_Ephemeris > &eph_map) const
Writes data from the GPS L1 C/A navigation message into the RINEX file.
Rinex_Printer(int version=0, const std::string &base_path=".", const std::string &base_name="-")
Default constructor. Creates GNSS Navigation and Observables RINEX files and their headers...
std::fstream navMixFile
Output file stream for RINEX Mixed navigation data file.
This class is a storage for the BEIDOU IONOSPHERIC data as described in ICD v2.1. ...
Class that handles the generation of Receiver INdependent EXchange format (RINEX) files...
void rinex_sbs_header(std::fstream &out) const
Generates the SBAS raw data header.
std::fstream navBdsFile
Output file stream for RINEX Galileo navigation data file.
This class is a storage and orbital model functions for the GLONASS SV ephemeris data as described in...
void rinex_obs_header(std::fstream &out, const Gps_Ephemeris &eph, double d_TOW_first_observation)
Generates the GPS Observation data header.
boost::posix_time::ptime compute_Galileo_time(const Galileo_Ephemeris &eph, double obs_time) const
Computes the Galileo time and returns a boost::posix_time::ptime object.
std::fstream navFile
Output file stream for RINEX navigation data file.
void update_nav_header(std::fstream &out, const Gps_Utc_Model &utc_model, const Gps_Iono &gps_iono, const Gps_Ephemeris &eph) const
Writes raw SBAS messages into the RINEX file.
~Rinex_Printer()
Default destructor. Closes GNSS Navigation and Observables RINEX files.
boost::posix_time::ptime compute_BDS_time(const Beidou_Dnav_Ephemeris &eph, double obs_time) const
Computes the BDS Time and returns a boost::posix_time::ptime object.
This class is a storage and orbital model functions for the GPS SV ephemeris data as described in Bei...
This is the class that contains the information that is shared by the processing blocks.
boost::posix_time::ptime compute_GPS_time(const Gps_Ephemeris &eph, double obs_time) const
Computes the GPS time and returns a boost::posix_time::ptime object.
std::fstream obsFile
Output file stream for RINEX observation file.
double get_leap_second(const Glonass_Gnav_Ephemeris &eph, double gps_obs_time) const
Computes number of leap seconds of GPS relative to UTC.
This class is a storage for the GPS UTC MODEL data as described in in IS-GPS-200K.
This class decodes a GPS NAV Data message as described in IS-GPS-200K.
This class is a storage for the GALILEO IONOSPHERIC data as described in Galileo ICD paragraph 5...
void to_date_time(int gps_week, int gps_tow, int &year, int &month, int &day, int &hour, int &minute, int &second) const
Represents GPS time in the date time format. Leap years are considered, but leap seconds are not...
void rinex_nav_header(std::fstream &out, const Gps_Iono &iono, const Gps_Utc_Model &utc_model, const Gps_Ephemeris &eph) const
Generates the GPS L1 C/A Navigation Data header.
This class is a storage and orbital model functions for the Galileo SV ephemeris data as described in...
This class is a storage for the GLONASS GNAV UTC MODEL data as described in GLONASS ICD (Edition 5...
This class is a storage for the GPS UTC MODEL data as described in IS-GPS-200K.
This class is a storage for the GLONASS SV ALMANAC data as described GLONASS ICD (Edition 5...
std::fstream navGalFile
Output file stream for RINEX Galileo navigation data file.
std::fstream navGloFile
Output file stream for RINEX GLONASS navigation data file.
This class is a storage for the GALILEO UTC MODEL data as described in Galileo ICD https://www...
boost::posix_time::ptime compute_UTC_time(const Gps_Navigation_Message &nav_msg) const
Computes the UTC time and returns a boost::posix_time::ptime object.
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200K. ...
std::fstream sbsFile
Output file stream for RINEX SBAS raw data file.