38 #ifndef GNSS_SDR_RINEX_PRINTER_H 39 #define GNSS_SDR_RINEX_PRINTER_H 41 #include <boost/date_time/posix_time/posix_time.hpp> 49 #include <unordered_map> 90 const std::string& base_path =
".",
91 const std::string& base_name =
"-");
171 const std::map<int, Gnss_Synchro>& gnss_observables_map,
174 bool flag_write_RINEX_obs_output);
180 const std::map<int32_t, Gps_Ephemeris>& new_eph);
186 const std::map<int32_t, Gps_CNAV_Ephemeris>& new_cnav_eph);
192 const std::map<int32_t, Galileo_Ephemeris>& new_gal_eph);
198 const std::map<int32_t, Glonass_Gnav_Ephemeris>& new_glo_eph);
204 const std::map<int32_t, Beidou_Dnav_Ephemeris>& new_bds_eph);
216 return d_rinex_header_written;
224 return output_navfilename;
237 const std::unordered_map<std::string, std::string> satelliteSystem = {
240 {
"SBAS payload",
"S"},
248 void rinex_obs_header(std::fstream& out,
250 double d_TOW_first_observation);
255 void rinex_obs_header(std::fstream& out,
257 double d_TOW_first_observation,
258 const std::string& gps_bands =
"2S");
263 void rinex_obs_header(std::fstream& out,
266 double d_TOW_first_observation,
267 const std::string& gps_bands =
"1C 2S");
273 void rinex_obs_header(std::fstream& out,
275 double d_TOW_first_observation,
276 const std::string& bands =
"1B");
283 void rinex_obs_header(std::fstream& out,
286 double d_TOW_first_observation,
287 const std::string& galileo_bands =
"1B");
293 void rinex_obs_header(std::fstream& out,
297 double d_TOW_first_observation,
298 const std::string& gps_bands =
"1C 2S",
299 const std::string& galileo_bands =
"1B");
305 void rinex_obs_header(std::fstream& out,
308 double d_TOW_first_observation,
309 const std::string& gps_bands =
"2S",
310 const std::string& galileo_bands =
"1B");
316 void rinex_obs_header(std::fstream& out,
318 double d_TOW_first_observation,
319 const std::string& bands =
"1G");
325 void rinex_obs_header(std::fstream& out,
328 double d_TOW_first_observation,
329 const std::string& glonass_bands =
"1C");
335 void rinex_obs_header(std::fstream& out,
338 double d_TOW_first_observation,
339 const std::string& galileo_bands =
"1B",
340 const std::string& glonass_bands =
"1C");
346 void rinex_obs_header(std::fstream& out,
349 double d_TOW_first_observation,
350 const std::string& glonass_bands =
"1G");
355 void rinex_obs_header(std::fstream& out,
357 double d_TOW_first_observation,
358 const std::string& bands);
363 void rinex_sbs_header(std::fstream& out)
const;
368 void log_rinex_obs(std::fstream& out,
371 const std::map<int32_t, Gnss_Synchro>& observables)
const;
376 void log_rinex_obs(std::fstream& out,
379 const std::map<int32_t, Gnss_Synchro>& observables)
const;
384 void log_rinex_obs(std::fstream& out,
388 const std::map<int32_t, Gnss_Synchro>& observables,
389 bool triple_band =
false)
const;
395 void log_rinex_obs(std::fstream& out,
398 const std::map<int32_t, Gnss_Synchro>& observables,
399 const std::string& galileo_bands =
"1B")
const;
404 void log_rinex_obs(std::fstream& out,
408 const std::map<int32_t, Gnss_Synchro>& observables)
const;
413 void log_rinex_obs(std::fstream& out,
417 const std::map<int32_t, Gnss_Synchro>& observables)
const;
422 void log_rinex_obs(std::fstream& out,
427 const std::map<int32_t, Gnss_Synchro>& observables,
428 bool triple_band =
false)
const;
434 void log_rinex_obs(std::fstream& out,
437 const std::map<int32_t, Gnss_Synchro>& observables,
438 const std::string& glonass_bands =
"1C")
const;
443 void log_rinex_obs(std::fstream& out,
447 const std::map<int32_t, Gnss_Synchro>& observables)
const;
452 void log_rinex_obs(std::fstream& out,
456 const std::map<int32_t, Gnss_Synchro>& observables)
const;
461 void log_rinex_obs(std::fstream& out,
464 double galileo_obs_time,
465 const std::map<int32_t, Gnss_Synchro>& observables)
const;
470 void log_rinex_obs(std::fstream& out,
473 const std::map<int32_t, Gnss_Synchro>& observables,
474 const std::string& bds_bands)
const;
479 void rinex_nav_header(std::fstream& out,
487 void rinex_nav_header(std::fstream& out,
494 void rinex_nav_header(std::fstream& out,
501 void rinex_nav_header(std::fstream& out,
511 void rinex_nav_header(std::fstream& out,
520 void rinex_nav_header(std::fstream& out,
527 void rinex_nav_header(std::fstream& out,
536 void rinex_nav_header(std::fstream& out,
546 void rinex_nav_header(std::fstream& out,
555 void rinex_nav_header(std::fstream& out,
562 void rinex_nav_header(std::fstream& out,
572 void rinex_nav_header(std::fstream& out,
581 void rinex_nav_header(std::fstream& out,
589 void rinex_nav_header(std::fstream& out,
598 void log_rinex_nav(std::fstream& out,
599 const std::map<int32_t, Gps_Ephemeris>& eph_map)
const;
604 void log_rinex_nav(std::fstream& out,
605 const std::map<int32_t, Gps_CNAV_Ephemeris>& eph_map);
610 void log_rinex_nav(std::fstream& out,
611 const std::map<int32_t, Galileo_Ephemeris>& eph_map)
const;
616 void log_rinex_nav(std::fstream& out,
617 const std::map<int32_t, Gps_Ephemeris>& gps_eph_map,
618 const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map);
623 void log_rinex_nav(std::fstream& out,
624 const std::map<int32_t, Gps_CNAV_Ephemeris>& gps_cnav_eph_map,
625 const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map);
630 void log_rinex_nav(std::fstream& out,
631 const std::map<int32_t, Glonass_Gnav_Ephemeris>& eph_map)
const;
636 void log_rinex_nav(std::fstream& out,
637 const std::map<int32_t, Gps_Ephemeris>& gps_eph_map,
638 const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map)
const;
643 void log_rinex_nav(std::fstream& out,
644 const std::map<int32_t, Gps_CNAV_Ephemeris>& gps_cnav_eph_map,
645 const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map);
650 void log_rinex_nav(std::fstream& out,
651 const std::map<int32_t, Galileo_Ephemeris>& galileo_eph_map,
652 const std::map<int32_t, Glonass_Gnav_Ephemeris>& glonass_gnav_eph_map);
657 void log_rinex_nav(std::fstream& out,
658 const std::map<int32_t, Beidou_Dnav_Ephemeris>& eph_map)
const;
677 boost::posix_time::ptime compute_GPS_time(
const Gps_Ephemeris& eph,
double obs_time)
const;
682 boost::posix_time::ptime compute_GPS_time(
const Gps_CNAV_Ephemeris& eph,
double obs_time)
const;
687 boost::posix_time::ptime compute_Galileo_time(
const Galileo_Ephemeris& eph,
double obs_time)
const;
708 void to_date_time(
int gps_week,
722 void update_nav_header(std::fstream& out,
726 void update_nav_header(std::fstream& out,
730 void update_nav_header(std::fstream& out,
737 void update_nav_header(std::fstream& out,
743 void update_nav_header(std::fstream& out,
747 void update_nav_header(std::fstream& out,
751 void update_nav_header(std::fstream& out,
758 void update_nav_header(std::fstream& out,
764 void update_nav_header(std::fstream& out,
770 void update_nav_header(std::fstream& out,
774 void update_obs_header(std::fstream& out,
777 void update_obs_header(std::fstream& out,
780 void update_obs_header(std::fstream& out,
783 void update_obs_header(std::fstream& out,
786 void update_obs_header(std::fstream& out,
792 int signalStrength(
double snr)
const;
810 std::string createFilename(
const std::string& type,
const std::string& base_name)
const;
815 std::string getLocalTime()
const;
820 void lengthCheck(
const std::string& line)
const;
835 inline std::string& leftJustify(std::string& s,
836 std::string::size_type length,
837 char pad =
' ')
const;
852 inline std::string leftJustify(
const std::string& s,
853 std::string::size_type length,
854 char pad =
' ')
const 857 return leftJustify(t, length, pad);
867 inline std::string& rightJustify(std::string& s,
868 std::string::size_type length,
869 char pad =
' ')
const;
877 inline std::string rightJustify(
const std::string& s,
878 std::string::size_type length,
879 char pad =
' ')
const 882 return rightJustify(t, length, pad);
896 inline std::string doub2sci(
double d,
897 std::string::size_type length,
898 std::string::size_type expLen,
899 bool showSign =
true,
900 bool checkSwitch =
true)
const;
917 inline std::string& sci2for(std::string& aStr,
918 std::string::size_type startPos = 0,
919 std::string::size_type length = std::string::npos,
920 std::string::size_type expLen = 3,
921 bool checkSwitch =
true)
const;
936 inline std::string doub2for(
double d,
937 std::string::size_type length,
938 std::string::size_type expLen,
939 bool checkSwitch =
true)
const;
947 inline double asDouble(
const std::string& s)
const 949 return strtod(s.c_str(),
nullptr);
953 inline int toInt(
const std::string& bitString,
int sLength)
const;
960 inline int64_t asInt(
const std::string& s)
const 962 return strtol(s.c_str(),
nullptr, 10);
972 inline std::string asString(
double x,
973 std::string::size_type precision = 17)
const;
982 inline std::string asString(
long double x,
983 std::string::size_type precision = 21)
const;
993 inline std::string asString(
const X x)
const;
995 inline std::string asFixWidthString(
int x,
int width,
char fill_digit)
const;
997 std::map<std::string, std::string> observationType;
998 std::map<std::string, std::string> observationCode;
1000 std::fstream obsFile;
1001 std::fstream navFile;
1002 std::fstream sbsFile;
1003 std::fstream navGalFile;
1004 std::fstream navGloFile;
1005 std::fstream navBdsFile;
1006 std::fstream navMixFile;
1008 std::string navfilename;
1009 std::string obsfilename;
1010 std::string sbsfilename;
1011 std::string navGalfilename;
1012 std::string navGlofilename;
1013 std::string navBdsfilename;
1014 std::string navMixfilename;
1015 std::vector<std::string> output_navfilename;
1017 std::string d_stringVersion;
1019 double d_fake_cnav_iode;
1021 int d_numberTypesObservations;
1022 bool d_rinex_header_updated;
1023 bool d_rinex_header_written;
1024 bool d_pre_2009_file;
1030 inline std::string& Rinex_Printer::leftJustify(std::string& s,
1031 std::string::size_type length,
1034 if (length < s.length())
1036 s = s.substr(0, length);
1040 s.append(length - s.length(), pad);
1048 inline std::string& Rinex_Printer::rightJustify(std::string& s,
1049 std::string::size_type length,
1052 if (length < s.length())
1054 s = s.substr(s.length() - length, std::string::npos);
1058 s.insert(static_cast<std::string::size_type>(0), length - s.length(), pad);
1064 inline std::string Rinex_Printer::doub2for(
double d,
1065 std::string::size_type length,
1066 std::string::size_type expLen,
1067 bool checkSwitch)
const 1069 int16_t exponentLength = expLen;
1072 if (exponentLength < 0)
1077 if (exponentLength > 3 && checkSwitch)
1082 std::string toReturn = doub2sci(d, length, exponentLength,
true, checkSwitch);
1083 sci2for(toReturn, 0, length, exponentLength, checkSwitch);
1089 inline std::string Rinex_Printer::doub2sci(
double d,
1090 std::string::size_type length,
1091 std::string::size_type expLen,
1093 bool checkSwitch)
const 1095 std::string toReturn;
1096 int16_t exponentLength = expLen;
1099 if (exponentLength < 0)
1104 if (exponentLength > 3 && checkSwitch)
1109 std::stringstream c;
1110 c.setf(std::ios::scientific, std::ios::floatfield);
1123 c.precision(length - 3 - exponentLength - 1 - expSize);
1130 inline std::string& Rinex_Printer::sci2for(std::string& aStr,
1131 std::string::size_type startPos,
1132 std::string::size_type length,
1133 std::string::size_type expLen,
1134 bool checkSwitch)
const 1136 std::string::size_type idx = aStr.find(
'.', startPos);
1142 bool redoexp = !checkSwitch;
1145 if ((idx <= 0) || (idx >= (startPos + length - expLen - 1)))
1160 aStr[idx] = aStr[idx - 1];
1161 aStr[idx - 1] =
'.';
1163 if (asDouble(aStr.substr(startPos, length)) != 0.0)
1169 idx = aStr.find(
'e', startPos);
1170 if (idx == std::string::npos)
1172 idx = aStr.find(
'E', startPos);
1173 if (idx == std::string::npos)
1192 exp = aStr.substr(idx + 1, std::string::npos);
1196 aStr.erase(idx + 1);
1207 aStr += Rinex_Printer::rightJustify(asString(iexp), expLen,
'0');
1214 aStr.insert(static_cast<std::string::size_type>(0), 1,
' ');
1220 aStr.insert(static_cast<std::string::size_type>(1), 1,
'0');
1227 inline std::string asString(
long double x, std::string::size_type precision)
1229 std::ostringstream ss;
1230 ss << std::fixed << std::setprecision(precision) << x;
1235 inline std::string Rinex_Printer::asString(
double x, std::string::size_type precision)
const 1237 std::ostringstream ss;
1238 ss << std::fixed << std::setprecision(precision) << x;
1243 inline std::string Rinex_Printer::asFixWidthString(
int x,
int width,
char fill_digit)
const 1245 std::ostringstream ss;
1246 ss << std::setfill(fill_digit) << std::setw(width) << x;
1247 return ss.str().substr(ss.str().size() - width);
1251 inline int64_t asInt(
const std::string& s)
1253 return strtol(s.c_str(),
nullptr, 10);
1257 inline int Rinex_Printer::toInt(
const std::string& bitString,
int sLength)
const 1261 for (
int i = 0; i < sLength; i++)
1263 tempInt = bitString[i] -
'0';
1264 num |= (1 << (sLength - 1 - i)) * tempInt;
1271 inline std::string Rinex_Printer::asString(
const X x)
const 1273 std::ostringstream ss;
1281 #endif // GNSS_SDR_RINEX_PRINTER_H This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200M. ...
std::string get_obsfilename() const
Returns name of RINEX observation file.
This is a storage class for the GPS CNAV ephemeris data as described in IS-GPS-200M.
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-...
bool is_rinex_header_written() const
Returns true is the RINEX file headers are already written.
Rinex_Printer(int version=0, const std::string &base_path=".", const std::string &base_name="-")
Constructor. Creates GNSS Navigation and Observables RINEX files.
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 print_rinex_annotation(const Rtklib_Solver *pvt_solver, const std::map< int, Gnss_Synchro > &gnss_observables_map, double rx_time, int type_of_rx, bool flag_write_RINEX_obs_output)
Print RINEX annotation. If it is the first annotation, it also prints the RINEX headers for navigatio...
This class is a storage and orbital model functions for the GLONASS SV ephemeris data as described in...
This class implements a PVT solution based on RTKLIB.
~Rinex_Printer()
Destructor. Removes created files if empty.
This is a storage class for the Beidou SV ephemeris data as described in BeiDou Navigation Satellite ...
This is the class that contains the information that is shared by the processing blocks.
void log_rinex_nav_gal_nav(int type_of_rx, const std::map< int32_t, Galileo_Ephemeris > &new_gal_eph)
Print RINEX annotation for Galileo NAV message.
void log_rinex_nav_gps_cnav(int type_of_rx, const std::map< int32_t, Gps_CNAV_Ephemeris > &new_cnav_eph)
Print RINEX annotation for GPS CNAV message.
void log_rinex_nav_gps_nav(int type_of_rx, const std::map< int32_t, Gps_Ephemeris > &new_eph)
Print RINEX annotation for GPS NAV message.
This class is a storage for the GPS UTC MODEL data as described in in IS-GPS-200M.
This class decodes a GPS NAV Data message as described in IS-GPS-200M.
This class is a storage for the GALILEO IONOSPHERIC data as described in Galileo ICD paragraph 5...
void set_pre_2009_file(bool pre_2009_file)
Set processing for signals older than 2009.
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-200M.
This class is a storage for the GLONASS SV ALMANAC data as described GLONASS ICD (Edition 5...
void log_rinex_nav_glo_gnav(int type_of_rx, const std::map< int32_t, Glonass_Gnav_Ephemeris > &new_glo_eph)
Print RINEX annotation for Glonass GNAV message.
This class is a storage for the GALILEO UTC MODEL data as described in Galileo ICD https://www...
std::vector< std::string > get_navfilename() const
Returns name of RINEX navigation file(s)
This class is a storage for the GPS IONOSPHERIC data as described in IS-GPS-200M. ...
void log_rinex_nav_bds_dnav(int type_of_rx, const std::map< int32_t, Beidou_Dnav_Ephemeris > &new_bds_eph)
Print RINEX annotation for BeiDou DNAV message.