WSL/SLF GitLab Repository

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

More fixes for Visual C++ (but not all done yet) as well as new assignments...

More fixes for Visual C++ (but not all done yet) as well as new assignments operators for 1d, 2d, 3d arrays. It is now possible to do something like my2Dgrid.grid2D = 2.; and every cell will be filled with 2.
parent e9063b21
......@@ -35,7 +35,7 @@ IF(UNIX)
ENDIF(APPLE)
ELSE(UNIX)
IF(WIN32)
set(PLATFORM "-DWIN32 -U__STRICT_ANSI__")
set(PLATFORM "-DWIN32 -U__STRICT_ANSI__ -D_USE_MATH_DEFINES")
set(EXTRA_WARNINGS "-ansi")
ENDIF(WIN32)
ENDIF(UNIX)
......
......@@ -72,6 +72,7 @@ template<class T> class Array {
const T operator ()(const unsigned int& index) const;
Array<T>& operator =(const Array<T>&);
Array<T>& operator =(const T& value);
Array<T>& operator+=(const T& rhs);
const Array<T> operator+(const T& rhs);
......@@ -267,6 +268,12 @@ template<class T> Array<T>& Array<T>::operator=(const Array<T>& source) {
return *this;
}
template<class T> Array<T>& Array<T>::operator=(const T& value) {
//reset every single member of the Array3D<T>
std::fill(vecData.begin(), vecData.end(), value);
return *this;
}
template<class T> Array<T>& Array<T>::operator+=(const Array<T>& rhs)
{
//They have to have equal size
......
......@@ -137,6 +137,7 @@ template<class T> class Array2D {
Array2DProxy<T> operator[](const unsigned int& i);
Array2D<T>& operator =(const Array2D<T>&);
Array2D<T>& operator =(const T& value);
Array2D<T>& operator+=(const T& rhs);
const Array2D<T> operator+(const T& rhs);
......@@ -361,6 +362,17 @@ template<class T> Array2D<T>& Array2D<T>::operator=(const Array2D<T>& source) {
return *this;
}
template<class T> Array2D<T>& Array2D<T>::operator=(const T& value) {
//reset every single member of the Array3D<T>
/*for (unsigned int ii=0; ii<nx; ii++) {
for (unsigned int jj=0; jj<ny; jj++) {
operator()(ii,jj) = value;
}
}*/
std::fill(vecData.begin(), vecData.end(), value);
return *this;
}
template<class T> Array2D<T>& Array2D<T>::operator+=(const Array2D<T>& rhs)
{
//They have to have equal size
......
......@@ -166,6 +166,7 @@ template<class T> class Array3D {
Array3DProxy<T> operator[](const unsigned int& i);
Array3D<T>& operator =(const Array3D<T>&);
Array3D<T>& operator =(const T& value);
Array3D<T>& operator+=(const T& rhs);
const Array3D<T> operator+(const T& rhs);
......@@ -423,6 +424,19 @@ template<class T> Array3D<T>& Array3D<T>::operator=(const Array3D<T>& source) {
return *this;
}
template<class T> Array3D<T>& Array3D<T>::operator=(const T& value) {
//reset every single member of the Array3D<T>
/*for (unsigned int ii=0; ii<nx; ii++) {
for (unsigned int jj=0; jj<ny; jj++) {
for(unsigned int kk=0; kk<nz; kk++) {
operator()(ii,jj,kk) = value;
}
}
}*/
std::fill(vecData.begin(), vecData.end(), value);
return *this;
}
template<class T> Array3D<T>& Array3D<T>::operator+=(const Array3D<T>& rhs)
{
//They have to have equal size
......
......@@ -123,6 +123,7 @@ class BufferedIOHandler : public IOInterface {
friend class IOManager;
private:
//private methods
const std::vector<METEO_TIMESERIE>& get_complete_buffer(Date& start, Date& end);
void push_meteo_data(const Date& date_start, const Date& date_end,
......@@ -131,16 +132,17 @@ class BufferedIOHandler : public IOInterface {
void setDfltBufferProperties();
void bufferData(const Date& date_start, const Date& date_end, std::vector< METEO_TIMESERIE >& vecvecMeteo);
//private members
IOHandler& iohandler;
const Config& cfg;
std::vector< METEO_TIMESERIE > vec_buffer_meteo;
std::map<std::string, Grid2DObject> mapBufferedGrids;
Date buffer_start, buffer_end;
Duration chunk_size; ///< How much data to read at once
Duration buff_before; ///< How much data to read before the requested date in buffer
unsigned int chunks; ///< How many chuncks to buffer
std::vector< METEO_TIMESERIE > vec_buffer_meteo;
std::map<std::string, Grid2DObject> mapBufferedGrids;
};
} //end namespace
#endif
......@@ -15,9 +15,6 @@
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>
......
......@@ -139,6 +139,7 @@ class Coords {
int getUTMZone(const double latitude, const double longitude, std::string& zone_out) const;
private:
double ref_latitude, ref_longitude;
double altitude; ///<altitude of the point (the altitude is currently NOT dependant on the projection)
double latitude; ///<latitude of the point
double longitude; ///<longitude of the point
......@@ -147,7 +148,6 @@ class Coords {
int grid_i; ///<grid index i (please notice that this index is NOT automatically regenerated NOR checked)
int grid_j; ///<grid index j (please notice that this index is NOT automatically regenerated NOR checked)
int grid_k; ///<grid index k (please notice that this index is NOT automatically regenerated NOR checked)
double ref_latitude, ref_longitude;
static const bool __init; ///<helper variable to enable the init of static collection data
static bool initializeMaps();
......
......@@ -15,9 +15,6 @@
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 <limits.h>
......
......@@ -23,9 +23,6 @@
#include <meteoio/Grid2DObject.h>
#include <meteoio/IOUtils.h>
#ifdef MSVC
#define _USE_MATH_DEFINES
#endif
#include <cmath>
#include <limits>
......@@ -123,8 +120,8 @@ class DEMObject : public Grid2DObject {
void getNeighbours(const unsigned int i, const unsigned int j, double A[4][4]);
double safeGet(const int i, const int j);
slope_type dflt_algorithm;
int update_flag;
slope_type dflt_algorithm;
unsigned int slope_failures; ///<contains the number of points that have an elevation but no slope
unsigned int curvature_failures; ///<contains the number of points that have an elevation but no curvature
......
......@@ -189,7 +189,7 @@ 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)
void Date::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)
{
setDate(year, (signed)month, (signed)day, (signed)hour, (signed)minute, in_timezone, in_dst);
}
......
......@@ -170,9 +170,9 @@ class Date {
void plausibilityCheck(const int& in_year, const int& in_month, const int& in_day, const int& in_hour, const int& in_minute) const;
double timezone;
bool dst;
double gmt_julian;
int gmt_year, gmt_month, gmt_day, gmt_hour, gmt_minute;
bool dst;
bool undef;
};
......
......@@ -22,10 +22,12 @@
#ifndef USE_PRECOMPILED_HEADERS
#ifdef WIN32
#include <direct.h>
#include <windows.h>
#include <direct.h>
#include <windows.h>
#undef max
#undef min
#else
#include <dlfcn.h>
#include <dlfcn.h>
#endif
#include <iostream>
#include <sstream>
......
......@@ -15,9 +15,6 @@
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>
......
......@@ -128,13 +128,18 @@ class Grid3DObject{
* @return (bool) true if same geolocalization
*/
bool isSameGeolocalization(const Grid3DObject& target);
/**
* @brief Extract a 2D grid for a given height
* @param z layer to extract
* @param layer extracted 2D grid
*/
void extractLayer(const unsigned int& z, Grid2DObject& layer);
Array3D<double> grid3D;
unsigned int ncols, nrows, ndepth;
double cellsize;
Coords llcorner;
unsigned int ncols, nrows, ndepth;
//NOTE: the altitude is understood as above sea level,
//that is we curently don't support altitude as above the local ground
//std::vector<double> thickness;
......
......@@ -15,9 +15,6 @@
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>
......
......@@ -155,20 +155,22 @@ class MeteoData {
unsigned int getNrOfParameters() const;
private:
//static methods
static std::map<unsigned int, std::string> static_meteoparamname; ///<Associate a name with meteo parameters in Parameters
static const bool __init; ///<helper variable to enable the init of static collection data
static bool initStaticData();///<initialize the static map meteoparamname
unsigned int nrOfAllParameters;
//private methods
void initAllParameters();
void associateMemberVariables();
void initParameterMap(); ///<initializes the meteoparam map that allows sequential access to meteo parameters
std::map<std::string, double> extraparameters; ///<All non-standard meteo parameters will end up in this map
std::map<std::string, double*> mapParameterByName; ///<Associate name and meteo parameter
std::map<unsigned int, double*> meteoparam; ///<Associate an unsigned int with every meteo parameter
std::map<unsigned int, std::string> meteoparamname; ///<Associate a name with every meteo parameter
void initAllParameters();
void associateMemberVariables();
void initParameterMap(); ///<initializes the meteoparam map that allows sequential access to meteo parameters
unsigned int nrOfAllParameters;
bool resampled; ///<set this to true if MeteoData is result of resampling
};
......
......@@ -9,10 +9,12 @@
#define _Included_SYNCHRONIZED_H_
#ifdef WIN32
/* link to kernel32.dll */
#include <windows.h>
/* link to kernel32.dll */
#include <windows.h>
#undef max
#undef min
#else //assumes it's a Unix/Linux system
#include <pthread.h>
#include <pthread.h>
#endif
/**
......@@ -39,7 +41,7 @@
4. test part: the lock variable is tested and found to be false: the loop exits.
5. exit part: the lock variable is destroyed, unlocking the mutex.
*
*
*
*/
#define synchronized(M) for(Lock M##_lock = M; M##_lock; M##_lock.setUnlock())
......@@ -47,7 +49,7 @@
/**
* Mutex class, encapsulating CRiTICAL SECTION
* Mutex class, encapsulating CRiTICAL SECTION
*/
class Mutex
{
......@@ -120,7 +122,7 @@ Mutex mutex1;
//synchronized code here
...
} //lock1 destroyed -> mutex1 unlocked
*
*
*/
class Lock
{
......
......@@ -15,9 +15,6 @@
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/libinterpol2D.h>
......
......@@ -15,9 +15,6 @@
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/meteofilters/FilterWindAvg.h>
......
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