WSL/SLF GitLab Repository

Commit 633ff3ac authored by Mathias Bavay's avatar Mathias Bavay
Browse files

the USER interpolation method should now work as expected. A new method...

the USER interpolation method should now work as expected. A new method "getParameterIndex()" has been written for MeteoGrids for a future use.
parent a6a170da
......@@ -933,19 +933,12 @@ void WinstralAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
std::string USERInterpolation::getGridFileName() const
{
//HACK: use read2DGrid(grid, MeteoGrid::Parameters, Date) instead?
//HACK: use read2DGrid(grid, MeteoGrid::Parameters, Date) instead?
if (vecArgs.size() != 1){
throw InvalidArgumentException("Please provide the path to the grids for the "+algo+" interpolation algorithm", AT);
}
const std::string ext(".asc");
std::string gridname = vecArgs[0] + "/";
if (!vecMeteo.empty()) {
const Date& timestep = vecMeteo.at(0).date;
gridname = gridname + timestep.toString(Date::NUM) + "_" + MeteoData::getParameterName(param) + ext;
} else {
gridname = gridname + "Default" + "_" + MeteoData::getParameterName(param) + ext;
}
const std::string gridname = vecArgs[0] + "/" + date.toString(Date::NUM) + "_" + MeteoData::getParameterName(param) + ext;
return gridname;
}
......@@ -969,6 +962,8 @@ double USERInterpolation::getQualityRating(const Date& i_date, const MeteoData::
void USERInterpolation::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear();
info.str(filename);
gridsmanager.read2DGrid(grid, filename);
if(!grid.isSameGeolocalization(dem)) {
throw InvalidArgumentException("[E] trying to load a grid(" + filename + ") that has not the same georeferencing as the DEM!", AT);
......
......@@ -78,6 +78,16 @@ const std::string& MeteoGrids::getParameterName(const size_t& parindex)
return paramname[parindex];
}
size_t MeteoGrids::getParameterIndex(const std::string& parname)
{
for (size_t ii=0; ii<MeteoGrids::nrOfParameters; ii++) {
if (paramname[ii] == parname)
return ii;
}
return IOUtils::npos; //parameter not a part of MeteoGrids
}
/************************************************************
* static section *
************************************************************/
......@@ -139,7 +149,7 @@ const std::string& MeteoData::getParameterName(const size_t& parindex)
const std::string& MeteoData::getNameForParameter(const size_t& parindex) const
{
if (parindex >= nrOfAllParameters)
if (parindex >= MeteoData::nrOfAllParameters)
throw IndexOutOfBoundsException("Trying to get name for parameter that does not exist", AT);
return param_name[parindex];
......@@ -205,7 +215,7 @@ void MeteoData::reset()
* The plugin-specific nodata values are replaced by MeteoIO's internal nodata value
*/
void MeteoData::standardizeNodata(const double& plugin_nodata) {
for (size_t ii=0; ii<nrOfAllParameters; ii++) {
for (size_t ii=0; ii<MeteoData::nrOfAllParameters; ii++) {
//loop through all meteo params and check whether they're nodata values
if (data[ii] <= plugin_nodata)
data[ii] = IOUtils::nodata;
......
......@@ -82,6 +82,7 @@ class MeteoGrids {
static const size_t nrOfParameters; ///<holds the number of meteo parameters stored in MeteoData
static const std::string& getParameterName(const size_t& parindex);
static size_t getParameterIndex(const std::string& parname);
private:
//static methods
......
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