WSL/SLF GitLab Repository

Commit 9a2d7aef authored by Mathias Bavay's avatar Mathias Bavay
Browse files

removing an obsolete method, code cleanup and removing the unecessary IOInterface.cc

parent f3326a77
......@@ -27,24 +27,23 @@ ENDIF(DATA_QA)
SET(meteoio_sources
${dataClasses_sources}
Timer.cc
Config.cc
IOExceptions.cc
IOUtils.cc
FileUtils.cc
Graphics.cc
IOManager.cc
IOHandler.cc
BufferedIOHandler.cc
MeteoProcessor.cc
ResamplingAlgorithms.cc
ResamplingAlgorithms2D.cc
Meteo1DInterpolator.cc
InterpolationAlgorithms.cc
Meteo1DInterpolator.cc
Meteo2DInterpolator.cc
DataGenerator.cc
GeneratorAlgorithms.cc
Timer.cc
IOHandler.cc
Graphics.cc
Meteo2DInterpolator.cc
BufferedIOHandler.cc
IOInterface.cc
Config.cc
IOExceptions.cc
IOUtils.cc
FileUtils.cc
plugins/libsmet.cc
${plugins_sources}
${meteoLaws_sources}
......
......@@ -187,6 +187,21 @@ IOInterface* IOHandler::getPlugin(const std::string& plugin_name) const
return NULL; //no plugin found
}
//this is actually an object factory
IOInterface* IOHandler::getPlugin(const std::string& cfgkey, const std::string& cfgsection)
{
std::string op_src;
cfg.getValue(cfgkey, cfgsection, op_src);
if (mapPlugins.find(op_src) == mapPlugins.end()) {
mapPlugins[op_src] = getPlugin(op_src);
if (mapPlugins[op_src]==NULL)
throw IOException("Cannot find plugin " + op_src + " as requested in file " + cfg.getSourceName() + ". Has it been activated through ccmake? Is it declared in IOHandler::getPlugin?", AT);
}
return mapPlugins[op_src];
}
//Copy constructor
IOHandler::IOHandler(const IOHandler& aio)
: IOInterface(), cfg(aio.cfg), mapPlugins(aio.mapPlugins), copy_parameter(aio.copy_parameter),
......@@ -218,20 +233,6 @@ IOHandler& IOHandler::operator=(const IOHandler& source) {
return *this;
}
IOInterface* IOHandler::getPlugin(const std::string& cfgkey, const std::string& cfgsection)
{
std::string op_src;
cfg.getValue(cfgkey, cfgsection, op_src);
if (mapPlugins.find(op_src) == mapPlugins.end()) {
mapPlugins[op_src] = getPlugin(op_src);
if (mapPlugins[op_src]==NULL)
throw IOException("Cannot find plugin " + op_src + " as requested in file " + cfg.getSourceName() + ". Has it been activated through ccmake? Is it registered in IOHandler::registerPlugins?", AT);
}
return mapPlugins[op_src];
}
void IOHandler::read2DGrid(Grid2DObject& grid_out, const std::string& i_filename)
{
IOInterface *plugin = getPlugin("GRID2D", "Input");
......@@ -263,38 +264,6 @@ void IOHandler::readStationData(const Date& date, STATIONS_SET& vecStation)
plugin->readStationData(date, vecStation);
}
void IOHandler::readMeteoData(const Date& date, METEO_SET& vecMeteo)
{
std::vector< std::vector<MeteoData> > meteoTmpBuffer;
readMeteoData(date, date, meteoTmpBuffer);
vecMeteo.clear();
vecMeteo.reserve( meteoTmpBuffer.size() );
for (size_t ii=0; ii<meteoTmpBuffer.size(); ++ii) {//stations
if (!meteoTmpBuffer[ii].empty())
vecMeteo.push_back( meteoTmpBuffer[ii].front() );
}
}
void IOHandler::checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo) const
{
for (size_t stat_idx=0; stat_idx<vecVecMeteo.size(); ++stat_idx) { //for each station
const size_t nr_timestamps = vecVecMeteo[stat_idx].size();
if (nr_timestamps==0) continue;
Date previous_date( vecVecMeteo[stat_idx].front().date );
for (size_t ii=1; ii<nr_timestamps; ++ii) {
const Date& current_date = vecVecMeteo[stat_idx][ii].date;
if (current_date<=previous_date) {
const StationData& station = vecVecMeteo[stat_idx][ii].meta;
throw IOException("Error at time "+current_date.toString(Date::ISO)+" for station \""+station.stationName+"\" ("+station.stationID+") : timestamps must be in increasing order and unique!", AT);
}
previous_date = current_date;
}
}
}
void IOHandler::readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_SET>& vecMeteo,
const size_t& stationindex)
......@@ -336,12 +305,33 @@ void IOHandler::write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Param
plugin->write2DGrid(grid_in, parameter, date);
}
/**
* Make sure all timestamps are unique and in increasing order
*/
void IOHandler::checkTimestamps(const std::vector<METEO_SET>& vecVecMeteo) const
{
for (size_t stat_idx=0; stat_idx<vecVecMeteo.size(); ++stat_idx) { //for each station
const size_t nr_timestamps = vecVecMeteo[stat_idx].size();
if (nr_timestamps==0) continue;
Date previous_date( vecVecMeteo[stat_idx].front().date );
for (size_t ii=1; ii<nr_timestamps; ++ii) {
const Date& current_date = vecVecMeteo[stat_idx][ii].date;
if (current_date<=previous_date) {
const StationData& station = vecVecMeteo[stat_idx][ii].meta;
throw IOException("Error at time "+current_date.toString(Date::ISO)+" for station \""+station.stationName+"\" ("+station.stationID+") : timestamps must be in increasing order and unique!", AT);
}
previous_date = current_date;
}
}
}
/**
* Parse [Input] section for potential parameters that the user wants
* duplicated (as '%%::COPY = %%')
*/
void IOHandler::parse_copy_config()
{
/**
* Parse [Input] section for potential parameters that the user wants
* duplicated (as '%%::COPY = %%')
*/
vector<string> copy_keys;
const size_t nrOfMatches = cfg.findKeys(copy_keys, "::COPY", "Input", true); //search anywhere in key
......
......@@ -54,7 +54,6 @@ class IOHandler : public IOInterface {
virtual void readMeteoData(const Date& dateStart, const Date& dateEnd,
std::vector<METEO_SET>& vecMeteo,
const size_t& stationindex=IOUtils::npos);
void readMeteoData(const Date& date, METEO_SET& vecMeteo);
virtual void readAssimilationData(const Date&, Grid2DObject& da_out);
virtual void readPOI(std::vector<Coords>& pts);
......
/***********************************************************************************/
/* Copyright 2009 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
/***********************************************************************************/
/* This file is part of MeteoIO.
MeteoIO is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MeteoIO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/IOInterface.h>
namespace mio {
IOInterface::~IOInterface(){}
} //namespace
......@@ -89,7 +89,7 @@ namespace mio {
*/
class IOInterface {
public:
virtual ~IOInterface();
virtual ~IOInterface() {};
/**
* @brief A generic function for parsing 2D grids into a Grid2DObject. The string parameter shall be used for addressing the
......
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