WSL/SLF GitLab Repository

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

Several bugs have been found in the FULL_MERGE merging strategy. Merging...

Several bugs have been found in the FULL_MERGE merging strategy. Merging half-hourly data into a vector of 3 hours data was not working at all, now it should work!
parent c674e740
......@@ -295,8 +295,8 @@ size_t Config::findKeys(std::vector<std::string>& vecResult, const std::string&
//Loop through keys, look for match - push it into vecResult
if (anywhere) {
const string key_pattern = IOUtils::strToUpper(keymatch);
const string section_pattern = IOUtils::strToUpper(section);
const string key_pattern( IOUtils::strToUpper(keymatch) );
const string section_pattern( IOUtils::strToUpper(section) );
for (map<string,string>::const_iterator it=properties.begin(); it != properties.end(); ++it) {
const size_t found_section = (it->first).find(section_pattern, 0);
......@@ -304,17 +304,17 @@ size_t Config::findKeys(std::vector<std::string>& vecResult, const std::string&
const size_t found_pos = (it->first).find(key_pattern, section_len);
if (found_pos!=string::npos) { //found it!
const string key = (it->first).substr(section_len + 2); //from pos to the end
const string key( (it->first).substr(section_len + 2) ); //from pos to the end
vecResult.push_back(key);
}
}
} else {
const string key_pattern = IOUtils::strToUpper(section) + "::" + IOUtils::strToUpper(keymatch);
const string key_pattern( IOUtils::strToUpper(section) + "::" + IOUtils::strToUpper(keymatch) );
for (map<string,string>::const_iterator it=properties.begin(); it != properties.end(); ++it) {
const size_t found_pos = (it->first).find(key_pattern, 0);
if (found_pos==0) { //found it!
const string key = (it->first).substr(section_len + 2); //from pos to the end
const string key( (it->first).substr(section_len + 2) ); //from pos to the end
vecResult.push_back(key);
}
}
......
......@@ -553,11 +553,11 @@ void IOHandler::merge_stations(STATIONS_SET& vecStation) const
if (merge_commands.empty()) return;
for (size_t ii=0; ii<vecStation.size(); ii++) {
const string toStationID( IOUtils::strToUpper( vecStation[ii].stationID ) );
const std::string toStationID( IOUtils::strToUpper( vecStation[ii].stationID ) );
//we do not support "chain merge": station A merging station B and station C merging station A
if ( std::find(merged_stations.begin(), merged_stations.end(), toStationID)!=merged_stations.end() ) continue;
const map< string, vector<string> >::const_iterator it = merge_commands.find( toStationID );
const std::map< string, vector<string> >::const_iterator it = merge_commands.find( toStationID );
if (it == merge_commands.end()) continue; //no merge commands for this station
const std::vector<std::string> &merge_from( it->second );
......
......@@ -363,7 +363,7 @@ void MeteoData::mergeTimeSeries(std::vector<MeteoData>& vec1, const std::vector<
if (!vec1.empty()) {
const size_t nrExtra2 = vec2.back().nrOfAllParameters - nrOfParameters;
for (size_t pp=0; pp<nrExtra2; pp++) {
const std::string extra_name = vec2.back().extra_param_name[pp];
const std::string extra_name( vec2.back().extra_param_name[pp] );
if (vec1.back().getParameterIndex(extra_name)==IOUtils::npos) {
for (size_t ii=0; ii<vec1.size(); ii++) vec1[ii].addParameter( extra_name );
}
......@@ -409,25 +409,29 @@ void MeteoData::mergeTimeSeries(std::vector<MeteoData>& vec1, const std::vector<
size_t last_v1 = vec1_start; //last element from vec1 that will have to be invalidated
for(size_t ii=vec1_start; ii<vec1.size(); ii++) {
const Date curr_date( vec1[ii].date );
while ((curr_date>vec2[idx2].date) && (idx2<vec2.size())) {
while ((idx2<vec2.size()) && (curr_date>vec2[idx2].date)) {
tmp.push_back( md_pattern );
tmp.front().date = vec2[idx2].date;
tmp.front().merge( vec2[idx2] ); //so the extra params are properly handled
tmp.back().date = vec2[idx2].date;
tmp.back().merge( vec2[idx2] ); //so the extra params are properly handled
idx2++;
}
if (idx2==vec2.size()) return;//nothing left to merge
if (idx2==vec2.size()) break; //nothing left to merge
if (curr_date==vec2[idx2].date) vec1[ii].merge( vec2[idx2] );
if (curr_date==vec2[idx2].date) {
vec1[ii].merge( vec2[idx2] );
idx2++;
}
tmp.push_back( vec1[ii] );
last_v1 = ii;
}
const size_t new_count = last_v1 - vec1_start;
const size_t new_count = last_v1 - vec1_start + 1;
if (new_count<tmp.size())
vec1.insert( vec1.begin() + vec1_start, tmp.size()-new_count, tmp.front()); //so room for the extra params is allocated
for(size_t ii=0; ii<tmp.size(); ii++)
vec1[vec1_start+ii] = tmp[ii];
vec1_end = idx2;
} else {
size_t idx2 = vec1_start;
......
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