mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2026-09-06 09:28:53 +00:00
Avoid throwing exceptions in main()
This commit is contained in:
+106
-38
@@ -33,7 +33,10 @@
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <random>
|
||||
#include <string>
|
||||
@@ -78,6 +81,8 @@ Concurrent_Map<Gps_Acq_Assist> global_gps_acq_assist_map;
|
||||
|
||||
std::vector<double> TTFF_v;
|
||||
|
||||
const char *const ttff_message_queue_name = "gnss_sdr_ttff_message_queue";
|
||||
|
||||
class TtffTest : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
@@ -298,7 +303,6 @@ void receive_msg()
|
||||
while (!leave)
|
||||
{
|
||||
// wait for the queues to be created
|
||||
const std::string queue_name = "gnss_sdr_ttff_message_queue";
|
||||
std::unique_ptr<boost::interprocess::message_queue> d_mq;
|
||||
bool queue_found = false;
|
||||
while (!queue_found)
|
||||
@@ -306,7 +310,7 @@ void receive_msg()
|
||||
try
|
||||
{
|
||||
// Attempt to open the message queue
|
||||
d_mq = std::make_unique<boost::interprocess::message_queue>(boost::interprocess::open_only, queue_name.c_str());
|
||||
d_mq = std::make_unique<boost::interprocess::message_queue>(boost::interprocess::open_only, ttff_message_queue_name);
|
||||
queue_found = true; // Queue found
|
||||
}
|
||||
catch (const boost::interprocess::interprocess_exception &)
|
||||
@@ -362,6 +366,65 @@ void receive_msg()
|
||||
}
|
||||
|
||||
|
||||
void stop_receive_msg_thread() noexcept
|
||||
{
|
||||
try
|
||||
{
|
||||
boost::interprocess::message_queue::remove(ttff_message_queue_name);
|
||||
boost::interprocess::message_queue mq(
|
||||
boost::interprocess::create_only, // Create a new queue
|
||||
ttff_message_queue_name, // Queue name
|
||||
10, // Maximum number of messages
|
||||
sizeof(double) // Maximum message size
|
||||
);
|
||||
const double finish = -1.0;
|
||||
mq.send(&finish, sizeof(finish), 0);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class ReceiveMsgThreadGuard
|
||||
{
|
||||
public:
|
||||
ReceiveMsgThreadGuard() = default;
|
||||
ReceiveMsgThreadGuard(const ReceiveMsgThreadGuard &) = delete;
|
||||
ReceiveMsgThreadGuard &operator=(const ReceiveMsgThreadGuard &) = delete;
|
||||
ReceiveMsgThreadGuard(ReceiveMsgThreadGuard &&) = delete;
|
||||
ReceiveMsgThreadGuard &operator=(ReceiveMsgThreadGuard &&) = delete;
|
||||
~ReceiveMsgThreadGuard() noexcept
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
receive_msg_thread = std::thread(receive_msg);
|
||||
}
|
||||
|
||||
void Stop() noexcept
|
||||
{
|
||||
if (receive_msg_thread.joinable())
|
||||
{
|
||||
stop_receive_msg_thread();
|
||||
try
|
||||
{
|
||||
receive_msg_thread.join();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
boost::interprocess::message_queue::remove(ttff_message_queue_name);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::thread receive_msg_thread;
|
||||
};
|
||||
|
||||
|
||||
void TtffTest::print_TTFF_report(const std::vector<double> &ttff_v, const std::shared_ptr<ConfigurationInterface> &config_)
|
||||
{
|
||||
std::ofstream ttff_report_file;
|
||||
@@ -701,58 +764,63 @@ TEST_F(TtffTest /*unused*/, HotStart /*unused*/)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::cout << "Running Time-To-First-Fix test...\n";
|
||||
int res = 0;
|
||||
TTFF_v.clear();
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
bool command_line_flags_initialized = false;
|
||||
#endif
|
||||
try
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
} // catch the "testing::internal::<unnamed>::ClassUniqueToAlwaysTrue" from gtest
|
||||
std::cout << "Running Time-To-First-Fix test...\n";
|
||||
TTFF_v.clear();
|
||||
try
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
} // catch the "testing::internal::<unnamed>::ClassUniqueToAlwaysTrue" from gtest
|
||||
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
command_line_flags_initialized = true;
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
#else
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
#endif
|
||||
|
||||
// Start queue thread
|
||||
std::thread receive_msg_thread(receive_msg);
|
||||
// Start queue thread
|
||||
ReceiveMsgThreadGuard receive_msg_thread;
|
||||
receive_msg_thread.Start();
|
||||
|
||||
// Run the Tests
|
||||
try
|
||||
// Run the Tests
|
||||
try
|
||||
{
|
||||
res = RUN_ALL_TESTS();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG(WARNING) << "Unexpected catch";
|
||||
}
|
||||
|
||||
// Terminate the queue thread
|
||||
receive_msg_thread.Stop();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
res = RUN_ALL_TESTS();
|
||||
std::cerr << e.what() << '\n';
|
||||
res = 1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG(WARNING) << "Unexpected catch";
|
||||
std::cerr << "Unexpected error\n";
|
||||
res = 1;
|
||||
}
|
||||
|
||||
// Terminate the queue thread
|
||||
const std::string queue_name = "gnss_sdr_ttff_message_queue";
|
||||
boost::interprocess::message_queue::remove(queue_name.c_str());
|
||||
|
||||
// Create a new message queue
|
||||
auto mq = std::make_unique<boost::interprocess::message_queue>(
|
||||
boost::interprocess::create_only, // Create a new queue
|
||||
queue_name.c_str(), // Queue name
|
||||
10, // Maximum number of messages
|
||||
sizeof(double) // Maximum message size
|
||||
);
|
||||
double finish = -1.0;
|
||||
if (mq)
|
||||
{
|
||||
mq->send(&finish, sizeof(finish), 0);
|
||||
}
|
||||
receive_msg_thread.join();
|
||||
boost::interprocess::message_queue::remove(queue_name.c_str());
|
||||
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
if (command_line_flags_initialized)
|
||||
{
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ if(TARGET Boost::iostreams AND TARGET Boost::serialization)
|
||||
${GNSSTK_LIBRARY}
|
||||
Threads::Threads
|
||||
core_system_parameters
|
||||
algorithms_libs
|
||||
)
|
||||
|
||||
if(ENABLE_GLOG_AND_GFLAGS)
|
||||
|
||||
+496
-429
@@ -19,6 +19,7 @@
|
||||
#include "galileo_ephemeris.h" // IWYU pragma: keep
|
||||
#include "galileo_iono.h"
|
||||
#include "galileo_utc_model.h"
|
||||
#include "gnss_sdr_filesystem.h"
|
||||
#include "gps_ephemeris.h"
|
||||
#include "gps_iono.h"
|
||||
#include "gps_utc_model.h"
|
||||
@@ -28,8 +29,11 @@
|
||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
#include <cstddef> // for size_t
|
||||
#include <cstdlib>
|
||||
#include <exception>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#if GNSSTK_USES_GPSTK_NAMESPACE
|
||||
#include <gpstk/Epoch.hpp>
|
||||
#include <gpstk/GPSWeekSecond.hpp>
|
||||
@@ -61,437 +65,500 @@ using namespace google;
|
||||
std::string TstVersionString() { return "1.0"; }
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
||||
static bool copy_file_binary(const std::string& source_filename, const std::string& destination_filename)
|
||||
{
|
||||
const std::string intro_help(
|
||||
std::string("\n rinex2assist converts navigation RINEX files into XML files for Assisted GNSS\n") +
|
||||
"Copyright (C) 2018 (see AUTHORS file for a list of contributors)\n" +
|
||||
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
||||
"See COPYING file to see a copy of the General Public License.\n \n" +
|
||||
"Usage: \n" +
|
||||
" rinex2assist <RINEX Nav file input>");
|
||||
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::SetUsageMessage(intro_help);
|
||||
google::SetVersionString("1.0");
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
#else
|
||||
absl::FlagsUsageConfig empty_config;
|
||||
empty_config.version_string = &TstVersionString;
|
||||
absl::SetFlagsUsageConfig(empty_config);
|
||||
absl::SetProgramUsageMessage(intro_help);
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
#endif
|
||||
if ((argc != 2))
|
||||
std::ifstream source(source_filename.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if (!source)
|
||||
{
|
||||
std::cerr << "Usage:\n";
|
||||
std::cerr << " " << argv[0]
|
||||
<< " <RINEX Nav file input>"
|
||||
<< '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
std::string xml_filename;
|
||||
|
||||
// Uncompress if RINEX file is gzipped
|
||||
std::string rinex_filename(argv[1]);
|
||||
std::string input_filename = rinex_filename;
|
||||
std::size_t found = rinex_filename.find_last_of('.');
|
||||
if (found != std::string::npos)
|
||||
std::ofstream destination(destination_filename.c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (!destination)
|
||||
{
|
||||
if (rinex_filename.size() >= found + 3)
|
||||
{
|
||||
if ((rinex_filename.substr(found + 1, found + 3) == "gz"))
|
||||
{
|
||||
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not open file " << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
|
||||
try
|
||||
{
|
||||
in.push(boost::iostreams::gzip_decompressor());
|
||||
}
|
||||
catch (const boost::exception& e)
|
||||
{
|
||||
std::cerr << "Could not decompress file " << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
in.push(file);
|
||||
std::string rinex_filename_unzipped = rinex_filename.substr(0, found);
|
||||
std::ofstream output_file(rinex_filename_unzipped.c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not create file " << rinex_filename_unzipped << '\n';
|
||||
return 1;
|
||||
}
|
||||
boost::iostreams::copy(in, output_file);
|
||||
input_filename = rinex_filename_unzipped;
|
||||
}
|
||||
}
|
||||
if (rinex_filename.size() >= found + 2)
|
||||
{
|
||||
if ((rinex_filename.substr(found + 1, found + 2) == "Z"))
|
||||
{
|
||||
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not open file" << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
file.close();
|
||||
std::string uncompress_executable(UNCOMPRESS_EXECUTABLE);
|
||||
if (!uncompress_executable.empty())
|
||||
{
|
||||
// option k is not always available, so we save a copy of the original file
|
||||
std::string argum = std::string("/bin/cp " + rinex_filename + " " + rinex_filename + ".aux");
|
||||
int s1 = std::system(argum.c_str());
|
||||
std::string argum2 = std::string(uncompress_executable + " -f " + rinex_filename);
|
||||
int s2 = std::system(argum2.c_str());
|
||||
std::string argum3 = std::string("/bin/mv " + rinex_filename + +".aux" + " " + rinex_filename);
|
||||
int s3 = std::system(argum3.c_str());
|
||||
input_filename = rinex_filename.substr(0, found);
|
||||
if ((s1 != 0) or (s2 != 0) or (s3 != 0))
|
||||
{
|
||||
std::cerr << "Failure uncompressing file.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "uncompress program not found.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<int, Gps_Ephemeris> eph_map;
|
||||
std::map<int, Galileo_Ephemeris> eph_gal_map;
|
||||
|
||||
Gps_Utc_Model gps_utc_model;
|
||||
Gps_Iono gps_iono;
|
||||
Galileo_Utc_Model gal_utc_model;
|
||||
Galileo_Iono gal_iono;
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try
|
||||
{
|
||||
// Read nav file
|
||||
gnsstk::Rinex3NavStream rnffs(input_filename.c_str()); // Open navigation data file
|
||||
gnsstk::Rinex3NavData rne;
|
||||
gnsstk::Rinex3NavHeader hdr;
|
||||
|
||||
// Read header
|
||||
rnffs >> hdr;
|
||||
|
||||
// Check that it really is a RINEX navigation file
|
||||
if (hdr.fileType.substr(0, 1) != "N")
|
||||
{
|
||||
std::cerr << "This is not a valid RINEX navigation file, or file not found.\n";
|
||||
std::cerr << "No XML file will be created.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Collect UTC parameters from RINEX header
|
||||
if (hdr.fileSys == "G: (GPS)" || hdr.fileSys == "MIXED")
|
||||
{
|
||||
gps_utc_model.valid = (hdr.valid > 2147483648) ? true : false;
|
||||
gps_utc_model.A1 = hdr.mapTimeCorr["GPUT"].A0;
|
||||
gps_utc_model.A0 = hdr.mapTimeCorr["GPUT"].A1;
|
||||
#if GNSSTK_OLDER_THAN_9
|
||||
gps_utc_model.tot = hdr.mapTimeCorr["GPUT"].refSOW;
|
||||
gps_utc_model.WN_T = hdr.mapTimeCorr["GPUT"].refWeek;
|
||||
#else
|
||||
if (hdr.mapTimeCorr["GPUT"].refTime != gnsstk::CommonTime::BEGINNING_OF_TIME)
|
||||
{
|
||||
gnsstk::GPSWeekSecond gws(hdr.mapTimeCorr["GPUT"].refTime);
|
||||
gps_utc_model.tot = gws.getSOW();
|
||||
gps_utc_model.WN_T = gws.getWeek();
|
||||
}
|
||||
#endif
|
||||
gps_utc_model.DeltaT_LS = hdr.leapSeconds;
|
||||
gps_utc_model.WN_LSF = hdr.leapWeek;
|
||||
gps_utc_model.DN = hdr.leapDay;
|
||||
gps_utc_model.DeltaT_LSF = hdr.leapDelta;
|
||||
|
||||
// Collect iono parameters from RINEX header
|
||||
gps_iono.valid = (hdr.mapIonoCorr["GPSA"].param[0] == 0) ? false : true;
|
||||
gps_iono.alpha0 = hdr.mapIonoCorr["GPSA"].param[0];
|
||||
gps_iono.alpha1 = hdr.mapIonoCorr["GPSA"].param[1];
|
||||
gps_iono.alpha2 = hdr.mapIonoCorr["GPSA"].param[2];
|
||||
gps_iono.alpha3 = hdr.mapIonoCorr["GPSA"].param[3];
|
||||
gps_iono.beta0 = hdr.mapIonoCorr["GPSB"].param[0];
|
||||
gps_iono.beta1 = hdr.mapIonoCorr["GPSB"].param[1];
|
||||
gps_iono.beta2 = hdr.mapIonoCorr["GPSB"].param[2];
|
||||
gps_iono.beta3 = hdr.mapIonoCorr["GPSB"].param[3];
|
||||
}
|
||||
if (hdr.fileSys == "E: (GAL)" || hdr.fileSys == "MIXED")
|
||||
{
|
||||
gal_utc_model.A0 = hdr.mapTimeCorr["GAUT"].A0;
|
||||
gal_utc_model.A1 = hdr.mapTimeCorr["GAUT"].A1;
|
||||
gal_utc_model.Delta_tLS = hdr.leapSeconds;
|
||||
#if GNSSTK_OLDER_THAN_9
|
||||
gal_utc_model.tot = hdr.mapTimeCorr["GAUT"].refSOW;
|
||||
gal_utc_model.WNot = hdr.mapTimeCorr["GAUT"].refWeek;
|
||||
#else
|
||||
if (hdr.mapTimeCorr["GAUT"].refTime != gnsstk::CommonTime::BEGINNING_OF_TIME)
|
||||
{
|
||||
gnsstk::GPSWeekSecond gws(hdr.mapTimeCorr["GAUT"].refTime);
|
||||
gal_utc_model.tot = gws.getSOW();
|
||||
gal_utc_model.WNot = gws.getWeek();
|
||||
}
|
||||
#endif
|
||||
gal_utc_model.WN_LSF = hdr.leapWeek;
|
||||
gal_utc_model.DN = hdr.leapDay;
|
||||
gal_utc_model.Delta_tLSF = hdr.leapDelta;
|
||||
gal_utc_model.flag_utc_model = (hdr.mapTimeCorr["GAUT"].A0 == 0.0);
|
||||
gal_iono.ai0 = hdr.mapIonoCorr["GAL"].param[0];
|
||||
gal_iono.ai1 = hdr.mapIonoCorr["GAL"].param[1];
|
||||
gal_iono.ai2 = hdr.mapIonoCorr["GAL"].param[2];
|
||||
gal_iono.Region1_flag = false;
|
||||
gal_iono.Region2_flag = false;
|
||||
gal_iono.Region3_flag = false;
|
||||
gal_iono.Region4_flag = false;
|
||||
gal_iono.Region5_flag = false;
|
||||
gal_iono.tow = 0.0;
|
||||
gal_iono.WN = 0.0;
|
||||
}
|
||||
|
||||
// Read navigation data
|
||||
while (rnffs >> rne)
|
||||
{
|
||||
if (rne.satSys == "G" or rne.satSys.empty())
|
||||
{
|
||||
// Fill GPS ephemeris object
|
||||
Gps_Ephemeris eph;
|
||||
eph.PRN = rne.PRNID;
|
||||
eph.tow = rne.xmitTime;
|
||||
eph.IODE_SF2 = rne.IODE;
|
||||
eph.IODE_SF3 = rne.IODE;
|
||||
eph.Crs = rne.Crs;
|
||||
eph.delta_n = rne.dn;
|
||||
eph.M_0 = rne.M0;
|
||||
eph.Cuc = rne.Cuc;
|
||||
eph.ecc = rne.ecc;
|
||||
eph.Cus = rne.Cus;
|
||||
eph.sqrtA = rne.Ahalf;
|
||||
eph.toe = rne.Toe;
|
||||
eph.toc = rne.Toc;
|
||||
eph.Cic = rne.Cic;
|
||||
eph.OMEGA_0 = rne.OMEGA0;
|
||||
eph.Cis = rne.Cis;
|
||||
eph.i_0 = rne.i0;
|
||||
eph.Crc = rne.Crc;
|
||||
eph.omega = rne.w;
|
||||
eph.OMEGAdot = rne.OMEGAdot;
|
||||
eph.idot = rne.idot;
|
||||
eph.code_on_L2 = rne.codeflgs; //
|
||||
eph.WN = rne.weeknum;
|
||||
eph.L2_P_data_flag = rne.L2Pdata;
|
||||
eph.SV_accuracy = rne.accuracy;
|
||||
eph.SV_health = rne.health;
|
||||
eph.TGD = rne.Tgd;
|
||||
eph.IODC = rne.IODC;
|
||||
eph.AODO = 0; //
|
||||
eph.fit_interval_flag = (rne.fitint > 4) ? true : false;
|
||||
eph.spare1 = 0.0;
|
||||
eph.spare2 = 0.0;
|
||||
eph.af0 = rne.af0;
|
||||
eph.af1 = rne.af1;
|
||||
eph.af2 = rne.af2;
|
||||
eph.integrity_status_flag = false; //
|
||||
eph.alert_flag = false; //
|
||||
eph.antispoofing_flag = false; //
|
||||
eph_map[i] = eph;
|
||||
i++;
|
||||
}
|
||||
if (rne.satSys == "E")
|
||||
{
|
||||
// Fill Galileo ephemeris object
|
||||
Galileo_Ephemeris eph;
|
||||
eph.PRN = rne.PRNID;
|
||||
eph.M_0 = rne.M0;
|
||||
eph.ecc = rne.ecc;
|
||||
eph.sqrtA = rne.Ahalf;
|
||||
eph.OMEGA_0 = rne.OMEGA0;
|
||||
eph.i_0 = rne.i0;
|
||||
eph.omega = rne.w;
|
||||
eph.OMEGAdot = rne.OMEGAdot;
|
||||
eph.delta_n = rne.dn;
|
||||
eph.idot = rne.idot;
|
||||
eph.Cuc = rne.Cuc;
|
||||
eph.Cus = rne.Cus;
|
||||
eph.Crc = rne.Crc;
|
||||
eph.Crs = rne.Crs;
|
||||
eph.Cic = rne.Cic;
|
||||
eph.Cis = rne.Cis;
|
||||
eph.toe = rne.Toe;
|
||||
eph.toc = rne.Toc;
|
||||
eph.af0 = rne.af0;
|
||||
eph.af1 = rne.af1;
|
||||
eph.af2 = rne.af2;
|
||||
eph.WN = rne.weeknum;
|
||||
eph_gal_map[j] = eph;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Error reading the RINEX file: " << e.what() << '\n';
|
||||
std::cerr << "No XML file will be created.\n";
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (i == 0 and j == 0)
|
||||
{
|
||||
std::cerr << "No navigation data found in the RINEX file. No XML file will be created.\n";
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Write XML ephemeris
|
||||
if (i != 0)
|
||||
{
|
||||
std::ofstream ofs;
|
||||
if (xml_filename.empty())
|
||||
{
|
||||
xml_filename = "gps_ephemeris.xml";
|
||||
}
|
||||
try
|
||||
{
|
||||
ofs.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
if (j != 0)
|
||||
{
|
||||
std::ofstream ofs2;
|
||||
xml_filename = "gal_ephemeris.xml";
|
||||
try
|
||||
{
|
||||
ofs2.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs2);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", eph_gal_map);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
// Write XML UTC
|
||||
if (gps_utc_model.valid)
|
||||
{
|
||||
std::ofstream ofs3;
|
||||
xml_filename = "gps_utc_model.xml";
|
||||
try
|
||||
{
|
||||
ofs3.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs3);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", gps_utc_model);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
// Write XML iono
|
||||
if (gps_iono.valid)
|
||||
{
|
||||
std::ofstream ofs4;
|
||||
xml_filename = "gps_iono.xml";
|
||||
try
|
||||
{
|
||||
ofs4.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs4);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", gps_iono);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
if (gal_utc_model.A0 != 0)
|
||||
{
|
||||
std::ofstream ofs5;
|
||||
xml_filename = "gal_utc_model.xml";
|
||||
try
|
||||
{
|
||||
ofs5.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs5);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", gal_utc_model);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
if (gal_iono.ai0 != 0)
|
||||
{
|
||||
std::ofstream ofs7;
|
||||
xml_filename = "gal_iono.xml";
|
||||
try
|
||||
{
|
||||
ofs7.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs7);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", gal_iono);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 0;
|
||||
destination << source.rdbuf();
|
||||
return destination.good();
|
||||
}
|
||||
|
||||
|
||||
static int run_uncompress(const std::string& uncompress_executable, const std::string& filename)
|
||||
{
|
||||
const pid_t pid = fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (pid == 0)
|
||||
{
|
||||
execl(uncompress_executable.c_str(), uncompress_executable.c_str(), "-f", filename.c_str(), static_cast<char*>(nullptr));
|
||||
_exit(127);
|
||||
}
|
||||
|
||||
int status = 0;
|
||||
if (waitpid(pid, &status, 0) == -1)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (WIFEXITED(status))
|
||||
{
|
||||
return WEXITSTATUS(status);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
try
|
||||
{
|
||||
const std::string intro_help(
|
||||
std::string("\n rinex2assist converts navigation RINEX files into XML files for Assisted GNSS\n") +
|
||||
"Copyright (C) 2018 (see AUTHORS file for a list of contributors)\n" +
|
||||
"This program comes with ABSOLUTELY NO WARRANTY;\n" +
|
||||
"See COPYING file to see a copy of the General Public License.\n \n" +
|
||||
"Usage: \n" +
|
||||
" rinex2assist <RINEX Nav file input>");
|
||||
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::SetUsageMessage(intro_help);
|
||||
google::SetVersionString("1.0");
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
#else
|
||||
absl::FlagsUsageConfig empty_config;
|
||||
empty_config.version_string = &TstVersionString;
|
||||
absl::SetFlagsUsageConfig(empty_config);
|
||||
absl::SetProgramUsageMessage(intro_help);
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
#endif
|
||||
if ((argc != 2))
|
||||
{
|
||||
std::cerr << "Usage:\n";
|
||||
std::cerr << " " << argv[0]
|
||||
<< " <RINEX Nav file input>"
|
||||
<< '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::string xml_filename;
|
||||
|
||||
// Uncompress if RINEX file is gzipped
|
||||
std::string rinex_filename(argv[1]);
|
||||
std::string input_filename = rinex_filename;
|
||||
std::size_t found = rinex_filename.find_last_of('.');
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
if (rinex_filename.size() >= found + 3)
|
||||
{
|
||||
if ((rinex_filename.substr(found + 1, found + 3) == "gz"))
|
||||
{
|
||||
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not open file " << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
|
||||
try
|
||||
{
|
||||
in.push(boost::iostreams::gzip_decompressor());
|
||||
}
|
||||
catch (const boost::exception& e)
|
||||
{
|
||||
std::cerr << "Could not decompress file " << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
in.push(file);
|
||||
std::string rinex_filename_unzipped = rinex_filename.substr(0, found);
|
||||
std::ofstream output_file(rinex_filename_unzipped.c_str(), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not create file " << rinex_filename_unzipped << '\n';
|
||||
return 1;
|
||||
}
|
||||
boost::iostreams::copy(in, output_file);
|
||||
input_filename = rinex_filename_unzipped;
|
||||
}
|
||||
}
|
||||
if (rinex_filename.size() >= found + 2)
|
||||
{
|
||||
if ((rinex_filename.substr(found + 1, found + 2) == "Z"))
|
||||
{
|
||||
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
|
||||
if (file.fail())
|
||||
{
|
||||
std::cerr << "Could not open file" << rinex_filename << '\n';
|
||||
return 1;
|
||||
}
|
||||
file.close();
|
||||
std::string uncompress_executable(UNCOMPRESS_EXECUTABLE);
|
||||
if (!uncompress_executable.empty())
|
||||
{
|
||||
// option k is not always available, so we save a copy of the original file
|
||||
const std::string rinex_filename_aux = rinex_filename + ".aux";
|
||||
const bool copy_ok = copy_file_binary(rinex_filename, rinex_filename_aux);
|
||||
const int uncompress_status = copy_ok ? run_uncompress(uncompress_executable, rinex_filename) : -1;
|
||||
errorlib::error_code ec;
|
||||
if (copy_ok)
|
||||
{
|
||||
fs::rename(fs::path(rinex_filename_aux), fs::path(rinex_filename), ec);
|
||||
}
|
||||
input_filename = rinex_filename.substr(0, found);
|
||||
if (!copy_ok || (uncompress_status != 0) || ec)
|
||||
{
|
||||
std::cerr << "Failure uncompressing file.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "uncompress program not found.\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::map<int, Gps_Ephemeris> eph_map;
|
||||
std::map<int, Galileo_Ephemeris> eph_gal_map;
|
||||
|
||||
Gps_Utc_Model gps_utc_model;
|
||||
Gps_Iono gps_iono;
|
||||
Galileo_Utc_Model gal_utc_model;
|
||||
Galileo_Iono gal_iono;
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
try
|
||||
{
|
||||
// Read nav file
|
||||
gnsstk::Rinex3NavStream rnffs(input_filename.c_str()); // Open navigation data file
|
||||
gnsstk::Rinex3NavData rne;
|
||||
gnsstk::Rinex3NavHeader hdr;
|
||||
|
||||
// Read header
|
||||
rnffs >> hdr;
|
||||
|
||||
// Check that it really is a RINEX navigation file
|
||||
if (hdr.fileType.substr(0, 1) != "N")
|
||||
{
|
||||
std::cerr << "This is not a valid RINEX navigation file, or file not found.\n";
|
||||
std::cerr << "No XML file will be created.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Collect UTC parameters from RINEX header
|
||||
if (hdr.fileSys == "G: (GPS)" || hdr.fileSys == "MIXED")
|
||||
{
|
||||
gps_utc_model.valid = (hdr.valid > 2147483648) ? true : false;
|
||||
gps_utc_model.A1 = hdr.mapTimeCorr["GPUT"].A0;
|
||||
gps_utc_model.A0 = hdr.mapTimeCorr["GPUT"].A1;
|
||||
#if GNSSTK_OLDER_THAN_9
|
||||
gps_utc_model.tot = hdr.mapTimeCorr["GPUT"].refSOW;
|
||||
gps_utc_model.WN_T = hdr.mapTimeCorr["GPUT"].refWeek;
|
||||
#else
|
||||
if (hdr.mapTimeCorr["GPUT"].refTime != gnsstk::CommonTime::BEGINNING_OF_TIME)
|
||||
{
|
||||
gnsstk::GPSWeekSecond gws(hdr.mapTimeCorr["GPUT"].refTime);
|
||||
gps_utc_model.tot = gws.getSOW();
|
||||
gps_utc_model.WN_T = gws.getWeek();
|
||||
}
|
||||
#endif
|
||||
gps_utc_model.DeltaT_LS = hdr.leapSeconds;
|
||||
gps_utc_model.WN_LSF = hdr.leapWeek;
|
||||
gps_utc_model.DN = hdr.leapDay;
|
||||
gps_utc_model.DeltaT_LSF = hdr.leapDelta;
|
||||
|
||||
// Collect iono parameters from RINEX header
|
||||
gps_iono.valid = (hdr.mapIonoCorr["GPSA"].param[0] == 0) ? false : true;
|
||||
gps_iono.alpha0 = hdr.mapIonoCorr["GPSA"].param[0];
|
||||
gps_iono.alpha1 = hdr.mapIonoCorr["GPSA"].param[1];
|
||||
gps_iono.alpha2 = hdr.mapIonoCorr["GPSA"].param[2];
|
||||
gps_iono.alpha3 = hdr.mapIonoCorr["GPSA"].param[3];
|
||||
gps_iono.beta0 = hdr.mapIonoCorr["GPSB"].param[0];
|
||||
gps_iono.beta1 = hdr.mapIonoCorr["GPSB"].param[1];
|
||||
gps_iono.beta2 = hdr.mapIonoCorr["GPSB"].param[2];
|
||||
gps_iono.beta3 = hdr.mapIonoCorr["GPSB"].param[3];
|
||||
}
|
||||
if (hdr.fileSys == "E: (GAL)" || hdr.fileSys == "MIXED")
|
||||
{
|
||||
gal_utc_model.A0 = hdr.mapTimeCorr["GAUT"].A0;
|
||||
gal_utc_model.A1 = hdr.mapTimeCorr["GAUT"].A1;
|
||||
gal_utc_model.Delta_tLS = hdr.leapSeconds;
|
||||
#if GNSSTK_OLDER_THAN_9
|
||||
gal_utc_model.tot = hdr.mapTimeCorr["GAUT"].refSOW;
|
||||
gal_utc_model.WNot = hdr.mapTimeCorr["GAUT"].refWeek;
|
||||
#else
|
||||
if (hdr.mapTimeCorr["GAUT"].refTime != gnsstk::CommonTime::BEGINNING_OF_TIME)
|
||||
{
|
||||
gnsstk::GPSWeekSecond gws(hdr.mapTimeCorr["GAUT"].refTime);
|
||||
gal_utc_model.tot = gws.getSOW();
|
||||
gal_utc_model.WNot = gws.getWeek();
|
||||
}
|
||||
#endif
|
||||
gal_utc_model.WN_LSF = hdr.leapWeek;
|
||||
gal_utc_model.DN = hdr.leapDay;
|
||||
gal_utc_model.Delta_tLSF = hdr.leapDelta;
|
||||
gal_utc_model.flag_utc_model = (hdr.mapTimeCorr["GAUT"].A0 == 0.0);
|
||||
gal_iono.ai0 = hdr.mapIonoCorr["GAL"].param[0];
|
||||
gal_iono.ai1 = hdr.mapIonoCorr["GAL"].param[1];
|
||||
gal_iono.ai2 = hdr.mapIonoCorr["GAL"].param[2];
|
||||
gal_iono.Region1_flag = false;
|
||||
gal_iono.Region2_flag = false;
|
||||
gal_iono.Region3_flag = false;
|
||||
gal_iono.Region4_flag = false;
|
||||
gal_iono.Region5_flag = false;
|
||||
gal_iono.tow = 0.0;
|
||||
gal_iono.WN = 0.0;
|
||||
}
|
||||
|
||||
// Read navigation data
|
||||
while (rnffs >> rne)
|
||||
{
|
||||
if (rne.satSys == "G" or rne.satSys.empty())
|
||||
{
|
||||
// Fill GPS ephemeris object
|
||||
Gps_Ephemeris eph;
|
||||
eph.PRN = rne.PRNID;
|
||||
eph.tow = rne.xmitTime;
|
||||
eph.IODE_SF2 = rne.IODE;
|
||||
eph.IODE_SF3 = rne.IODE;
|
||||
eph.Crs = rne.Crs;
|
||||
eph.delta_n = rne.dn;
|
||||
eph.M_0 = rne.M0;
|
||||
eph.Cuc = rne.Cuc;
|
||||
eph.ecc = rne.ecc;
|
||||
eph.Cus = rne.Cus;
|
||||
eph.sqrtA = rne.Ahalf;
|
||||
eph.toe = rne.Toe;
|
||||
eph.toc = rne.Toc;
|
||||
eph.Cic = rne.Cic;
|
||||
eph.OMEGA_0 = rne.OMEGA0;
|
||||
eph.Cis = rne.Cis;
|
||||
eph.i_0 = rne.i0;
|
||||
eph.Crc = rne.Crc;
|
||||
eph.omega = rne.w;
|
||||
eph.OMEGAdot = rne.OMEGAdot;
|
||||
eph.idot = rne.idot;
|
||||
eph.code_on_L2 = rne.codeflgs; //
|
||||
eph.WN = rne.weeknum;
|
||||
eph.L2_P_data_flag = rne.L2Pdata;
|
||||
eph.SV_accuracy = rne.accuracy;
|
||||
eph.SV_health = rne.health;
|
||||
eph.TGD = rne.Tgd;
|
||||
eph.IODC = rne.IODC;
|
||||
eph.AODO = 0; //
|
||||
eph.fit_interval_flag = (rne.fitint > 4) ? true : false;
|
||||
eph.spare1 = 0.0;
|
||||
eph.spare2 = 0.0;
|
||||
eph.af0 = rne.af0;
|
||||
eph.af1 = rne.af1;
|
||||
eph.af2 = rne.af2;
|
||||
eph.integrity_status_flag = false; //
|
||||
eph.alert_flag = false; //
|
||||
eph.antispoofing_flag = false; //
|
||||
eph_map[i] = eph;
|
||||
i++;
|
||||
}
|
||||
if (rne.satSys == "E")
|
||||
{
|
||||
// Fill Galileo ephemeris object
|
||||
Galileo_Ephemeris eph;
|
||||
eph.PRN = rne.PRNID;
|
||||
eph.M_0 = rne.M0;
|
||||
eph.ecc = rne.ecc;
|
||||
eph.sqrtA = rne.Ahalf;
|
||||
eph.OMEGA_0 = rne.OMEGA0;
|
||||
eph.i_0 = rne.i0;
|
||||
eph.omega = rne.w;
|
||||
eph.OMEGAdot = rne.OMEGAdot;
|
||||
eph.delta_n = rne.dn;
|
||||
eph.idot = rne.idot;
|
||||
eph.Cuc = rne.Cuc;
|
||||
eph.Cus = rne.Cus;
|
||||
eph.Crc = rne.Crc;
|
||||
eph.Crs = rne.Crs;
|
||||
eph.Cic = rne.Cic;
|
||||
eph.Cis = rne.Cis;
|
||||
eph.toe = rne.Toe;
|
||||
eph.toc = rne.Toc;
|
||||
eph.af0 = rne.af0;
|
||||
eph.af1 = rne.af1;
|
||||
eph.af2 = rne.af2;
|
||||
eph.WN = rne.weeknum;
|
||||
eph_gal_map[j] = eph;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Error reading the RINEX file: " << e.what() << '\n';
|
||||
std::cerr << "No XML file will be created.\n";
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (i == 0 and j == 0)
|
||||
{
|
||||
std::cerr << "No navigation data found in the RINEX file. No XML file will be created.\n";
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Write XML ephemeris
|
||||
if (i != 0)
|
||||
{
|
||||
std::ofstream ofs;
|
||||
if (xml_filename.empty())
|
||||
{
|
||||
xml_filename = "gps_ephemeris.xml";
|
||||
}
|
||||
try
|
||||
{
|
||||
ofs.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
if (j != 0)
|
||||
{
|
||||
std::ofstream ofs2;
|
||||
xml_filename = "gal_ephemeris.xml";
|
||||
try
|
||||
{
|
||||
ofs2.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs2);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", eph_gal_map);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
// Write XML UTC
|
||||
if (gps_utc_model.valid)
|
||||
{
|
||||
std::ofstream ofs3;
|
||||
xml_filename = "gps_utc_model.xml";
|
||||
try
|
||||
{
|
||||
ofs3.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs3);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_utc_model", gps_utc_model);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
// Write XML iono
|
||||
if (gps_iono.valid)
|
||||
{
|
||||
std::ofstream ofs4;
|
||||
xml_filename = "gps_iono.xml";
|
||||
try
|
||||
{
|
||||
ofs4.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs4);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", gps_iono);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
|
||||
if (gal_utc_model.A0 != 0)
|
||||
{
|
||||
std::ofstream ofs5;
|
||||
xml_filename = "gal_utc_model.xml";
|
||||
try
|
||||
{
|
||||
ofs5.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs5);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", gal_utc_model);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
if (gal_iono.ai0 != 0)
|
||||
{
|
||||
std::ofstream ofs7;
|
||||
xml_filename = "gal_iono.xml";
|
||||
try
|
||||
{
|
||||
ofs7.open(xml_filename.c_str(), std::ofstream::trunc | std::ofstream::out);
|
||||
boost::archive::xml_oarchive xml(ofs7);
|
||||
xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", gal_iono);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << "Problem creating the XML file " << xml_filename << ": " << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
std::cout << "Generated file: " << xml_filename << '\n';
|
||||
}
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Unexpected error\n";
|
||||
#if USE_GLOG_AND_GFLAGS
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user