00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FELT_ARRAY_H_
00025 #define FELT_ARRAY_H_
00026 #include <string>
00027 #include <set>
00028 #include <vector>
00029 #include <map>
00030 #include <ctime>
00031 #include <boost/array.hpp>
00032 #include "Felt_File_Error.h"
00033
00034 namespace MetNoFelt {
00035 using namespace std;
00036
00041 struct ShortPairLess : public binary_function<const pair<short, short>, const pair<short, short>, bool>
00042 {
00043 bool operator()(const pair<short, short>& p1, const pair<short, short>& p2) {
00044 if (p1.first == p2.first) return p1.second < p2.second;
00045 return p1.first < p2.first;
00046 }
00047 };
00049 typedef set<pair<short,short>, ShortPairLess > ShortPairSet;
00050
00051
00053
00057 class Felt_Array
00058 {
00059 private:
00060 typedef map<time_t, boost::array<short, 4> > TIME_MAP;
00061 string feltArrayName;
00062 ShortPairSet levelPairs;
00063
00064 TIME_MAP times;
00065 map<time_t, map<short, int> > fieldSizeMap;
00066 int nx;
00067 int ny;
00068 long scaling_factor;
00069 int gridType;
00070 boost::array<short, 16> idx;
00071 boost::array<short, 20> header;
00072 boost::array<float, 6> gridParameters;
00073 string dataType;
00074 double fillValue;
00075
00076 public:
00078 Felt_Array();
00085 explicit Felt_Array(const string name, const boost::array<short, 16> idx, const string& dataType = "short");
00086 virtual ~Felt_Array();
00091 void addInformationByIndex(const boost::array<short, 16>& idx, int fieldSize) throw(Felt_File_Error);
00093 const boost::array<short, 16>& getIndexHeader() const {return idx;}
00094
00100 void setDataHeader(boost::array<short, 20> header) throw(Felt_File_Error);
00102 const boost::array<short, 20>& getDataHeader() const {return header;}
00103
00105 short getLevelType() const {return idx[10];}
00107 void setGridType(int gridType) {this->gridType = gridType;}
00109 int getGridType() const {return gridType;}
00113 void setGridParameters(boost::array<float, 6> gridParameters) {this->gridParameters = gridParameters;}
00115 const boost::array<float, 6>& getGridParameters() const {return gridParameters;}
00116
00118 const string& getName() const;
00120 const string& getDatatype() const {return dataType;}
00122 double getFillValue() const { return fillValue;}
00124 void setFillValue(double fillValue) {this->fillValue = fillValue;}
00126 vector<time_t> getTimes() const;
00128 vector<short> getLevels() const;
00132 vector<pair<short, short> > getLevelPairs() const;
00134 int getX() const {return header[9];}
00136 int getY() const {return header[10];}
00138 short getVerticalFeltType() const {return idx[10];}
00140 double getScalingFactor() const;
00141
00143 boost::array<short, 16> const getIndex(time_t time, short level) throw(Felt_File_Error);
00144 int getFieldSize(time_t time, short level) const throw (Felt_File_Error);
00145
00146 private:
00147 void testHeaderElement(short oldVal, short newVal, const std::string& msg) const throw(Felt_File_Error);
00148 };
00149
00150 }
00151 #endif