mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-15 20:50:33 +00:00
Fix string comparisons, improve const correctness
This commit is contained in:
parent
cc58fbe30f
commit
f7df714a7f
@ -68,7 +68,7 @@ GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path)
|
||||
{
|
||||
geojson_base_path = p.string();
|
||||
}
|
||||
if (geojson_base_path.compare(".") != 0)
|
||||
if (geojson_base_path != ".")
|
||||
{
|
||||
std::cout << "GeoJSON files will be stored at " << geojson_base_path << std::endl;
|
||||
}
|
||||
@ -83,7 +83,7 @@ GeoJSON_Printer::~GeoJSON_Printer()
|
||||
}
|
||||
|
||||
|
||||
bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
bool GeoJSON_Printer::set_headers(const std::string& filename, bool time_tag_name)
|
||||
{
|
||||
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time();
|
||||
tm timeinfo = boost::posix_time::to_tm(pt);
|
||||
@ -140,7 +140,7 @@ bool GeoJSON_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
DLOG(INFO) << "GeoJSON printer writing on " << filename.c_str();
|
||||
|
||||
// Set iostream numeric format and precision
|
||||
geojson_file.setf(geojson_file.fixed, geojson_file.floatfield);
|
||||
geojson_file.setf(geojson_file.std::ofstream::fixed, geojson_file.std::ofstream::floatfield);
|
||||
geojson_file << std::setprecision(14);
|
||||
|
||||
// Writing the header
|
||||
@ -171,7 +171,7 @@ bool GeoJSON_Printer::print_position(const std::shared_ptr<Pvt_Solution>& positi
|
||||
double longitude;
|
||||
double height;
|
||||
|
||||
std::shared_ptr<Pvt_Solution> position_ = position;
|
||||
const std::shared_ptr<Pvt_Solution>& position_ = position;
|
||||
|
||||
if (print_average_values == false)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
public:
|
||||
GeoJSON_Printer(const std::string& base_path = ".");
|
||||
~GeoJSON_Printer();
|
||||
bool set_headers(std::string filename, bool time_tag_name = true);
|
||||
bool set_headers(const std::string& filename, bool time_tag_name = true);
|
||||
bool print_position(const std::shared_ptr<Pvt_Solution>& position, bool print_average_values);
|
||||
bool close_file();
|
||||
};
|
||||
|
@ -70,7 +70,7 @@ Gpx_Printer::Gpx_Printer(const std::string& base_path)
|
||||
{
|
||||
gpx_base_path = p.string();
|
||||
}
|
||||
if (gpx_base_path.compare(".") != 0)
|
||||
if (gpx_base_path != ".")
|
||||
{
|
||||
std::cout << "GPX files will be stored at " << gpx_base_path << std::endl;
|
||||
}
|
||||
@ -79,7 +79,7 @@ Gpx_Printer::Gpx_Printer(const std::string& base_path)
|
||||
}
|
||||
|
||||
|
||||
bool Gpx_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
bool Gpx_Printer::set_headers(const std::string& filename, bool time_tag_name)
|
||||
{
|
||||
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time();
|
||||
tm timeinfo = boost::posix_time::to_tm(pt);
|
||||
@ -134,7 +134,7 @@ bool Gpx_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
{
|
||||
DLOG(INFO) << "GPX printer writing on " << filename.c_str();
|
||||
// Set iostream numeric format and precision
|
||||
gpx_file.setf(gpx_file.fixed, gpx_file.floatfield);
|
||||
gpx_file.setf(gpx_file.std::ofstream::fixed, gpx_file.std::ofstream::floatfield);
|
||||
gpx_file << std::setprecision(14);
|
||||
gpx_file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
|
||||
<< "<gpx version=\"1.1\" creator=\"GNSS-SDR\"" << std::endl
|
||||
@ -164,7 +164,7 @@ bool Gpx_Printer::print_position(const std::shared_ptr<rtklib_solver>& position,
|
||||
double height;
|
||||
|
||||
positions_printed = true;
|
||||
std::shared_ptr<rtklib_solver> position_ = position;
|
||||
const std::shared_ptr<rtklib_solver>& position_ = position;
|
||||
|
||||
double speed_over_ground = position_->get_speed_over_ground(); // expressed in m/s
|
||||
double course_over_ground = position_->get_course_over_ground(); // expressed in deg
|
||||
|
@ -57,7 +57,7 @@ private:
|
||||
public:
|
||||
Gpx_Printer(const std::string& base_path = ".");
|
||||
~Gpx_Printer();
|
||||
bool set_headers(std::string filename, bool time_tag_name = true);
|
||||
bool set_headers(const std::string& filename, bool time_tag_name = true);
|
||||
bool print_position(const std::shared_ptr<rtklib_solver>& position, bool print_average_values);
|
||||
bool close_file();
|
||||
};
|
||||
|
@ -173,7 +173,7 @@ bool hybrid_ls_pvt::get_PVT(std::map<int, Gnss_Synchro> gnss_observables_map, do
|
||||
{
|
||||
// 1 GPS - find the ephemeris for the current GPS SV observation. The SV PRN ID is the map key
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
if (sig_.compare("1C") == 0)
|
||||
if (sig_ == "1C")
|
||||
{
|
||||
gps_ephemeris_iter = gps_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (gps_ephemeris_iter != gps_ephemeris_map.end())
|
||||
@ -228,7 +228,7 @@ bool hybrid_ls_pvt::get_PVT(std::map<int, Gnss_Synchro> gnss_observables_map, do
|
||||
DLOG(INFO) << "No ephemeris data for SV " << gnss_observables_iter->first;
|
||||
}
|
||||
}
|
||||
if (sig_.compare("2S") == 0)
|
||||
if (sig_ == "2S")
|
||||
{
|
||||
gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.end())
|
||||
|
@ -70,7 +70,7 @@ Kml_Printer::Kml_Printer(const std::string& base_path)
|
||||
{
|
||||
kml_base_path = p.string();
|
||||
}
|
||||
if (kml_base_path.compare(".") != 0)
|
||||
if (kml_base_path != ".")
|
||||
{
|
||||
std::cout << "KML files will be stored at " << kml_base_path << std::endl;
|
||||
}
|
||||
@ -87,7 +87,7 @@ Kml_Printer::Kml_Printer(const std::string& base_path)
|
||||
}
|
||||
|
||||
|
||||
bool Kml_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
bool Kml_Printer::set_headers(const std::string& filename, bool time_tag_name)
|
||||
{
|
||||
boost::posix_time::ptime pt = boost::posix_time::second_clock::local_time();
|
||||
tm timeinfo = boost::posix_time::to_tm(pt);
|
||||
@ -143,10 +143,10 @@ bool Kml_Printer::set_headers(std::string filename, bool time_tag_name)
|
||||
{
|
||||
DLOG(INFO) << "KML printer writing on " << filename.c_str();
|
||||
// Set iostream numeric format and precision
|
||||
kml_file.setf(kml_file.fixed, kml_file.floatfield);
|
||||
kml_file.setf(kml_file.std::ofstream::fixed, kml_file.std::ofstream::floatfield);
|
||||
kml_file << std::setprecision(14);
|
||||
|
||||
tmp_file.setf(tmp_file.fixed, tmp_file.floatfield);
|
||||
tmp_file.setf(tmp_file.std::ofstream::fixed, tmp_file.std::ofstream::floatfield);
|
||||
tmp_file << std::setprecision(14);
|
||||
|
||||
kml_file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl
|
||||
@ -222,7 +222,7 @@ bool Kml_Printer::print_position(const std::shared_ptr<rtklib_solver>& position,
|
||||
|
||||
positions_printed = true;
|
||||
|
||||
std::shared_ptr<rtklib_solver> position_ = position;
|
||||
const std::shared_ptr<rtklib_solver>& position_ = position;
|
||||
|
||||
double speed_over_ground = position_->get_speed_over_ground(); // expressed in m/s
|
||||
double course_over_ground = position_->get_course_over_ground(); // expressed in deg
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
public:
|
||||
Kml_Printer(const std::string& base_path = std::string("."));
|
||||
~Kml_Printer();
|
||||
bool set_headers(std::string filename, bool time_tag_name = true);
|
||||
bool set_headers(const std::string& filename, bool time_tag_name = true);
|
||||
bool print_position(const std::shared_ptr<rtklib_solver>& position, bool print_average_values);
|
||||
bool close_file();
|
||||
};
|
||||
|
@ -44,6 +44,7 @@ Ls_Pvt::Ls_Pvt() : Pvt_Solution()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
arma::vec Ls_Pvt::bancroftPos(const arma::mat& satpos, const arma::vec& obs)
|
||||
{
|
||||
// BANCROFT Calculation of preliminary coordinates for a GPS receiver based on pseudoranges
|
||||
@ -233,9 +234,9 @@ arma::vec Ls_Pvt::leastSquarePos(const arma::mat& satpos, const arma::vec& obs,
|
||||
Rot_X = Ls_Pvt::rotateSatellite(traveltime, X.col(i)); //armadillo
|
||||
|
||||
//--- Find DOA and range of satellites
|
||||
double* azim = 0;
|
||||
double* elev = 0;
|
||||
double* dist = 0;
|
||||
double* azim = nullptr;
|
||||
double* elev = nullptr;
|
||||
double* dist = nullptr;
|
||||
topocent(azim, elev, dist, pos.subvec(0, 2), Rot_X - pos.subvec(0, 2));
|
||||
|
||||
if (traveltime < 0.1 && nmbOfSatellites > 3)
|
||||
|
@ -48,7 +48,7 @@
|
||||
using google::LogMessage;
|
||||
|
||||
|
||||
Nmea_Printer::Nmea_Printer(std::string filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path)
|
||||
Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path)
|
||||
{
|
||||
nmea_base_path = base_path;
|
||||
d_flag_nmea_output_file = flag_nmea_output_file;
|
||||
@ -79,7 +79,7 @@ Nmea_Printer::Nmea_Printer(std::string filename, bool flag_nmea_output_file, boo
|
||||
nmea_base_path = p.string();
|
||||
}
|
||||
|
||||
if ((nmea_base_path.compare(".") != 0) and (d_flag_nmea_output_file == true))
|
||||
if ((nmea_base_path != ".") and (d_flag_nmea_output_file == true))
|
||||
{
|
||||
std::cout << "NMEA files will be stored at " << nmea_base_path << std::endl;
|
||||
}
|
||||
@ -99,7 +99,7 @@ Nmea_Printer::Nmea_Printer(std::string filename, bool flag_nmea_output_file, boo
|
||||
}
|
||||
}
|
||||
|
||||
nmea_devname = nmea_dump_devname;
|
||||
nmea_devname = std::move(nmea_dump_devname);
|
||||
if (flag_nmea_tty_port == true)
|
||||
{
|
||||
nmea_dev_descriptor = init_serial(nmea_devname.c_str());
|
||||
@ -126,20 +126,20 @@ Nmea_Printer::~Nmea_Printer()
|
||||
}
|
||||
|
||||
|
||||
int Nmea_Printer::init_serial(std::string serial_device)
|
||||
int Nmea_Printer::init_serial(const std::string& serial_device)
|
||||
{
|
||||
/*!
|
||||
* Opens the serial device and sets the default baud rate for a NMEA transmission (9600,8,N,1)
|
||||
*/
|
||||
int fd = 0;
|
||||
struct termios options;
|
||||
struct termios options = {};
|
||||
int64_t BAUD;
|
||||
int64_t DATABITS;
|
||||
int64_t STOPBITS;
|
||||
int64_t PARITYON;
|
||||
int64_t PARITY;
|
||||
|
||||
fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC);
|
||||
if (fd == -1) return fd; // failed to open TTY port
|
||||
|
||||
if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O
|
||||
|
@ -53,12 +53,12 @@ public:
|
||||
/*!
|
||||
* \brief Default constructor.
|
||||
*/
|
||||
Nmea_Printer(std::string filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_filename, const std::string& base_path = ".");
|
||||
Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path = ".");
|
||||
|
||||
/*!
|
||||
* \brief Print NMEA PVT and satellite info to the initialized device
|
||||
*/
|
||||
bool Print_Nmea_Line(const std::shared_ptr<rtklib_solver>& position, bool print_average_values);
|
||||
bool Print_Nmea_Line(const std::shared_ptr<rtklib_solver>& pvt_data, bool print_average_values);
|
||||
|
||||
/*!
|
||||
* \brief Default destructor.
|
||||
@ -72,7 +72,7 @@ private:
|
||||
std::string nmea_devname;
|
||||
int nmea_dev_descriptor; // NMEA serial device descriptor (i.e. COM port)
|
||||
std::shared_ptr<rtklib_solver> d_PVT_data;
|
||||
int init_serial(std::string serial_device); //serial port control
|
||||
int init_serial(const std::string& serial_device); //serial port control
|
||||
void close_serial();
|
||||
std::string get_GPGGA(); // fix data
|
||||
std::string get_GPGSV(); // satellite data
|
||||
|
@ -188,7 +188,7 @@ int Pvt_Solution::tropo(double *ddr_m, double sinel, double hsta_km, double p_mb
|
||||
double b;
|
||||
double rtop;
|
||||
|
||||
while (1)
|
||||
while (true)
|
||||
{
|
||||
rtop = pow((a_e + htop), 2) - pow((a_e + hsta_km), 2) * (1 - pow(sinel, 2));
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@ Rtcm_Printer::Rtcm_Printer(std::string filename, bool flag_rtcm_file_dump, bool
|
||||
{
|
||||
rtcm_base_path = p.string();
|
||||
}
|
||||
if (rtcm_base_path.compare(".") != 0)
|
||||
if (rtcm_base_path != ".")
|
||||
{
|
||||
std::cout << "RTCM binary file will be stored at " << rtcm_base_path << std::endl;
|
||||
}
|
||||
|
@ -473,11 +473,11 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
case 'G':
|
||||
{
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
if (sig_.compare("1C") == 0)
|
||||
if (sig_ == "1C")
|
||||
{
|
||||
band1 = true;
|
||||
}
|
||||
if (sig_.compare("2S") == 0)
|
||||
if (sig_ == "2S")
|
||||
{
|
||||
band2 = true;
|
||||
}
|
||||
@ -500,7 +500,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
{
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
// Galileo E1
|
||||
if (sig_.compare("1B") == 0)
|
||||
if (sig_ == "1B")
|
||||
{
|
||||
// 1 Gal - find the ephemeris for the current GALILEO SV observation. The SV PRN ID is the map key
|
||||
galileo_ephemeris_iter = galileo_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
@ -523,7 +523,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
}
|
||||
|
||||
// Galileo E5
|
||||
if (sig_.compare("5X") == 0)
|
||||
if (sig_ == "5X")
|
||||
{
|
||||
// 1 Gal - find the ephemeris for the current GALILEO SV observation. The SV PRN ID is the map key
|
||||
galileo_ephemeris_iter = galileo_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
@ -571,7 +571,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
// GPS L1
|
||||
// 1 GPS - find the ephemeris for the current GPS SV observation. The SV PRN ID is the map key
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
if (sig_.compare("1C") == 0)
|
||||
if (sig_ == "1C")
|
||||
{
|
||||
gps_ephemeris_iter = gps_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (gps_ephemeris_iter != gps_ephemeris_map.cend())
|
||||
@ -592,7 +592,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
}
|
||||
}
|
||||
// GPS L2 (todo: solve NAV/CNAV clash)
|
||||
if ((sig_.compare("2S") == 0) and (gps_dual_band == false))
|
||||
if ((sig_ == "2S") and (gps_dual_band == false))
|
||||
{
|
||||
gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.cend())
|
||||
@ -641,7 +641,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
}
|
||||
}
|
||||
// GPS L5
|
||||
if (sig_.compare("L5") == 0)
|
||||
if (sig_ == "L5")
|
||||
{
|
||||
gps_cnav_ephemeris_iter = gps_cnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
if (gps_cnav_ephemeris_iter != gps_cnav_ephemeris_map.cend())
|
||||
@ -693,7 +693,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
{
|
||||
std::string sig_(gnss_observables_iter->second.Signal);
|
||||
// GLONASS GNAV L1
|
||||
if (sig_.compare("1G") == 0)
|
||||
if (sig_ == "1G")
|
||||
{
|
||||
// 1 Glo - find the ephemeris for the current GLONASS SV observation. The SV Slot Number (PRN ID) is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
@ -715,7 +715,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
|
||||
}
|
||||
}
|
||||
// GLONASS GNAV L2
|
||||
if (sig_.compare("2G") == 0)
|
||||
if (sig_ == "2G")
|
||||
{
|
||||
// 1 GLONASS - find the ephemeris for the current GLONASS SV observation. The SV PRN ID is the map key
|
||||
glonass_gnav_ephemeris_iter = glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN);
|
||||
|
Loading…
Reference in New Issue
Block a user