WSL/SLF GitLab Repository

Commit 13509ff4 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

The info string for the spatial interpolations was not being cleared between...

The info string for the spatial interpolations was not being cleared between calls, leading to ever increasing content... Otherwise, using an ostringstream instead of stringstream in PNGIO and fixed a typo in the documentation.
parent 43a7ecfb
......@@ -279,6 +279,7 @@ double ConstLapseRateAlgorithm::getQualityRating(const Date& i_date, const Meteo
void ConstLapseRateAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if (vecAltitudes.empty())
......@@ -328,6 +329,7 @@ double IDWLapseAlgorithm::getQualityRating(const Date& i_date, const MeteoData::
void IDWLapseAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if (vecAltitudes.empty())
......@@ -355,7 +357,8 @@ double LocalIDWLapseAlgorithm::getQualityRating(const Date& i_date, const MeteoD
void LocalIDWLapseAlgorithm::calculate(const DEMObject& /*dem*/, Grid2DObject& /*grid*/)
{
/*if (nrOfMeasurments == 0)
/*info.clear(); info.str("");
if (nrOfMeasurments == 0)
throw IOException("Interpolation FAILED for parameter " + MeteoData::getParameterName(param), AT);
//Set regression coefficients
......@@ -406,6 +409,7 @@ double RHAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Parame
void RHAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if (vecAltitudes.empty())
......@@ -466,6 +470,7 @@ double ILWRAlgorithm::getQualityRating(const Date& i_date, const MeteoData::Para
void ILWRAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if (vecAltitudes.empty())
......@@ -522,6 +527,7 @@ double SimpleWindInterpolationAlgorithm::getQualityRating(const Date& i_date, co
void SimpleWindInterpolationAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
vector<double> vecAltitudes;
getStationAltitudes(vecMeta, vecAltitudes);
if (vecAltitudes.empty())
......@@ -598,6 +604,7 @@ double SnowHNWInterpolation::getQualityRating(const Date& i_date, const MeteoDat
void SnowHNWInterpolation::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
//retrieve optional arguments
std::string base_algo;
if (vecArgs.empty()){
......@@ -696,6 +703,7 @@ double OrdinaryKrigingAlgorithm::getQualityRating(const Date& i_date, const Mete
void OrdinaryKrigingAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
//optimization: getRange (from variogram fit -> exclude stations that are at distances > range (-> smaller matrix)
//or, get max range from io.ini, build variogram from this user defined max range
if(!computeVariogram()) //only refresh once a month, or once a week, etc
......@@ -705,6 +713,7 @@ void OrdinaryKrigingAlgorithm::calculate(const DEMObject& dem, Grid2DObject& gri
void LapseOrdinaryKrigingAlgorithm::calculate(const DEMObject& dem, Grid2DObject& grid)
{
info.clear(); info.str("");
//optimization: getRange (from variogram fit -> exclude stations that are at distances > range (-> smaller matrix)
//or, get max range from io.ini, build variogram from this user defined max range
vector<double> vecAltitudes;
......
......@@ -163,7 +163,7 @@ class InterpolationAlgorithm {
std::vector<MeteoData> vecMeteo;
std::vector<double> vecData; ///<store the measurement for the given parameter
std::vector<StationData> vecMeta; ///<store the station data for the given parameter
std::ostringstream info; ///<to store some extra information about the interoplation process
std::ostringstream info; ///<to store some extra information about the interplation process
MeteoData::Parameters param; ///<the parameter that we will interpolate
size_t nrOfMeasurments; ///<the available number of measurements
IOManager& iomanager;
......
......@@ -768,7 +768,7 @@ std::string PNGIO::decimal_to_dms(const double& decimal) {
const double m = floor( ((decimal - (double)d)*60.)*100. ) / 100.;
const double s = 3600.*(decimal - (double)d) - 60.*m;
std::stringstream dms;
std::ostringstream dms;
dms << d << "/1 " << static_cast<int>(m*100) << "/100 " << fixed << setprecision(6) << s << "/1";
return dms.str();
}
......
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