WSL/SLF GitLab Repository

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

The OLWR hack for Norway has been implemented in SMETIO (a cleaner, long term...

The OLWR hack for Norway has been implemented in SMETIO (a cleaner, long term solution will still have to be developed). Various types issues have been identified by Visual C++ and should have been fixed.
parent a6bdfa63
......@@ -143,5 +143,6 @@ class BufferedIOHandler : public IOInterface {
size_t chunks; ///< How many chuncks to buffer
size_t max_grids; ///< How many grids to buffer (grids, dems, landuse and assimilation grids together)
};
} //end namespace
#endif
......@@ -282,8 +282,8 @@ class ConfigProxy {
const Config::Options& opt;
ConfigProxy(const Config& i_cfg, const std::string& i_key,
const std::string& i_section, const Config::Options& i_opt)
: proxycfg(i_cfg), key(i_key),section(i_section), opt(i_opt) { }
const std::string& i_section, const Config::Options& i_opt)
: proxycfg(i_cfg), key(i_key),section(i_section), opt(i_opt) { }
template<typename T> operator T()
{
......
......@@ -529,14 +529,14 @@ int Date::getJulianDayNumber(const bool& gmt) const {
if(gmt) {
const double first_day_of_year = getJulianDayNumber(gmt_year, 1, 1);
return (gmt_julian - first_day_of_year + 1);
return (int)(gmt_julian - first_day_of_year + 1);
} else {
const double local_julian = GMTToLocal(gmt_julian);
int local_year, local_month, local_day, local_hour, local_minute;
calculateValues(local_julian, local_year, local_month, local_day, local_hour, local_minute);
const double in_day_offset = 1./24.*((double)local_hour+1./60.*(double)local_minute) - 0.5;
const double first_day_of_year = static_cast<double>(getJulianDayNumber(local_year, 1, 1)) + in_day_offset;
return (local_julian - first_day_of_year + 1);
return (int)(local_julian - first_day_of_year + 1);
}
}
......
......@@ -30,10 +30,10 @@ Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, IOManager& i_iom)
* Concept of this constructor: loop over all MeteoData::Parameters and then look
* for configuration of interpolation algorithms within the Config object.
*/
for (unsigned int ii=0; ii < MeteoData::nrOfParameters; ii++){ //loop over all MeteoData member variables
for (size_t ii=0; ii < MeteoData::nrOfParameters; ii++){ //loop over all MeteoData member variables
std::vector<std::string> tmpAlgorithms;
const std::string& parname = MeteoData::getParameterName(ii); //Current parameter name
unsigned int nrOfAlgorithms = getAlgorithmsForParameter(parname, tmpAlgorithms);
size_t nrOfAlgorithms = getAlgorithmsForParameter(parname, tmpAlgorithms);
if (nrOfAlgorithms > 0)
mapAlgorithms[parname] = tmpAlgorithms;
......@@ -43,7 +43,7 @@ Meteo2DInterpolator::Meteo2DInterpolator(const Config& i_cfg, IOManager& i_iom)
void Meteo2DInterpolator::check_projections(const DEMObject& dem, const std::vector<MeteoData>& vec_meteo)
{
//check that the stations are using the same projection as the dem
for (unsigned int i=0; i<(unsigned int)vec_meteo.size(); i++) {
for (size_t i=0; i<vec_meteo.size(); i++) {
const StationData& meta = vec_meteo[i].meta;
if(!meta.position.isSameProj(dem.llcorner)) {
std::stringstream os;
......@@ -75,7 +75,7 @@ void Meteo2DInterpolator::interpolate(const Date& date, const DEMObject& dem, co
auto_ptr<InterpolationAlgorithm> bestalgorithm(NULL);
vector<string> vecArgs;
for (unsigned int ii=0; ii < it->second.size(); ii++){
for (size_t ii=0; ii < it->second.size(); ii++){
const string& algoname = it->second.at(ii);
getArgumentsForAlgorithm(meteoparam, algoname, vecArgs);
......@@ -146,8 +146,8 @@ size_t Meteo2DInterpolator::getAlgorithmsForParameter(const std::string& parname
}
size_t Meteo2DInterpolator::getArgumentsForAlgorithm(const MeteoData::Parameters& param,
const std::string& algorithm,
std::vector<std::string>& vecArgs) const
const std::string& algorithm,
std::vector<std::string>& vecArgs) const
{
vecArgs.clear();
const string keyname = MeteoData::getParameterName(param) +"::"+ algorithm;
......
......@@ -87,7 +87,7 @@ const resamplingptr& ResamplingAlgorithms::getAlgorithm(const std::string& algon
* @endcode
*/
void ResamplingAlgorithms::NoResampling(const unsigned int& /*pos*/, const unsigned int& /*paramindex*/,
void ResamplingAlgorithms::NoResampling(const size_t& /*pos*/, const size_t& /*paramindex*/,
const std::vector<std::string>& /*taskargs*/, std::vector<MeteoData>& /*vecM*/)
{
return;
......@@ -106,7 +106,7 @@ void ResamplingAlgorithms::NoResampling(const unsigned int& /*pos*/, const unsig
* @endcode
*/
void ResamplingAlgorithms::NearestNeighbour(const unsigned int& pos, const unsigned int& paramindex,
void ResamplingAlgorithms::NearestNeighbour(const size_t& pos, const size_t& paramindex,
const std::vector<std::string>& /*taskargs*/, std::vector<MeteoData>& vecM)
{
if (pos >= vecM.size())
......@@ -119,7 +119,7 @@ void ResamplingAlgorithms::NearestNeighbour(const unsigned int& pos, const unsig
//Try to find the nearest neighbour, if there are two equally distant, then return the arithmetic mean
MeteoData m1, m2;
bool found1=false, found2=false;
for (unsigned int ii=pos+1; ii<vecM.size(); ii++){
for (size_t ii=pos+1; ii<vecM.size(); ii++){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
m1 = vecM[ii];
found1 = true;
......@@ -127,7 +127,7 @@ void ResamplingAlgorithms::NearestNeighbour(const unsigned int& pos, const unsig
}
}
for (unsigned int ii=0; ii<(unsigned int)pos; ii++){
for (size_t ii=0; ii<pos; ii++){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
m2 = vecM[ii];
found2 = true;
......@@ -165,7 +165,7 @@ void ResamplingAlgorithms::NearestNeighbour(const unsigned int& pos, const unsig
* TA::args = extrapolate
* @endcode
*/
void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsigned int& paramindex,
void ResamplingAlgorithms::LinearResampling(const size_t& pos, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM)
{
if (pos >= vecM.size())
......@@ -184,7 +184,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
size_t indexP1=IOUtils::npos, indexP2=IOUtils::npos;
bool foundP1=false, foundP2=false;
for (unsigned int ii=pos; (ii--) > 0; ){
for (size_t ii=pos; (ii--) > 0; ){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP1 = (size_t)ii;
foundP1 = true;
......@@ -192,7 +192,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
}
}
for (unsigned int ii=pos+1; ii<vecM.size(); ii++){
for (size_t ii=pos+1; ii<vecM.size(); ii++){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP2 = (size_t)ii;
foundP2 = true;
......@@ -210,7 +210,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
//At this point we either have a valid indexP1 or indexP2 and we can at least try to extrapolate
if (!foundP1 && foundP2){ //only nodata values found before pos, try looking after indexP2
for (unsigned int ii=indexP2+1; ii<vecM.size(); ii++){
for (size_t ii=indexP2+1; ii<vecM.size(); ii++){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP1 = ii;
foundP1 = true;
......@@ -218,7 +218,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
}
}
} else if (foundP1 && !foundP2){ //only nodata found after pos, try looking before indexP1
for (unsigned int ii=indexP1; (ii--) > 0; ){
for (size_t ii=indexP1; (ii--) > 0; ){
if (vecM[ii].param(paramindex) != IOUtils::nodata){
indexP2=ii;
foundP2 = true;
......@@ -249,7 +249,7 @@ void ResamplingAlgorithms::LinearResampling(const unsigned int& pos, const unsig
* HNW::arg1 = 3600
* @endcode
*/
void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned int& paramindex,
void ResamplingAlgorithms::Accumulate(const size_t& pos, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM)
{
/*
......@@ -277,7 +277,7 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
//find start of accumulation period
bool found_start=false;
unsigned int start_idx = pos+1;
size_t start_idx = pos+1;
Date dateStart(vecM[pos].date.getJulianDate() - accumulate_period/(24.*3600.), vecM[pos].date.getTimeZone());
for (start_idx=pos+1; (start_idx--) > 0; ){
......@@ -299,7 +299,7 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
//HACK: we consider nodata to be 0. In fact, we should try to interpolate from valid points
//if they are not too far away
unsigned int interval_end = start_idx + 1;
size_t interval_end = start_idx + 1;
double valstart = funcval(vecM, start_idx, dateStart, paramindex);
double valend = funcval(vecM, interval_end, vecM[interval_end].date, paramindex);
......@@ -327,7 +327,7 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
vecM[pos].param(paramindex) = sum;
return;
} else {
for (unsigned int ii=interval_end+1; ii<pos; ii++){
for (size_t ii=interval_end+1; ii<pos; ii++){
const double& val = vecM[ii].param(paramindex);
if (val != IOUtils::nodata)
sum += val;
......@@ -343,10 +343,10 @@ void ResamplingAlgorithms::Accumulate(const unsigned int& pos, const unsigned in
//TODO:check if at least one point has been summed. If not -> nodata
}
double ResamplingAlgorithms::funcval(const std::vector<MeteoData>& vecM, const unsigned int& index,
const Date& date, const unsigned int& paramindex)
double ResamplingAlgorithms::funcval(const std::vector<MeteoData>& vecM, const size_t& index,
const Date& date, const size_t& paramindex)
{
unsigned int start = index;
size_t start = index;
if (vecM[start].isResampled()){
if (start > 0){
start--;
......@@ -355,7 +355,7 @@ double ResamplingAlgorithms::funcval(const std::vector<MeteoData>& vecM, const u
}
}
unsigned int end = index+1;
size_t end = index+1;
const double& valstart = vecM[start].param(paramindex);
if (!vecM[index].isResampled() && (vecM[index].date == date))
......
......@@ -30,8 +30,8 @@
namespace mio {
typedef void(*resamplingptr)(const unsigned int& position, const unsigned int& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
typedef void(*resamplingptr)(const size_t& position, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
/**
* @class ResamplingAlgorithms
......@@ -47,19 +47,19 @@ class ResamplingAlgorithms {
static const resamplingptr& getAlgorithm(const std::string& algorithmname);
//Available algorithms
static void NoResampling(const unsigned int& position, const unsigned int& paramindex,
static void NoResampling(const size_t& position, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
static void LinearResampling(const unsigned int& position, const unsigned int& paramindex,
static void LinearResampling(const size_t& position, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
static void NearestNeighbour(const unsigned int& position, const unsigned int& paramindex,
static void NearestNeighbour(const size_t& position, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
static void Accumulate(const unsigned int& pos, const unsigned int& paramindex,
static void Accumulate(const size_t& position, const size_t& paramindex,
const std::vector<std::string>& taskargs, std::vector<MeteoData>& vecM);
private:
static double funcval(const std::vector<MeteoData>& vecM, const unsigned int& index,
const Date& date, const unsigned int& paramindex);
static double funcval(const std::vector<MeteoData>& vecM, const size_t& index,
const Date& date, const size_t& paramindex);
static double linearInterpolation(const double& x1, const double& y1,
const double& x2, const double& y2, const double& x3);
......
......@@ -218,9 +218,9 @@ size_t SMETCommon::readLineToVec(const std::string& line_in, std::vector<std::st
return vec_string.size();
}
SMETWriter::SMETWriter(const std::string& in_filename, const SMETType& in_type, const bool& in_gzip)
: filename(in_filename), smet_type(in_type), gzip(in_gzip), nr_of_fields(0),
julian_field(0), timestamp_field(0), nodata_value(-999.), nodata_string(""),
SMETWriter::SMETWriter(const std::string& in_filename, const SMETType& in_type, const bool& in_gzip)
: filename(in_filename), smet_type(in_type), gzip(in_gzip), nr_of_fields(0),
julian_field(0), timestamp_field(0), nodata_value(-999.), nodata_string(""),
location_in_header(false), location_in_data_wgs84(false), location_in_data_epsg(false),
timestamp_present(false), julian_present(false), file_is_binary(false),
location_wgs84(0), location_epsg(0)
......@@ -270,7 +270,7 @@ void SMETWriter::set_header_value(const std::string& key, const std::string& val
{
//check if header key/value pair is valid
if (valid_header_pair(key, value)){
header[key] = value;
header[key] = value;
if ((SMETCommon::all_optional_header_keys.find(key) == SMETCommon::all_optional_header_keys.end())
&& (SMETCommon::all_mandatory_header_keys.find(key) == SMETCommon::all_mandatory_header_keys.end()))
......@@ -312,7 +312,7 @@ bool SMETWriter::valid_header_pair(const std::string& key, const std::string& va
istringstream ss(value);
int intvalue;
if (!(ss >> intvalue)) return false;
}
}
if (SMETCommon::all_decimal_header_values.find(key) != SMETCommon::all_decimal_header_values.end()){
//check if value is a double value
......@@ -332,7 +332,7 @@ bool SMETWriter::valid_header_pair(const std::string& key, const std::string& va
bool SMETWriter::check_fields(const std::string& key, const std::string& value)
{
vector<string> tmp_vec;
size_t counter = SMETCommon::readLineToVec(value, tmp_vec);
//Firstly: Check if number of fields is consistent
......@@ -428,7 +428,7 @@ void SMETWriter::write(const std::vector<std::string>& vec_timestamp, const std:
return;
}
if (!timestamp_present)
if (!timestamp_present)
throw SMETException("No timestamp present, use write(const vector<double>& data)", SMET_AT);
const size_t nr_of_data_fields = nr_of_fields - 1;
......@@ -446,7 +446,7 @@ void SMETWriter::write(const std::vector<std::string>& vec_timestamp, const std:
const size_t offset = ii*(nr_of_fields-1);
if (data.size() != 0)
copy(data.begin()+offset, data.begin()+offset+nr_of_data_fields, current_data.begin());
write_data_line_ascii(vec_timestamp[ii], current_data);
write_data_line_ascii(vec_timestamp[ii], current_data);
}
} else {
throw SMETException("Cannot write a binary file with a timestamp, use julian instead", SMET_AT);
......@@ -473,7 +473,7 @@ void SMETWriter::write(const std::vector<double>& data)
throw SMETException("Inconsistency between data and header fields detected, recheck your data", SMET_AT);
std::vector<double> current_data;
current_data.resize(nr_of_fields);
current_data.resize(nr_of_fields);
check_formatting();
if (smet_type == ASCII){
......@@ -488,7 +488,7 @@ void SMETWriter::write(const std::vector<double>& data)
copy(data.begin()+ii*nr_of_fields, data.begin()+ii*nr_of_fields+nr_of_fields, current_data.begin());
write_data_line_binary(current_data);
}
file_is_binary = false;
}
......@@ -506,9 +506,9 @@ void SMETWriter::write_header()
fout << "[HEADER]" << endl;
fout << "station_id = " << header["station_id"] << endl;
it = header.find("station_name");
if (it != header.end())
if (it != header.end())
fout << "station_name = " << it->second << endl;
if (location_in_header){
......@@ -534,27 +534,27 @@ void SMETWriter::write_header()
//Optional header keys:
it = header.find("tz");
if (it != header.end())
if (it != header.end())
fout << "tz = " << it->second << endl;
it = header.find("creation");
if (it != header.end())
if (it != header.end())
fout << "creation = " << it->second << endl;
it = header.find("source");
if (it != header.end())
if (it != header.end())
fout << "source = " << it->second << endl;
it = header.find("units_offset");
if (it != header.end())
if (it != header.end())
fout << "units_offset = " << it->second << endl;
it = header.find("units_multiplier");
if (it != header.end())
if (it != header.end())
fout << "units_multiplier = " << it->second << endl;
it = header.find("comment");
if (it != header.end())
if (it != header.end())
fout << "comment = " << it->second << endl;
for (size_t ii=0; ii<other_header_keys.size(); ii++){
......@@ -572,7 +572,7 @@ void SMETWriter::write_data_line_binary(const std::vector<double>& data)
if (!file_is_binary){ //open it as binary file
fout.close();
fout.open(filename.c_str(), ios::out | ios::app | ios::binary); //reopen as binary file
if (fout.fail())
if (fout.fail())
throw SMETException("Could not access file " + filename, SMET_AT);
file_is_binary = true;
......@@ -638,7 +638,7 @@ void SMETWriter::set_precision(const std::vector<size_t>& vec_precision)
}
SMETReader::SMETReader(const std::string& in_fname) : filename(in_fname), nr_of_fields(0), timestamp_present(false),
SMETReader::SMETReader(const std::string& in_fname) : filename(in_fname), nr_of_fields(0), timestamp_present(false),
julian_present(false), timestamp_field(0), julian_field(0),
isAscii(true), location_wgs84(0), location_epsg(0),
location_data_wgs84(0), location_data_epsg(0), nodata_value(-999.),
......@@ -730,7 +730,7 @@ void SMETReader::process_header()
for (it = header.begin(); it != header.end(); it++){
if (SMETCommon::all_mandatory_header_keys.find(it->first) != SMETCommon::all_mandatory_header_keys.end())
obligatory_keys.insert(it->first);
if (it->first == "fields"){
SMETCommon::readLineToVec(it->second, tmp_vec);
string newfields = "";
......@@ -750,7 +750,7 @@ void SMETReader::process_header()
julian_present = true;
julian_field = ii;
}
//Using WGS_84 coordinate system
if (tmp_vec[ii] == "latitude") location_data_wgs84 |= 1;
else if (tmp_vec[ii] == "longitude") location_data_wgs84 |= 2;
......@@ -821,7 +821,7 @@ void SMETReader::process_header()
if (obligatory_keys.size() != SMETCommon::all_mandatory_header_keys.size())
throw SMETException("Not a valid SMET file, mandatory information in header is missing", SMET_AT);
if ((location_wgs84 == 7) || (location_epsg == 15) || (location_data_wgs84 == 7)
if ((location_wgs84 == 7) || (location_epsg == 15) || (location_data_wgs84 == 7)
|| ((location_epsg == 8) && (location_data_epsg == 7))){
//location info present somewhere
} else {
......@@ -882,7 +882,7 @@ void SMETReader::checkSignature(const std::vector<std::string>& vecSignature, bo
throw SMETException("The signature of file " + filename + " is invalid", SMET_AT);
std::string version = vecSignature[1];
if ((version != "0.9") && (version != "0.95") && (version != "0.99")
if ((version != "0.9") && (version != "0.95") && (version != "0.99")
&& (version != "1.0") && (version != SMETCommon::smet_version))
throw SMETException("Unsupported file format version for file " + filename, SMET_AT);
......@@ -900,7 +900,7 @@ void SMETReader::checkSignature(const std::vector<std::string>& vecSignature, bo
throw SMETException("The 3rd column of file " + filename + " must be either ASCII or BINARY", SMET_AT);
}
void SMETReader::read(const std::string& i_timestamp_start, const std::string& i_timestamp_end,
void SMETReader::read(const std::string& i_timestamp_start, const std::string& i_timestamp_end,
std::vector<std::string>& vec_timestamp, std::vector<double>& vec_data)
{
if (!timestamp_present){
......@@ -933,7 +933,7 @@ void SMETReader::read(const double& i_julian_start, const double& i_julian_end,
void SMETReader::read(std::vector<std::string>& vec_timestamp, std::vector<double>& vec_data)
{
if (!timestamp_present)
if (!timestamp_present)
throw SMETException("Requesting to read timestamp when there is none present", SMET_AT);
ifstream fin;
......@@ -963,7 +963,7 @@ void SMETReader::read(std::vector<std::string>& vec_timestamp, std::vector<doubl
throw SMETException("Binary SMET file has no field timestamp, only julian date", SMET_AT);
} catch(...) {
cleanup(fin);
throw;
throw;
}
cleanup(fin);
......@@ -971,9 +971,9 @@ void SMETReader::read(std::vector<std::string>& vec_timestamp, std::vector<doubl
void SMETReader::read(std::vector<double>& vec_data)
{
if (timestamp_present)
if (timestamp_present)
SMETException("Requesting not to read timestamp when there is one present", SMET_AT);
vector<string> tmp_vec;
ios_base::openmode mode = ios::in;
......@@ -982,9 +982,9 @@ void SMETReader::read(std::vector<double>& vec_data)
ifstream fin;
fin.open (filename.c_str(), ios::in);
if (fin.fail())
if (fin.fail())
throw SMETException("Could not open file '" + filename + "' for reading", SMET_AT);
try {
fin.seekg(data_start_fpointer); //jump to data start position in the file
if (julian_interval && julian_present){
......@@ -1002,7 +1002,7 @@ void SMETReader::read(std::vector<double>& vec_data)
read_data_binary(fin, vec_data);
} catch(...) {
cleanup(fin);
throw;
throw;
}
cleanup(fin);
......@@ -1029,7 +1029,7 @@ void SMETReader::read_data_ascii(std::ifstream& fin, std::vector<std::string>& v
size_t shift = 0;
if (julian_interval && julian_present){
double current_julian = SMETCommon::convert_to_double(tmp_vec[julian_field]);
if (current_julian < julian_start)
if (current_julian < julian_start)
continue; //skip lines that don't hold the dates we're interested in
else if (current_julian > julian_end)
break; //skip the rest of the file
......@@ -1060,7 +1060,7 @@ void SMETReader::read_data_ascii(std::ifstream& fin, std::vector<std::string>& v
}
}
if (current_fpointer != -1){
if (current_fpointer != static_cast<streampos>(-1)){
if (timestamp_interval && timestamp_present)
map_timestamp_streampos[timestamp_end] = current_fpointer;
else if (julian_interval && julian_present)
......@@ -1094,7 +1094,7 @@ void SMETReader::read_data_binary(std::ifstream& fin, std::vector<double>& vec_d
}
}
}
if (julian_present && julian_interval){
if ((julian < julian_start) || (julian > julian_end)){
for (size_t ii=0; ii<nr_of_fields; ii++){
......@@ -1113,10 +1113,10 @@ void SMETReader::read_data_binary(std::ifstream& fin, std::vector<double>& vec_d
throw SMETException("Corrupted data in section [DATA]", SMET_AT);
}
if (current_fpointer != -1){
if (current_fpointer != static_cast<streampos>(-1)){
if (julian_interval && julian_present)
map_julian_streampos[julian_end] = current_fpointer;
}
}
}
double SMETReader::get_header_doublevalue(const std::string& key) const
......@@ -1124,7 +1124,7 @@ double SMETReader::get_header_doublevalue(const std::string& key) const
map<string,string>::const_iterator it = header.find(key);
if (it != header.end())
return SMETCommon::convert_to_double(it->second);
return nodata_value;
}
......@@ -1134,7 +1134,7 @@ int SMETReader::get_header_intvalue(const std::string& key) const
if (it != header.end())
return SMETCommon::convert_to_int(it->second);
return floor(nodata_value + 0.1);
return (int)floor(nodata_value + 0.1);
}
std::string SMETReader::get_header_value(const std::string& key) const
......@@ -1142,7 +1142,7 @@ std::string SMETReader::get_header_value(const std::string& key) const
map<string,string>::const_iterator it = header.find(key);
if (it != header.end())
return it->second;
return "";
}
......
......@@ -157,8 +157,8 @@ double LinVario::f(const double& x) {
void LinVario::setDefaultGuess() {
double xzero=X[0];
unsigned int xzero_idx=0;
for(unsigned int i=1; i<X.size(); i++) {
size_t xzero_idx=0;
for(size_t i=1; i<X.size(); i++) {
if(abs(X[i])<xzero) { xzero=X[i]; xzero_idx=i;}
}
const double slope = Interpol1D::arithmeticMean( Interpol1D::derivative(X, Y) );
......@@ -182,8 +182,8 @@ double ExpVario::f(const double& x) {
void ExpVario::setDefaultGuess() {
double xzero=X[0];
unsigned int xzero_idx=0;
for(unsigned int i=1; i<X.size(); i++) {
size_t xzero_idx=0;
for(size_t i=1; i<X.size(); i++) {
if(abs(X[i])<xzero) { xzero=X[i]; xzero_idx=i;}
}
Lambda.push_back( Y[xzero_idx] );
......@@ -207,8 +207,8 @@ double RatQuadVario::f(const double& x) {
void RatQuadVario::setDefaultGuess() {
double xzero=X[0];
unsigned int xzero_idx=0;
for(unsigned int i=1; i<X.size(); i++) {
size_t xzero_idx=0;
for(size_t i=1; i<X.size(); i++) {
if(abs(X[i])<xzero) { xzero=X[i]; xzero_idx=i;}
}
Lambda.push_back( Y[xzero_idx] );
......@@ -223,8 +223,8 @@ double LinearLS::f(const double& x) {
void LinearLS::setDefaultGuess() {
double xzero=X[0];
unsigned int xzero_idx=0;
for(unsigned int i=1; i<X.size(); i++) {
size_t xzero_idx=0;
for(size_t i=1; i<X.size(); i++) {
if(abs(X[i])<xzero) { xzero=X[i]; xzero_idx=i;}
}
......@@ -242,8 +242,8 @@ void Quadratic::setDefaultGuess() {
std::vector<double> der = Interpol1D::derivative(X, Y);
const double acc = 0.5 * Interpol1D::arithmeticMean( Interpol1D::derivative(X, der) );
double xzero=der[0];
unsigned int xzero_idx=0;
for(unsigned int i=1; i<der.size(); i++) {
size_t xzero_idx=0;
for(size_t i=1; i<der.size(); i++) {
if(abs(der[i])<xzero) { xzero=der[i]; xzero_idx=i;}
}
......
......@@ -139,15 +139,15 @@ bool FitLeastSquare::computeFit() {
do {
iter++;