WSL/SLF GitLab Repository

Commit 1d25491e authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Re-definition of the == operator for MeteoData, some code clean up in IOUtils and StationData

parent 8e49698d
......@@ -163,10 +163,10 @@ void IOUtils::trim(std::string& str)
const size_t endpos = str.find_last_not_of(whitespaces); // Find the first character position from reverse af
// if all spaces or empty return an empty string
if(( std::string::npos == startpos ) || ( std::string::npos == endpos)) {
str = "";
} else {
if(startpos!=std::string::npos && endpos!=std::string::npos) {
str = str.substr( startpos, endpos-startpos+1 );
} else {
str = "";
}
}
......
......@@ -71,6 +71,7 @@ const std::string& MeteoGrids::getParameterName(const size_t& parindex)
/************************************************************
* static section *
************************************************************/
const double MeteoData::epsilon = 1e-6;
const size_t MeteoData::nrOfParameters = MeteoData::lastparam - MeteoData::firstparam + 1;
map<size_t, string> MeteoData::static_meteoparamname;
std::vector<std::string> MeteoData::s_default_paramname;
......@@ -217,7 +218,6 @@ bool MeteoData::operator==(const MeteoData& in) const
return false;
for (size_t ii=0; ii<nrOfAllParameters; ii++) {
const double epsilon = (fabs(data[ii]) < fabs(in.data[ii]) ? fabs(in.data[ii]) : fabs(data[ii])) * std::numeric_limits<double>::epsilon();
if( !IOUtils::checkEpsilonEquality(data[ii], in.data[ii], epsilon) )
return false;
}
......
......@@ -183,6 +183,7 @@ class MeteoData {
static std::vector<std::string> s_default_paramname;
static const bool __init; ///<helper variable to enable the init of static collection data
static bool initStaticData();///<initialize the static map meteoparamname
static double epsilon; ///<for comparing fields
//private data members, please keep the order consistent with declaration lists and logic!
bool resampled; ///<set this to true if MeteoData is result of resampling
......
......@@ -58,8 +58,10 @@ void StationData::setSlope(const double& in_slope_angle, const double& in_azimut
//Comparison operator
bool StationData::operator==(const StationData& in) const {
return ( (position == in.position) && (stationID == in.stationID) &&
(slope==in.slope) && (azi==in.azi) );// && (stationName == in.stationName));
return ( (position == in.position) &&
(stationID == in.stationID) &&
(slope==in.slope) &&
(azi==in.azi) );// && (stationName == in.stationName));
}
bool StationData::operator!=(const StationData& in) const {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment