1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-15 11:45:47 +00:00

Add ability to read compressed .Z RINEX navigation files

This commit is contained in:
Carles Fernandez 2018-11-25 20:52:52 +01:00
parent 88e91e6912
commit 1f514f156c
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -45,6 +45,7 @@
#include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp> #include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp> #include <boost/iostreams/filter/gzip.hpp>
#include <cstdlib>
#include <iostream> #include <iostream>
@ -81,6 +82,11 @@ int main(int argc, char** argv)
if ((rinex_filename.substr(found + 1, found + 3).compare("gz") == 0)) if ((rinex_filename.substr(found + 1, found + 3).compare("gz") == 0))
{ {
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary); std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
if (file.fail())
{
std::cerr << "Could not open file " << rinex_filename << std::endl;
return 1;
}
boost::iostreams::filtering_streambuf<boost::iostreams::input> in; boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
try try
{ {
@ -97,6 +103,24 @@ int main(int argc, char** argv)
boost::iostreams::copy(in, output_file); boost::iostreams::copy(in, output_file);
rinex_filename = rinex_filename_unzipped; rinex_filename = rinex_filename_unzipped;
} }
if ((rinex_filename.substr(found + 1, found + 2).compare("Z") == 0))
{
std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary);
if (file.fail())
{
std::cerr << "Could not open file" << rinex_filename << std::endl;
return 1;
}
file.close();
// 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");
std::system(argum.c_str());
std::string argum2 = std::string("/usr/bin/uncompress -f " + rinex_filename);
std::system(argum2.c_str());
std::string argum3 = std::string("/bin/mv " + rinex_filename + +".aux" + " " + rinex_filename);
std::system(argum3.c_str());
rinex_filename = rinex_filename.substr(0, found);
}
} }
std::map<int, Gps_Ephemeris> eph_map; std::map<int, Gps_Ephemeris> eph_map;