OpenCPN Partial API docs
Loading...
Searching...
No Matches
GribReader.h
Go to the documentation of this file.
1/**********************************************************************
2zyGrib: meteorological GRIB file viewer
3Copyright (C) 2008 - Jacques Zaninetti - http://www.zygrib.org
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 3 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17***********************************************************************/
34#ifndef GRIBREADER_H
35#define GRIBREADER_H
36
37#include "wx/wxprec.h"
38
39#ifndef WX_PRECOMP
40#include "wx/wx.h"
41#endif // precompiled headers
42
43#include <iostream>
44#include <cmath>
45#include <vector>
46#include <set>
47#include <map>
48
49#include "GribRecord.h"
50#include "zuFile.h"
51
52//===============================================================
54public:
55 GribReader();
56 GribReader(const wxString fname);
58
59 void openFile(const wxString fname);
60 bool isOk() { return ok; }
61 long getFileSize() { return fileSize; }
62 wxString getFileName() { return fileName; }
63
64 int getNumberOfGribRecords(int dataType, int levelType, int levelValue);
65 int getTotalNumberOfGribRecords();
66
67 GribRecord *getGribRecord(int dataType, int levelType, int levelValue,
68 time_t date);
69
70 GribRecord *getFirstGribRecord();
71 GribRecord *getFirstGribRecord(int dataType, int levelType, int levelValue);
72
73 std::vector<GribRecord *> *getListOfGribRecords(int dataType, int levelType,
74 int levelValue);
75
76 // double getHoursBeetweenGribRecords() {return
77 // hoursBetweenRecords;}
78 std::set<time_t> getListDates() { return setAllDates; }
79 int getNumberOfDates() { return setAllDates.size(); }
80 time_t getRefDate() {
81 return setAllDates.size() > 0 ? *setAllDates.begin() : 0;
82 }
83
84 // Valeur pour un point et une date quelconques
85 double getTimeInterpolatedValue(int dataType, int levelType, int levelValue,
86 double px, double py, time_t date);
87
88 // Crée un GribRecord interpolé
89 GribRecord *getTimeInterpolatedGribRecord(int dataType, int levelType,
90 int levelValue, time_t date);
91
92 double computeDewPoint(double lon, double lat, time_t date);
93
94 int getDewpointDataStatus(int levelType, int levelValue);
95
96 enum GribFileDataStatus { DATA_IN_FILE, NO_DATA_IN_FILE, COMPUTED_DATA };
97
106 // void removeFirstCumulativeRecord ();
116 void copyFirstCumulativeRecord(int dataType, int levelType, int levelValue);
117 // void removeFirstCumulativeRecord (int dataType,int levelType,int
118 // levelValue);
119 void copyMissingWaveRecords(int dataType, int levelType, int levelValue);
120
121 void computeAccumulationRecords(int dataType, int levelType, int levelValue);
122
123 std::map<std::string, std::vector<GribRecord *> *> *getGribMap() {
124 return &mapGribRecords;
125 } // dsr
126
127private:
128 bool ok;
129 wxString fileName;
130 ZUFILE *file;
131 long fileSize;
132 // double hoursBetweenRecords;
133 int dewpointDataStatus;
134
135 std::map<std::string, std::vector<GribRecord *> *> mapGribRecords;
136
137 void storeRecordInMap(GribRecord *rec);
138
139 void readGribFileContent();
140 void readAllGribRecords();
141 void createListDates();
142 double computeHoursBeetweenGribRecords();
143 std::set<time_t> setAllDates;
144
145 void clean_vector(std::vector<GribRecord *> &ls);
146 void clean_all_vectors();
147 std::vector<GribRecord *> *getFirstNonEmptyList();
148
149 // Interpolation between 2 GribRecord
150 double get2GribsInterpolatedValueByDate(double px, double py, time_t date,
151 GribRecord *before,
152 GribRecord *after);
153
154 // Détermine les GribRecord qui encadrent une date
155 void findGribsAroundDate(int dataType, int levelType, int levelValue,
156 time_t date, GribRecord **before,
157 GribRecord **after);
158};
159
160#endif
GRIB Record Base Class Implementation.
void copyMissingWaveRecords()
Fills gaps in wave-related data fields by propagating known values across missing time periods.
void copyFirstCumulativeRecord()
Initializes cumulative meteorological parameters by copying their first record values.
Represents a meteorological data grid from a GRIB (Gridded Binary) file.
Definition GribRecord.h:182
Unified Compressed File Access System.