WSL/SLF GitLab Repository

Commit ea38ac95 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

Minor cleanup for clarity and consistency before deeper work...

parent bff04b07
......@@ -40,9 +40,9 @@ Meteo1DInterpolator::Meteo1DInterpolator(const Config& in_cfg)
//read the Config object to create the resampling algorithms for each
//MeteoData::Parameters parameter (i.e. each member variable like ta, p, psum, ...)
for (size_t ii=0; ii<MeteoData::nrOfParameters; ii++){ //loop over all MeteoData member variables
const std::string parname = MeteoData::getParameterName(ii); //Current parameter name
const std::string parname( MeteoData::getParameterName(ii) ); //Current parameter name
std::vector<std::string> vecArgs;
const std::string algo_name = getInterpolationForParameter(parname, vecArgs);
const std::string algo_name( getInterpolationForParameter(parname, vecArgs) );
mapAlgorithms[parname] = ResamplingAlgorithmsFactory::getAlgorithm(algo_name, parname, window_size, vecArgs);
}
}
......@@ -87,7 +87,7 @@ bool Meteo1DInterpolator::resampleData(const Date& date, const std::vector<Meteo
isResampled = false;
}
md = vecM[index]; //create a clone of the found element
if (!enable_resampling) {
if (isResampled==false) return true; //the element was found at the right time
else { //not found or wrong time: return a nodata element
......@@ -103,13 +103,13 @@ bool Meteo1DInterpolator::resampleData(const Date& date, const std::vector<Meteo
//now, perform the resampling
for (size_t ii=0; ii<md.getNrOfParameters(); ii++) {
const std::string parname = md.getNameForParameter(ii); //Current parameter name
const std::string parname( md.getNameForParameter(ii) ); //Current parameter name
const std::map< std::string, ResamplingAlgorithms* >::const_iterator it = mapAlgorithms.find(parname);
if (it!=mapAlgorithms.end()) {
it->second->resample(index, elementpos, ii, vecM, md);
} else { //we are dealing with an extra parameter, we need to add it to the map first, so it will exist next time...
std::vector<std::string> vecArgs;
const std::string algo_name = getInterpolationForParameter(parname, vecArgs);
const std::string algo_name( getInterpolationForParameter(parname, vecArgs) );
mapAlgorithms[parname] = ResamplingAlgorithmsFactory::getAlgorithm(algo_name, parname, window_size, vecArgs);;
mapAlgorithms[parname]->resample(index, elementpos, ii, vecM, md);
}
......@@ -117,10 +117,10 @@ bool Meteo1DInterpolator::resampleData(const Date& date, const std::vector<Meteo
#ifdef DATA_QA
const std::map< std::string, ResamplingAlgorithms* >::const_iterator it2 = mapAlgorithms.find(parname); //we have to re-find it in order to handle extra parameters
if ((index != IOUtils::npos) && vecM[index](ii)!=md(ii)) {
const std::string statName = md.meta.getStationName();
const std::string statID = md.meta.getStationID();
const std::string statName( md.meta.getStationName() );
const std::string statID( md.meta.getStationID() );
const std::string stat = (!statID.empty())? statID : statName;
const std::string algo_name = it2->second->getAlgo();
const std::string algo_name( it2->second->getAlgo() );
cout << "[DATA_QA] Resampling " << stat << "::" << parname << "::" << algo_name << " " << md.date.toString(Date::ISO_TZ) << " [" << md.date.toString(Date::ISO_WEEK) << "]\n";
}
#endif
......@@ -138,9 +138,8 @@ bool Meteo1DInterpolator::resampleData(const Date& date, const std::vector<Meteo
*/
string Meteo1DInterpolator::getInterpolationForParameter(const std::string& parname, std::vector<std::string>& vecArguments) const
{
string algo_name = "linear"; //the default resampling is linear
std::string algo_name( "linear" ); //the default resampling is linear
cfg.getValue(parname+"::resample", "Interpolations1D", algo_name, IOUtils::nothrow);
cfg.getValue(parname+"::"+algo_name, "Interpolations1D", vecArguments, IOUtils::nothrow);
if (cfg.keyExists(parname+"::"+"args", "Interpolations1D")) //HACK: temporary until we consider everybody has migrated
......
......@@ -106,7 +106,7 @@ Meteo2DInterpolator::~Meteo2DInterpolator()
{
std::map<std::string, std::vector<InterpolationAlgorithm*> >::iterator iter;
for (iter = mapAlgorithms.begin(); iter != mapAlgorithms.end(); ++iter) {
const vector<InterpolationAlgorithm*>& vecAlgs = iter->second;
const vector<InterpolationAlgorithm*>& vecAlgs( iter->second );
for (size_t ii=0; ii<vecAlgs.size(); ++ii)
delete vecAlgs[ii];
}
......@@ -122,8 +122,8 @@ void Meteo2DInterpolator::setAlgorithms()
std::set<std::string> set_of_used_parameters;
get_parameters(cfg, set_of_used_parameters);
std::set<std::string>::const_iterator it;
for (it = set_of_used_parameters.begin(); it != set_of_used_parameters.end(); ++it) {
std::set<std::string>::const_iterator it = set_of_used_parameters.begin();
for (; it != set_of_used_parameters.end(); ++it) {
const std::string parname( *it );
std::vector<std::string> tmpAlgorithms;
const size_t nrOfAlgorithms = getAlgorithmsForParameter(cfg, parname, tmpAlgorithms);
......@@ -186,7 +186,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
throw IOException("No interpolation algorithms configured for parameter "+param_name, AT);
//look for algorithm with the highest quality rating
const vector<InterpolationAlgorithm*>& vecAlgs = it->second;
const vector<InterpolationAlgorithm*>& vecAlgs( it->second );
double maxQualityRating = -1.;
size_t bestalgorithm = 0;
for (size_t ii=0; ii < vecAlgs.size(); ++ii){
......@@ -224,7 +224,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
const std::vector<Coords>& in_coords, std::vector<double>& result, std::string& info_string)
{
result.clear();
std::vector<Coords> vec_coords(in_coords);
std::vector<Coords> vec_coords( in_coords );
if (use_full_dem) {
Grid2DObject result_grid;
......
Markdown is supported
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