diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 88294b09c..220553a8b 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -117,6 +117,44 @@ Rtklib_Solver::Rtklib_Solver(int nchannels, std::string dump_filename, bool flag } } + +Rtklib_Solver::~Rtklib_Solver() +{ + if (d_dump_file.is_open() == true) + { + auto pos = d_dump_file.tellp(); + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor closing the RTKLIB dump file " << ex.what(); + } + if (pos == 0) + { + errorlib::error_code ec; + if (!fs::remove(fs::path(d_dump_filename), ec)) + { + std::cerr << "Problem removing temporary file " << d_dump_filename << '\n'; + } + d_flag_dump_mat_enabled = false; + } + } + if (d_flag_dump_mat_enabled) + { + try + { + save_matfile(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor saving the PVT .mat dump file " << ex.what(); + } + } +} + + bool Rtklib_Solver::save_matfile() { // READ DUMP FILE @@ -356,43 +394,6 @@ bool Rtklib_Solver::save_matfile() } -Rtklib_Solver::~Rtklib_Solver() -{ - if (d_dump_file.is_open() == true) - { - auto pos = d_dump_file.tellp(); - try - { - d_dump_file.close(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor closing the RTKLIB dump file " << ex.what(); - } - if (pos == 0) - { - errorlib::error_code ec; - if (!fs::remove(fs::path(d_dump_filename), ec)) - { - std::cerr << "Problem removing temporary file " << d_dump_filename << '\n'; - } - d_flag_dump_mat_enabled = false; - } - } - if (d_flag_dump_mat_enabled) - { - try - { - save_matfile(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor saving the PVT .mat dump file " << ex.what(); - } - } -} - - double Rtklib_Solver::get_gdop() const { return dop_[0];