WSL/SLF GitLab Repository

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

In SNIO, the METAFILE can now be optional (which means that the metadata...

In SNIO, the METAFILE can now be optional (which means that the metadata remain nodata, the user has therefore to fill them himself). This is used by Snowpack.

After the Visual C++ compilation log from Raphael, some changes have been implemented: lots of warnigs about signed/unsigned fixed, some unreachable code removed, and some methods reimplemented for Windows. We are not there yet, but moving closer...
parent d55f399d
......@@ -334,7 +334,7 @@ bool A3DIO::readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string
//throw InvalidFormatException("Premature End of Line or no data for date " + date_in + " found in File " + filename, AT);
}
for (int ii=0; ii<4; ii++) {
for (unsigned int ii=0; ii<4; ii++) {
if (!IOUtils::convertString(tmp_ymdh[ii], tmpvec.at(ii), std::dec))
throw InvalidFormatException(filename + ": " + line, AT);
}
......@@ -343,7 +343,7 @@ bool A3DIO::readMeteoDataLine(std::string& line, MeteoData& tmpdata, std::string
//Read rest of line with values ta, iswr, vw, rh, ea, hnw
for (int ii=0; ii<6; ii++) { //go through the columns
for (unsigned int ii=0; ii<6; ii++) { //go through the columns
if (!IOUtils::convertString(tmp_values[ii], tmpvec.at(ii+4), std::dec)) {
throw InvalidFormatException(filename + ": " + line, AT);
}
......@@ -594,7 +594,7 @@ void A3DIO::read2DMeteoData(const std::string& filename, const std::string& para
+ filename, AT);
}
for (int ii=0; ii<4; ii++) {
for (unsigned int ii=0; ii<4; ii++) {
if (!IOUtils::convertString(tmp_ymdh[ii], tmpvec[ii], std::dec)) {
throw InvalidFormatException("[E] Check date columns in " + filename, AT);
}
......
......@@ -15,6 +15,11 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <meteoio/Coords.h>
#ifdef PROJ4
......@@ -628,7 +633,7 @@ short int Coords::getEPSG() const {
return (32700+zoneNumber);
}
}
if(coordsystem=="PROJ4") return atoi(coordparam.c_str());
if(coordsystem=="PROJ4") return (short)atoi(coordparam.c_str());
//all others have no associated EPSG code
return -1;
......
......@@ -24,7 +24,6 @@
#include <string>
#include <iostream>
#include <map>
#include <cmath>
namespace mio {
......
......@@ -15,9 +15,14 @@
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/DEMObject.h>
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <limits.h>
#include <meteoio/DEMObject.h>
/**
* @file DEMObject.cc
* @brief implementation of the DEMBoject class
......@@ -406,10 +411,10 @@ double DEMObject::terrainDistance(Coords point1, const Coords& point2) {
}
for(unsigned int ii=1; ii<vec_points.size(); ii++) {
const int ix1=vec_points[last_point].ix;
const int iy1=vec_points[last_point].iy;
const int ix2=vec_points[ii].ix;
const int iy2=vec_points[ii].iy;
const unsigned int ix1=vec_points[last_point].ix;
const unsigned int iy1=vec_points[last_point].iy;
const unsigned int ix2=vec_points[ii].ix;
const unsigned int iy2=vec_points[ii].iy;
if(grid2D(ix2,iy2)!=IOUtils::nodata) {
if(grid2D(ix1,iy1)!=IOUtils::nodata) {
......
......@@ -23,6 +23,9 @@
#include <meteoio/Grid2DObject.h>
#include <meteoio/IOUtils.h>
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <limits>
......
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/Date.h>
#include <cmath>
using namespace std;
......@@ -188,6 +189,11 @@ void Date::setDate(const int& _year, const int& _month, const int& _day, const i
}
void setDate(const int& year, const unsigned int& month, const unsigned int& day, const unsigned int& hour, const unsigned int& minute, const double& in_timezone, const bool& in_dst=false)
{
setDate(year, (signed)month, (signed)day, (signed)hour, (signed)minute, in_timezone, in_dst);
}
/**
* @brief Set date from a julian date (JD).
* @param julian_in julian date to set
......
......@@ -23,7 +23,6 @@
#include <string>
#include <sstream>
#include <utility>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <ctime>
......@@ -100,7 +99,8 @@ class Date {
void setFromSys();
void setTimeZone(const double& in_timezone, const bool& in_dst=false);
void setDate(const double& julian_in, const double& in_timezone, const bool& _dst=false);
void setDate(const int& year, const int& month, const int& day, const int& hour, const int& minute, const double& in_timezone, const bool& _dst=false);
void setDate(const int& year, const int& month, const int& day, const int& hour, const int& minute, const double& in_timezone, const bool& in_dst=false);
void setDate(const int& year, const unsigned int& month, const unsigned int& day, const unsigned int& hour, const unsigned int& minute, const double& in_timezone, const bool& in_dst=false);
void setDate(const time_t& in_time, const bool& _dst=false);
void setModifiedJulianDate(const double& julian_in, const double& in_timezone, const bool& _dst=false);
void setUnixDate(const time_t& in_time, const bool& _dst=false);
......
......@@ -43,6 +43,7 @@ PluginObject* DynamicLibrary::newObject(const std::string& name, const Config& c
// Get the loadObject() function. If it doesn't exist, return NULL.
#ifdef WIN32
#pragma warning(disable:4191) //GetProcAddress does NOT return a FARPROC, the warning misses it...
const void (*loadSym)(const std::string&, const Config&) = (const void (*)(const std::string&, const Config&))GetProcAddress(_objFile, "loadObject");
#else
const void* loadSym = dlsym(_objFile, "loadObject");
......
......@@ -15,6 +15,10 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <meteoio/FilterAlgorithms.h>
using namespace std;
......
......@@ -28,7 +28,6 @@
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>
namespace mio {
......
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/Grid2DObject.h>
#include <cmath>
using namespace std;
......@@ -117,8 +118,8 @@ bool Grid2DObject::grid_to_WGS84(Coords& point) const {
//still fitting in the grid and return an error
if(i<0) i=0;
if(j<0) j=0;
if(i>(signed)ncols) i=ncols;
if(j>(signed)nrows) j=nrows;
if(i>(signed)ncols) i=(signed)ncols;
if(j>(signed)nrows) j=(signed)nrows;
point.setGridIndex(i, j, IOUtils::inodata, false);
return false;
}
......@@ -172,7 +173,7 @@ bool Grid2DObject::WGS84_to_grid(Coords& point) const {
error_code=false;
}
if(i>(signed)ncols) {
i=ncols;
i=(signed)ncols;
error_code=false;
}
if(j<0) {
......@@ -180,7 +181,7 @@ bool Grid2DObject::WGS84_to_grid(Coords& point) const {
error_code=false;
}
if(j>(signed)nrows) {
j=nrows;
j=(signed)nrows;
error_code=false;
}
......
......@@ -24,7 +24,6 @@
#include <meteoio/IOUtils.h>
#include <iostream>
#include <cmath>
namespace mio {
......
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/Grid3DObject.h>
#include <cmath>
using namespace std;
......@@ -115,9 +116,9 @@ bool Grid3DObject::grid_to_WGS84(Coords& point) const {
if(i<0) i=0;
if(j<0) j=0;
if(k<0) k=0;
if(i>(signed)ncols) i=ncols;
if(j>(signed)nrows) j=nrows;
if(k>(signed)ndepth) k=ndepth;
if(i>(signed)ncols) i=(signed)ncols;
if(j>(signed)nrows) j=(signed)nrows;
if(k>(signed)ndepth) k=(signed)ndepth;
point.setGridIndex(i, j, k, false);
return false;
}
......@@ -171,7 +172,7 @@ bool Grid3DObject::WGS84_to_grid(Coords point) const {
error_code=false;
}
if(i>(signed)ncols) {
i=ncols;
i=(signed)ncols;
error_code=false;
}
if(j<0) {
......@@ -179,7 +180,7 @@ bool Grid3DObject::WGS84_to_grid(Coords point) const {
error_code=false;
}
if(j>(signed)nrows) {
j=nrows;
j=(signed)nrows;
error_code=false;
}
if(k<0) {
......@@ -187,7 +188,7 @@ bool Grid3DObject::WGS84_to_grid(Coords point) const {
error_code=false;
}
if(k>(signed)ndepth) {
k=ndepth;
k=(signed)ndepth;
error_code=false;
}
......
......@@ -23,7 +23,6 @@
#include <meteoio/IOExceptions.h>
#include <meteoio/Grid2DObject.h>
#include <cmath>
#include <iostream>
namespace mio {
......
......@@ -15,6 +15,10 @@
You should have received a copy of the GNU Lesser General Public License
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <meteoio/IOUtils.h>
#include <meteoio/Config.h> // to avoid forward declaration hell
......@@ -22,6 +26,9 @@
#ifdef _WIN32
#include <windows.h>
//removing two macros defined in windows.h
#undef max
#undef min
#include <strsafe.h>
#else
#include <dirent.h>
......@@ -155,7 +162,8 @@ bool IOUtils::validFileName(const std::string& filename)
#ifdef _WIN32
bool IOUtils::fileExists(const std::string& filename)
{
return ( GetFileAttributes( (CString)filename ) != INVALID_FILE_ATTRIBUTES );
CString CSfilename(filename.c_str());
return ( GetFileAttributes( CSfilename ) != INVALID_FILE_ATTRIBUTES );
}
void IOUtils::readDirectory(const std::string& path, std::list<std::string>& dirlist, const std::string& pattern)
......@@ -385,20 +393,21 @@ bool IOUtils::convertString(Date& t, const std::string& str, const double& time_
trim(s); //delete trailing and leading whitespaces and tabs
(void)f;
unsigned int year, month, day, hour, minute, second;
int year;
unsigned int month, day, hour, minute, second;
char rest[32] = "";
//HACK: we read the seconds, but we ignore them...
if (sscanf(s.c_str(), "%u-%u-%u %u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
if (sscanf(s.c_str(), "%d-%u-%u %u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
t.setDate(year, month, day, hour, minute, time_zone);
} else if (sscanf(s.c_str(), "%u-%u-%uT%u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
} else if (sscanf(s.c_str(), "%d-%u-%uT%u:%u:%u%31s", &year, &month, &day, &hour, &minute, &second, rest) >= 6) {
t.setDate(year, month, day, hour, minute, time_zone);
} else if (sscanf(s.c_str(), "%u-%u-%u %u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
} else if (sscanf(s.c_str(), "%d-%u-%u %u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
t.setDate(year, month, day, hour, minute, time_zone);
} else if (sscanf(s.c_str(), "%u-%u-%uT%u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
} else if (sscanf(s.c_str(), "%d-%u-%uT%u:%u%31s", &year, &month, &day, &hour, &minute, rest) >= 5) {
t.setDate(year, month, day, hour, minute, time_zone);
} else if (sscanf(s.c_str(), "%u-%u-%u%31s", &year, &month, &day, rest) >= 3) {
t.setDate(year, month, day, 0, 0, time_zone);
} else if (sscanf(s.c_str(), "%d-%u-%u%31s", &year, &month, &day, rest) >= 3) {
t.setDate(year, month, day, (unsigned)0, (unsigned)0, time_zone);
} else if (sscanf(s.c_str(), "%u:%u%31s", &hour, &minute, rest) >= 2) {
t.setDate( ((double)hour)/24. + ((double)minute)/24./60. , time_zone);
} else {
......
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/ResamplingAlgorithms.h>
#include <cmath>
using namespace std;
......
......@@ -26,7 +26,6 @@
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>
namespace mio {
......
......@@ -16,6 +16,7 @@
along with MeteoIO. If not, see <http://www.gnu.org/licenses/>.
*/
#include <meteoio/StationData.h>
#include <cmath>
using namespace std;
......
......@@ -19,9 +19,16 @@
//AUTHORS: Tuan Anh Nguyen (original implementation in popc)
// Mathias Bavay (port and rewrite for Alpine3D, then MeteoIO)
#include "Timer.h"
#include <sys/time.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#undef max
#undef min
#else
#include <sys/time.h>
#endif
#include "Timer.h"
namespace mio {
......@@ -76,12 +83,30 @@ double Timer::getElapsed() {
return elapsed;
}
#ifdef _WIN32
double Timer::getCurrentTime() {
SYSTEMTIME systemTime;
GetSystemTime( &systemTime );
FILETIME fileTime;
SystemTimeToFileTime( &systemTime, &fileTime );
ULARGE_INTEGER uli;
uli.LowPart = fileTime.dwLowDateTime;
uli.HighPart = fileTime.dwHighDateTime;
ULONGLONG units_convert = 10000*1000; //it gives the time since 1 January 1601 (UTC) in units of 100ns
return (double)(uli.QuadPart/units_convert - 11644473600L); //offset in seconds to Unix epoch
//this is 134774 days * 24*3600
}
#else
double Timer::getCurrentTime() {
timeval tp;
gettimeofday(&tp,NULL);
const double t=tp.tv_sec+double(tp.tv_usec)*1.0e-6;
return t;
}
#endif
} //namespace
......@@ -27,7 +27,6 @@
#include <string>
#include <sstream>
#include <utility>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <ctime>
......
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