00001 /* 00002 wdb 00003 00004 Copyright (C) 2007 met.no 00005 00006 Contact information: 00007 Norwegian Meteorological Institute 00008 Box 43 Blindern 00009 0313 OSLO 00010 NORWAY 00011 E-mail: wdb@met.no 00012 00013 This program is free software; you can redistribute it and/or modify 00014 it under the terms of the GNU General Public License as published by 00015 the Free Software Foundation; either version 2 of the License, or 00016 (at your option) any later version. 00017 00018 This program is distributed in the hope that it will be useful, 00019 but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program; if not, write to the Free Software 00025 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00026 MA 02110-1301, USA 00027 */ 00028 #ifndef FELTFIELD_H_ 00029 #define FELTFIELD_H_ 00030 00031 #include "FeltConstants.h" 00032 #include "FeltGridDefinition.h" 00033 #include <boost/shared_array.hpp> 00034 #include <boost/array.hpp> 00035 #include <boost/date_time/posix_time/posix_time_types.hpp> 00036 #include <boost/noncopyable.hpp> 00037 #include <string> 00038 #include <vector> 00039 00040 namespace felt 00041 { 00042 00043 typedef boost::shared_ptr<FeltGridDefinition> FeltGridDefinitionPtr; 00044 00045 class FeltFile; 00046 00047 class FeltField : boost::noncopyable 00048 { 00049 public: 00050 typedef boost::array<word, 16> Header; 00051 00052 FeltField(const FeltFile & ff, size_t index); 00053 00054 ~FeltField(); 00055 00056 bool valid() const { return gridSize() != 0; } 00057 00058 int producer() const { return header_[0]; } 00059 int gridArea() const { return header_[1]; } 00060 00061 boost::posix_time::ptime referenceTime() const; 00062 boost::posix_time::ptime validTime() const; 00063 00064 int parameter() const { return header_[11]; } 00068 int dataType() const { return header_[8]; } 00069 00070 int verticalCoordinate() const { return header_[10]; } 00071 int level1() const {return header_[12]; } 00072 int level2() const {return header_[13]; } 00073 int gridType() const { return header_[14]; } 00074 00078 void grid(std::vector<word> & out) const; 00079 size_t gridSize() const; 00080 int scaleFactor() const; 00081 int xNum() const; 00082 int yNum() const; 00084 int miscField() const; 00085 00089 int dataVersion() const; 00090 00092 FeltGridDefinitionPtr projectionInformation() const; 00093 00094 std::string information() const; 00095 std::string gridInformation() const; 00096 00098 const Header& getHeader() const {return header_;} 00099 00100 private: 00101 00102 int timeParameter() const { return header_[9]; } 00103 00104 00108 bool isSane() const; 00109 00110 private: 00111 size_t startingGridBlock() const; 00112 00113 const std::vector<word> & getGridHeader_() const; 00114 const std::vector<word> & getExtraGeometrySpecification_() const; 00115 00116 mutable std::vector<word> gridHeader_; 00117 mutable std::vector<word> extraGridSpec_; 00118 Header header_; 00119 const FeltFile & feltFile_; 00120 size_t index_; 00121 }; 00122 00123 } 00124 00125 #endif /*FELTFIELD_H_*/