From 7008e601a93b4faf7afdda2d9ba65861932bde0d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 25 Nov 2018 12:29:56 +0100 Subject: [PATCH] Add ability to read compressed RINEX navigation files --- src/utils/rinex2assist/CMakeLists.txt | 2 ++ src/utils/rinex2assist/README.md | 28 ++++++++++++++++++----- src/utils/rinex2assist/main.cc | 32 ++++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/utils/rinex2assist/CMakeLists.txt b/src/utils/rinex2assist/CMakeLists.txt index f99b52421..c87b1cd69 100644 --- a/src/utils/rinex2assist/CMakeLists.txt +++ b/src/utils/rinex2assist/CMakeLists.txt @@ -26,6 +26,8 @@ endif() set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${GPSTK_INCLUDE_DIR}/gpstk) +find_package(Boost COMPONENTS iostreams serialization REQUIRED) + include_directories( ${CMAKE_SOURCE_DIR}/src/core/system_parameters ${GFlags_INCLUDE_DIRS} diff --git a/src/utils/rinex2assist/README.md b/src/utils/rinex2assist/README.md index bc3246374..147c3a17f 100644 --- a/src/utils/rinex2assist/README.md +++ b/src/utils/rinex2assist/README.md @@ -1,7 +1,7 @@ Rinex2assist ------------ -This program generates ephemeris XML files from RINEX navigation data files. The usage is as follows: +This program reads data from RINEX navigation files and generates XML files that can be read by GNSS-SDR as Assisted GNSS data. The usage is as follows: ``` $ rinex2assist /path/to/RINEX_nav_file @@ -9,16 +9,34 @@ $ rinex2assist /path/to/RINEX_nav_file The argument is mandatory (the name of the RINEX navigation file). The name `gps_ephemeris.xml` is given to the output if GPS NAV data is fould. If the RINEX file contains Galileo data, the corresponding `gal_ephemeris.xml` file will be generated. The program is also able to extract parameters of the UTC and the Ionospheric models from the RINEX header, if available. They will be called `gps_utc_model.xml`, `gps_iono.xml`, `gal_utc_model.xml` and `gal_iono.xml`. - -The program accepts either versions 2.xx or 3.xx for the RINEX navigation data file. - There are some servers available for downloading RINEX navigation files. For instance: * NASA: [ftp://cddis.gsfc.nasa.gov/pub/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/) * ESA: [ftp://gssc.esa.int/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/) Just make sure to pick up a [station near you](http://gpspp.sakura.ne.jp/gmap/igsnet.htm). -An example of GNSS-SDR configuration using ephemeris and UTC and ionospheric model parameters for GPS L1 and Galileo signals is shown below: +The program accepts either versions 2.xx or 3.xx for the RINEX navigation data file, as well as compressed files (ending in `.gz`). + +Examples: + +``` +$ rinex2assist EBRE00ESP_R_20183290400_01H_GN.rnx.gz +Generated file: gps_ephemeris.xml +Generated file: gps_utc_model.xml +Generated file: gps_iono.xml +``` + +and + +``` +$ rinex2assist EBRE00ESP_R_20183290000_01H_EN.rnx.gz +Generated file: gal_ephemeris.xml +Generated file: gal_utc_model.xml +Generated file: gal_iono.xml +``` + + +An example of GNSS-SDR configuration using ephemeris, UTC and ionospheric model parameters for GPS L1 and Galileo signals is shown below: ``` GNSS-SDR.AGNSS_XML_enabled=true diff --git a/src/utils/rinex2assist/main.cc b/src/utils/rinex2assist/main.cc index 58cc48c0b..d09a1f933 100644 --- a/src/utils/rinex2assist/main.cc +++ b/src/utils/rinex2assist/main.cc @@ -42,6 +42,9 @@ #include #include #include +#include +#include +#include #include @@ -70,6 +73,33 @@ int main(int argc, char** argv) } std::string xml_filename; + // Uncompress if RINEX file is gzipped + std::string rinex_filename(argv[1]); + std::size_t found = rinex_filename.find_last_of("."); + if (found != std::string::npos) + { + if ((rinex_filename.substr(found + 1, found + 3).compare("gz") == 0)) + { + std::cerr << "Hello" << std::endl; + std::ifstream file(rinex_filename, std::ios_base::in | std::ios_base::binary); + boost::iostreams::filtering_streambuf in; + try + { + in.push(boost::iostreams::gzip_decompressor()); + } + catch (const boost::exception& e) + { + std::cerr << "Could not decompress file " << rinex_filename << std::endl; + 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); + boost::iostreams::copy(in, output_file); + rinex_filename = rinex_filename_unzipped; + } + } + std::map eph_map; std::map eph_gal_map; @@ -83,7 +113,7 @@ int main(int argc, char** argv) try { // Read nav file - gpstk::Rinex3NavStream rnffs(argv[1]); // Open navigation data file + gpstk::Rinex3NavStream rnffs(rinex_filename.c_str()); // Open navigation data file gpstk::Rinex3NavData rne; gpstk::Rinex3NavHeader hdr;