WSL/SLF GitLab Repository

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

The A3DIO plugin was not properly reading data, this has been fixed. Some...

The A3DIO plugin was not properly reading data, this has been fixed. Some warnings have been turned off for osX (signedness and 32/64 bits because of size_t since we will have to redo all our indices to make they consistently rely on size_t)
parent 25793786
......@@ -46,6 +46,9 @@ ELSE(MSVC)
ELSE(POPC)
SET(EXTRA_WARNINGS "-Wextra -pedantic -Weffc++ ${DEEP_WARNINGS}") #-Weffc++
ENDIF(POPC)
IF(APPLE)
SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -Wno-sign-conversion -Wno-shorten-64-to-32") #for now, keep clang quiet
ENDIF(APPLE)
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
SET(EXTRA_WARNINGS "${EXTRA_WARNINGS} -ansi") #Android does not like ansi...
IF(WIN32) #for gcc on windows
......
......@@ -677,10 +677,7 @@ SMETReader::SMETReader(const std::string& in_fname)
cleanup(fin); //closes file
}
SMETReader::~SMETReader()
{
}
SMETReader::~SMETReader() {}
void SMETReader::cleanup(std::ifstream& fin) throw()
{
......@@ -878,7 +875,6 @@ void SMETReader::read_header(std::ifstream& fin)
while (!fin.eof() && (fin.peek() != '[')){ //Read until next section
getline(fin, line, eoln);
SMETCommon::stripComments(line);
SMETCommon::trim(line);
......
......@@ -57,7 +57,6 @@ namespace mio {
*/
const double A3DIO::plugin_nodata = -9999.0; //plugin specific nodata value
const unsigned int A3DIO::buffer_reserve = 23*24*2; //kind of average size of a buffer for optimizing vectors
A3DIO::A3DIO(const std::string& configfile)
: cfg(configfile),
......@@ -270,32 +269,29 @@ void A3DIO::read1DMeteo(const Date& dateStart, const Date& dateEnd, std::vector<
try {
//Read one line, construct Date object and see whether date is greater or equal than the date_in object
bool eof_reached = false;
IOUtils::skipLines(fin, 1, eoln); //skip rest of line
IOUtils::skipLines(fin, 6, eoln); //skip header lines
//Loop going through the data sequentially until dateStart is found
do {
getline(fin, line, eoln); //read complete line
eof_reached = readMeteoDataLine(line, tmpdata, meteo1d);
//tmpdata.cleanData();
convertUnits(tmpdata);
} while((tmpdata.date < dateStart) && (!eof_reached));
if ((dateEnd < dateStart) && (!eof_reached)){ //Special case
vecMeteo.push_back( std::vector<MeteoData>() );
vecMeteo[0].push_back(tmpdata);
vecMeteo.front().push_back(tmpdata);
} else if ((tmpdata.date <= dateEnd) && (!eof_reached)) {
vecMeteo.push_back( std::vector<MeteoData>() );
vecMeteo[0].reserve(buffer_reserve);
}
while ((tmpdata.date <= dateEnd) && (!eof_reached)) {
//At this point tmpdata.date is >= dateStart
vecMeteo[0].push_back(tmpdata);
vecMeteo.front().push_back(tmpdata);
getline(fin, line, eoln); //read complete line
eof_reached = readMeteoDataLine(line, tmpdata, meteo1d);
//tmpdata.cleanData();
convertUnits(tmpdata);
}
} catch(...) {
......@@ -411,7 +407,6 @@ void A3DIO::read2DMeteo(std::vector< std::vector<MeteoData> >& vecMeteo)
//init vecStation with proper StationData, vecMeteo with nodata
for (size_t jj=0; jj<tmpvecS.size(); jj++){
vecMeteo.push_back( std::vector<MeteoData>() );
vecMeteo[jj+1].reserve(buffer_reserve);
MeteoData tmd; //create an empty data set
tmd.meta = tmpvecS[jj]; //add meta data to that data set
for (size_t ii=0; ii<vecMeteo.front().size(); ii++){
......
......@@ -58,8 +58,6 @@ class A3DIO : public IOInterface {
virtual void write2DGrid(const Grid2DObject& grid_in, const MeteoGrids::Parameters& parameter, const Date& date);
private:
static const double plugin_nodata; //plugin specific nodata value, e.g. -9999
static const unsigned int buffer_reserve; //for optimizing vectors (ie: avoid unecessary resizing)
void read1DStation(StationData& sd);
void read1DMeteo(const Date& dateStart, const Date& dateEnd, std::vector< std::vector<MeteoData> >&);
void read2DStations(const Date& timestamp, std::vector<StationData>& vecStation);
......@@ -88,6 +86,8 @@ class A3DIO : public IOInterface {
double in_tz, out_tz; //timezones
std::string meteo1d;
std::string coordin, coordinparam, coordout, coordoutparam; //projection parameters
static const double plugin_nodata; //plugin specific nodata value, e.g. -9999
};
} //end namespace
......
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