1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-28 05:33:20 +00:00

Fix runtime error when using Boost >= 1.66

This commit is contained in:
Carles Fernandez 2018-10-06 13:52:48 +02:00
parent 8d4e450f44
commit d9ac749575
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 41 additions and 23 deletions

View File

@ -370,13 +370,13 @@ void gnss_sdr_supl_client::read_supl_data()
bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name) bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name)
{ {
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
gps_ephemeris_map.clear(); gps_ephemeris_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_ephemeris_map); xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", this->gps_ephemeris_map);
ifs.close();
LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_ephemeris_map.size() << " satellites"; LOG(INFO) << "Loaded Ephemeris map data with " << this->gps_ephemeris_map.size() << " satellites";
} }
catch (std::exception& e) catch (std::exception& e)
@ -384,6 +384,7 @@ bool gnss_sdr_supl_client::load_ephemeris_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name; LOG(WARNING) << e.what() << "File: " << file_name;
return false; return false;
} }
ifs.close();
return true; return true;
} }
@ -392,12 +393,13 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
{ {
if (eph_map.empty() == false) if (eph_map.empty() == false)
{ {
std::ofstream ofs;
try 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); boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map); xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", eph_map);
ofs.close();
LOG(INFO) << "Saved Ephemeris map data"; LOG(INFO) << "Saved Ephemeris map data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -405,6 +407,7 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
LOG(WARNING) << e.what(); LOG(WARNING) << e.what();
return false; return false;
} }
ofs.close();
return true; return true;
} }
else else
@ -417,12 +420,13 @@ bool gnss_sdr_supl_client::save_ephemeris_map_xml(const std::string file_name, s
bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name) bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
{ {
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_utc_map", this->gps_utc); xml >> boost::serialization::make_nvp("GNSS-SDR_utc_map", this->gps_utc);
ifs.close();
LOG(INFO) << "Loaded UTC model data"; LOG(INFO) << "Loaded UTC model data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -430,6 +434,7 @@ bool gnss_sdr_supl_client::load_utc_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name; LOG(WARNING) << e.what() << "File: " << file_name;
return false; return false;
} }
ifs.close();
return true; return true;
} }
@ -438,12 +443,12 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
{ {
if (utc_map.empty() == false) if (utc_map.empty() == false)
{ {
std::ofstream ofs;
try 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); boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_utc_map", utc_map); xml << boost::serialization::make_nvp("GNSS-SDR_utc_map", utc_map);
ofs.close();
LOG(INFO) << "Saved UTC Model data"; LOG(INFO) << "Saved UTC Model data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -451,6 +456,7 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
LOG(WARNING) << e.what(); LOG(WARNING) << e.what();
return false; return false;
} }
ofs.close();
return true; return true;
} }
else else
@ -463,12 +469,12 @@ bool gnss_sdr_supl_client::save_utc_map_xml(const std::string file_name, std::ma
bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name) bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
{ {
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_iono_map", this->gps_iono); xml >> boost::serialization::make_nvp("GNSS-SDR_iono_map", this->gps_iono);
ifs.close();
LOG(INFO) << "Loaded IONO model data"; LOG(INFO) << "Loaded IONO model data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -476,6 +482,7 @@ bool gnss_sdr_supl_client::load_iono_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name; LOG(WARNING) << e.what() << "File: " << file_name;
return false; return false;
} }
ifs.close();
return true; return true;
} }
@ -484,12 +491,12 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
{ {
if (iono_map.empty() == false) if (iono_map.empty() == false)
{ {
std::ofstream ofs;
try 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); boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_iono_map", iono_map); xml << boost::serialization::make_nvp("GNSS-SDR_iono_map", iono_map);
ofs.close();
LOG(INFO) << "Saved IONO Model data"; LOG(INFO) << "Saved IONO Model data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -497,6 +504,7 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
LOG(WARNING) << e.what(); LOG(WARNING) << e.what();
return false; return false;
} }
ofs.close();
return true; return true;
} }
else else
@ -509,12 +517,12 @@ bool gnss_sdr_supl_client::save_iono_map_xml(const std::string file_name, std::m
bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name) bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name)
{ {
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_ref_time_map", this->gps_time); xml >> boost::serialization::make_nvp("GNSS-SDR_ref_time_map", this->gps_time);
ifs.close();
LOG(INFO) << "Loaded Ref Time data"; LOG(INFO) << "Loaded Ref Time data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -522,6 +530,7 @@ bool gnss_sdr_supl_client::load_ref_time_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name; LOG(WARNING) << e.what() << "File: " << file_name;
return false; return false;
} }
ifs.close();
return true; return true;
} }
@ -530,12 +539,13 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st
{ {
if (ref_time_map.empty() == false) if (ref_time_map.empty() == false)
{ {
std::ofstream ofs;
try 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); boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ref_time_map", ref_time_map); xml << boost::serialization::make_nvp("GNSS-SDR_ref_time_map", ref_time_map);
ofs.close();
LOG(INFO) << "Saved Ref Time data"; LOG(INFO) << "Saved Ref Time data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -543,6 +553,7 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st
LOG(WARNING) << e.what(); LOG(WARNING) << e.what();
return false; return false;
} }
ofs.close();
return true; return true;
} }
else else
@ -555,12 +566,12 @@ bool gnss_sdr_supl_client::save_ref_time_map_xml(const std::string file_name, st
bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name) bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name)
{ {
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
xml >> boost::serialization::make_nvp("GNSS-SDR_ref_location_map", this->gps_ref_loc); xml >> boost::serialization::make_nvp("GNSS-SDR_ref_location_map", this->gps_ref_loc);
ifs.close();
LOG(INFO) << "Loaded Ref Location data"; LOG(INFO) << "Loaded Ref Location data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -568,6 +579,7 @@ bool gnss_sdr_supl_client::load_ref_location_xml(const std::string file_name)
LOG(WARNING) << e.what() << "File: " << file_name; LOG(WARNING) << e.what() << "File: " << file_name;
return false; return false;
} }
ifs.close();
return true; return true;
} }
@ -576,12 +588,12 @@ bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name
{ {
if (ref_location_map.empty() == false) if (ref_location_map.empty() == false)
{ {
std::ofstream ofs;
try 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); boost::archive::xml_oarchive xml(ofs);
xml << boost::serialization::make_nvp("GNSS-SDR_ref_location_map", ref_location_map); xml << boost::serialization::make_nvp("GNSS-SDR_ref_location_map", ref_location_map);
ofs.close();
LOG(INFO) << "Saved Ref Location data"; LOG(INFO) << "Saved Ref Location data";
} }
catch (std::exception& e) catch (std::exception& e)
@ -589,6 +601,7 @@ bool gnss_sdr_supl_client::save_ref_location_map_xml(const std::string file_name
LOG(WARNING) << e.what(); LOG(WARNING) << e.what();
return false; return false;
} }
ofs.close();
return true; return true;
} }
else else

View File

@ -478,3 +478,4 @@
</second> </second>
</item> </item>
</GNSS-SDR_ephemeris_map> </GNSS-SDR_ephemeris_map>
</boost_serialization>

View File

@ -355,3 +355,4 @@
</second> </second>
</item> </item>
</GNSS-SDR_gnss_synchro_map> </GNSS-SDR_gnss_synchro_map>
</boost_serialization>

View File

@ -318,6 +318,8 @@ rtk_t configure_rtklib_options()
rtkinit(&rtk, &rtklib_configuration_options); rtkinit(&rtk, &rtklib_configuration_options);
return rtk; return rtk;
} }
//todo: add test cases for Galileo E1, E5 and GPS L5 //todo: add test cases for Galileo E1, E5 and GPS L5
TEST(RTKLibSolverTest, test1) TEST(RTKLibSolverTest, test1)
{ {
@ -371,20 +373,21 @@ TEST(RTKLibSolverTest, test1)
//load from xml (boost serialize) //load from xml (boost serialize)
std::string file_name = path + "data/rtklib_test/obs_test1.xml"; std::string file_name = path + "data/rtklib_test/obs_test1.xml";
std::ifstream ifs;
try 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); boost::archive::xml_iarchive xml(ifs);
gnss_synchro_map.clear(); gnss_synchro_map.clear();
xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_synchro_map); xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_synchro_map);
ifs.close();
std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl; std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl;
} }
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << e.what() << "File: " << file_name; std::cout << e.what() << "File: " << file_name;
} }
ifs.close();
// solve // solve
bool pvt_valid = false; bool pvt_valid = false;