OpenCPN Partial API docs
Loading...
Searching...
No Matches
grib_v1_record.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***********************************************************************/
18
29#ifndef GRIBV1RECORD_H
30#define GRIBV1RECORD_H
31
32#include <iostream>
33#include <cmath>
34
35#include "zu_file.h"
36#include "grib_record.h"
37
38//----------------------------------------------
39class GribV1Record : public GribRecord {
40public:
41 GribV1Record(ZUFILE* file, int id_);
42 GribV1Record(const GribRecord& rec);
43 GribV1Record() = default;
44
45 ~GribV1Record() override;
46
47protected:
48private:
49 zuint periodSeconds(zuchar unit, zuchar P1, zuchar P2, zuchar range);
50 //-----------------------------------------
51 void translateDataType(); // adapte les codes des différents centres météo
52 //---------------------------------------------
53 // SECTION 0: THE INDICATOR SECTION (IS)
54 //---------------------------------------------
55 zuint fileOffset0;
56 zuint seekStart, totalSize;
57 // zuchar edition_number;
58 bool b_len_add_8;
59
60 // SECTION 1: THE PRODUCT DEFINITION SECTION (PDS)
61 zuint fileOffset1;
62 zuint sectionSize1;
63 zuchar tableVersion;
64 zuchar data1[28];
65 bool hasGDS;
66 // bool hasBMS;
67 double decimalFactorD;
68 // SECTION 2: THE GRID DESCRIPTION SECTION (GDS)
69 zuint fileOffset2;
70 zuint sectionSize2;
71 // SECTION 3: BIT MAP SECTION (BMS)
72 zuint fileOffset3;
73 zuint sectionSize3;
74 // zuchar *bms_bits;
75 // SECTION 4: BINARY DATA SECTION (BDS)
76 zuint fileOffset4;
77 zuint sectionSize4;
78 zuchar unusedBitsEndBDS;
79 bool isGridData; // not spherical harmonics
80 bool isSimplePacking;
81 bool isFloatValues;
82 int scaleFactorE;
83 double scaleFactorEpow2;
84 double refValue;
85 zuint nbBitsInPack;
86 // SECTION 5: END SECTION (ES)
87
88 //---------------------------------------------
89 // Data Access
90 //---------------------------------------------
91 bool readGribSection0_IS(ZUFILE* file, unsigned int b_skip_initial_GRIB);
92 bool readGribSection1_PDS(ZUFILE* file);
93 bool readGribSection2_GDS(ZUFILE* file);
94 bool readGribSection3_BMS(ZUFILE* file);
95 bool readGribSection4_BDS(ZUFILE* file);
96 bool readGribSection5_ES(ZUFILE* file);
97
98 //---------------------------------------------
99 // Utility functions
100 //---------------------------------------------
101 zuchar readChar(ZUFILE* file);
102 int readSignedInt3(ZUFILE* file);
103 int readSignedInt2(ZUFILE* file);
104 zuint readInt2(ZUFILE* file);
105 zuint readInt3(ZUFILE* file);
106 double readFloat4(ZUFILE* file);
107
108 zuint makeInt3(zuchar a, zuchar b, zuchar c);
109 zuint makeInt2(zuchar b, zuchar c);
110
111 // void print();
112};
113
114#endif
A meteorological data grid from a GRIB (Gridded Binary) file.
GRIB Record Base Class Implementation.
Unified Compressed File Access System.