// // C++ Interface: %{MODULE} // // Description: // // // Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR} // // Copyright: See COPYING file that comes with this distribution // // #ifndef POLDERPARASOLFILEDATA_H #define POLDERPARASOLFILEDATA_H #include #include #include #include "filedatareader.h" #include "polder.h" #include #include #include "hdfi.h" #include "parasolleader.h" #include "parasoldata.h" #include "parasolfiledata.h" #include "satellitefiledata.h" #include "Hdf_sds.hpp" using namespace std; /** @author James MANLEY */ class PolderParasolFileData : public FileDataReader, protected PARASOLFileData{ public: PolderParasolFileData(const string &name = string(""), const string &mode = string("r")); virtual ~PolderParasolFileData(); virtual void* read_data(void* data, const char* sds_name, int * start=NULL, int * stride=NULL, int *edges=NULL, int rank=-1); virtual vector get_dataset_dimension(const string &sds_name); void get_dataset_fill_value(const string &sds_name, void* fill_value); int get_n_dataset(); string get_dataset_name(int i); int get_dataset_data_type(string sds_name); string get_values_attr_dataset(string sds_name,string attr_name); bool has_attr_dataset(string sds_name,string attr_name); /** * @brief closes the file */ void close_data_file(); /** * @brief open the file */ void open_data_file(); void get_fillValue(const string &sds_name, void *fillValue); protected: short colmin; short linemin; short colmax; short linemax; string cursds; int fileid; string filename; /** * @brief list of all variables of the product */ string *var_list; /** * @brief number of variables of the product */ int nb_var_list; int size; int maxLine; int maxColumn; void getLatLon(short line, short column, float32 *lat, float32 *lon); // *** Ajout B. Six - 24/05/2011 - voir polderparasolfiledata.cpp void getLatLon1(short line, short column, float32 *lat, float32 *lon); // *** Fin ajout short NINT(float32 x); void free_read_write_allocations( const bool *are_limits_initialized, int *start, int *stride, int *edges ); const bool check_read_write_limits(const char* sds_name, int *start, int *stride, int *edges, const int rank); void init_read_write_null_input_param(const char* sds_name, int *&start, int *&stride, int *&edges, int &rank, bool * initialized_values); float32* read_data_latlon(float32* data, const char* sds_name, int * start, int * stride, int *edges, int rank); template T* read_data_T(T* data, const char* sds_name, int * start, int * stride, int *edges, int rank, int type); int get_dataset_idtype(string name); template void getFillValues(T &fillvalue); virtual void get_scaling(const string &sds_name, float64 &scale, float64 &offset); virtual vector get_dataset_full_dimension(const string &sds_name); }; template void PolderParasolFileData::getFillValues(T &fillvalue) { if ( typeid(T) == typeid(char8) ) { fillvalue = static_cast((T )SCHAR_MIN); } else if ( typeid(T) == typeid(uchar8) ) { fillvalue = static_cast((T )UCHAR_MAX); } else if ( typeid(T) == typeid(int8) ) { fillvalue = static_cast((T )SCHAR_MIN); } else if ( typeid(T) == typeid(uint8) ) { fillvalue = static_cast((T )UCHAR_MAX); } else if ( typeid(T) == typeid(int16) ) { fillvalue = static_cast((T )SHRT_MIN); } else if ( typeid(T) == typeid(uint16) ) { fillvalue = static_cast((T )USHRT_MAX); } else if ( typeid(T) == typeid(int32) ) { fillvalue = static_cast((T )LONG_MIN); } else if ( typeid(T) == typeid(uint32) ) { fillvalue = static_cast((T )ULONG_MAX); } else if ( typeid(T) == typeid(float32) ) { fillvalue = static_cast((T )-DBL_MAX); } else if ( typeid(T) == typeid(float64) ) { fillvalue = static_cast((T )-LDBL_MAX); } } template T* PolderParasolFileData::read_data_T(T* data, const char* sds_name, int * start, int * stride, int *edges, int rank, int type) { bool stride_bool; if(stride==NULL) stride_bool=true; else stride_bool=false; bool are_limits_initialized[3]; // check if start, stride or edges had been initialized in this method // --- initialize NULL input parametres --- init_read_write_null_input_param(sds_name, start, stride, edges,rank, are_limits_initialized); // check the selection limits check_read_write_limits(sds_name, start,stride,edges,rank); // throw bad_index in case of probleml // read the size of the sds data vector dim = get_dataset_dimension(sds_name); if(rank==-1) rank = dim.size(); int osize =1; for(int i =0; i(malloc(sizeof(T)*osize)); T fillvalue; getFillValues(fillvalue); get_dataset_fill_value(sds_name,&fillvalue); for(int i=0; idata->get_data_entry_index(sds_name)-6; if( type == DFNT_UINT8){ ExtractVariable_Var_Byte(fileid, (unsigned char**)&val, param_ind); }else if( type == DFNT_UINT16){ ExtractVariable_Var_Short(fileid, (unsigned short**)&val, param_ind); }else if( type == DFNT_UINT32){ ExtractVariable_Var_Int(fileid, (unsigned int**)&val, param_ind); }else{ ExtractVariable_Var(fileid, (float**)&val, param_ind); } short *line= NULL; ExtractVariable_Grid(fileid, &line, &size, LINE); short *col= NULL; ExtractVariable_Grid(fileid, &col, &size, COLUMN); T **oval = NULL; oval = (T**)&data; short l,c; if(stride_bool){ for(int i=0; i=start[0] && c=start[1] && l=start[0] && c=start[1] && l