1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-15 04:30:33 +00:00

Fix writing of XML files. Previously, the tag boost_serialization was not closed, which caused a failure when trying to read those XML files with Boost >= 1.66

This commit is contained in:
Carles Fernandez 2018-10-06 20:10:16 +02:00
parent 8fd4d8ddc9
commit 79ae0a6c9d
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 22 additions and 33 deletions

View File

@ -506,12 +506,12 @@ bool RtklibPvt::save_assistance_to_XML()
if (eph_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(eph_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);
ofs.close();
LOG(INFO) << "Saved GPS L1 Ephemeris map data";
}
catch (const std::exception& e)
@ -519,13 +519,13 @@ bool RtklibPvt::save_assistance_to_XML()
LOG(WARNING) << e.what();
return false;
}
return true; // return variable (true == succeeded)
}
else
{
LOG(WARNING) << "Failed to save Ephemeris, map is empty";
return false;
}
return true; // return variable (true == succeeded)
}

View File

@ -400,12 +400,12 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
if (d_ls_pvt->gps_cnav_ephemeris_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->gps_cnav_ephemeris_map);
ofs.close();
LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data";
}
catch (std::exception& e)
@ -423,12 +423,12 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
if (d_ls_pvt->gps_ephemeris_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->gps_ephemeris_map);
ofs.close();
LOG(INFO) << "Saved GPS L1 CA Ephemeris map data";
}
catch (const std::exception& e)
@ -446,12 +446,12 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
if (d_ls_pvt->galileo_ephemeris_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->galileo_ephemeris_map);
ofs.close();
LOG(INFO) << "Saved Galileo E1 Ephemeris map data";
}
catch (const std::exception& e)
@ -469,12 +469,12 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
if (d_ls_pvt->glonass_gnav_ephemeris_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_ls_pvt->glonass_gnav_ephemeris_map);
ofs.close();
LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data";
}
catch (std::exception& e)
@ -515,12 +515,12 @@ bool rtklib_pvt_cc::save_gnss_synchro_map_xml(const std::string file_name)
{
if (gnss_observables_map.empty() == false)
{
std::ofstream ofs;
try
{
std::ofstream ofs(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
ofs.open(file_name.c_str(), std::ofstream::trunc | std::ofstream::out);
boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map);
ofs.close();
LOG(INFO) << "Saved gnss_sychro map data";
}
catch (std::exception& e)
@ -537,17 +537,17 @@ bool rtklib_pvt_cc::save_gnss_synchro_map_xml(const std::string file_name)
}
}
bool rtklib_pvt_cc::load_gnss_synchro_map_xml(const std::string file_name)
{
// load from xml (boost serialize)
std::ifstream ifs;
try
{
std::ifstream ifs(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
boost::archive::xml_iarchive xml(ifs);
gnss_observables_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map);
ifs.close();
return true;
//std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl;
}
catch (std::exception& e)
@ -555,6 +555,7 @@ bool rtklib_pvt_cc::load_gnss_synchro_map_xml(const std::string file_name)
std::cout << e.what() << "File: " << file_name;
return false;
}
return true;
}

View File

@ -384,7 +384,6 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
ifs.close();
return true;
}
@ -399,7 +398,6 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
ofs.open(file_name.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);
LOG(INFO) << "Saved Ephemeris map data";
}
catch (std::exception& e)
@ -407,14 +405,13 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
LOG(WARNING) << e.what();
return false;
}
ofs.close();
return true;
}
else
{
LOG(WARNING) << "Failed to save Ephemeris, map is empty";
return false;
}
return true;
}
@ -426,7 +423,6 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
ifs.open(file_name.c_str(), std::ifstream::binary | std::ifstream::in);
boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_utc_map", this->gps_utc);
LOG(INFO) << "Loaded UTC model data";
}
catch (std::exception& e)
@ -434,7 +430,6 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
ifs.close();
return true;
}
@ -456,14 +451,13 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
LOG(WARNING) << e.what();
return false;
}
ofs.close();
return true;
}
else
{
LOG(WARNING) << "Failed to save UTC model, map is empty";
return false;
}
return true;
}
@ -482,7 +476,6 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
ifs.close();
return true;
}
@ -504,14 +497,13 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
LOG(WARNING) << e.what();
return false;
}
ofs.close();
return true;
}
else
{
LOG(WARNING) << "Failed to save IONO model, map is empty";
return false;
}
return true;
}
@ -530,7 +522,6 @@ bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
ifs.close();
return true;
}
@ -553,14 +544,13 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st
LOG(WARNING) << e.what();
return false;
}
ofs.close();
return true;
}
else
{
LOG(WARNING) << "Failed to save Ref Time, map is empty";
return false;
}
return true;
}
@ -579,7 +569,6 @@ bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name;
return false;
}
ifs.close();
return true;
}
@ -601,12 +590,11 @@ bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name
LOG(WARNING) << e.what();
return false;
}
ofs.close();
return true;
}
else
{
LOG(WARNING) << "Failed to save Ref Location, map is empty";
return false;
}
return true;
}