File: MbzFile.h

package info (click to toggle)
zygrib 8.0.1%2Bdfsg.1-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 189,396 kB
  • ctags: 6,957
  • sloc: cpp: 59,202; makefile: 56
file content (88 lines) | stat: -rw-r--r-- 2,587 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**********************************************************************
zyGrib: meteorological GRIB file viewer
Copyright (C) 2008-2012 - Jacques Zaninetti - http://www.zygrib.org

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
***********************************************************************/

#ifndef MBZFILE_H
#define MBZFILE_H

#include "Util.h"
#include "zuFile.h"
#include "LongTaskProgress.h"

//------------------------------------------------------
class MButil
{
	public:
		static bool readInt8   (ZUFILE *f, int *val);
		static bool readInt16  (ZUFILE *f, int *val);
		static bool readInt32  (ZUFILE *f, int *val);
		static bool readFloat32  (ZUFILE *f, float *val);
		
		static bool getDateFromName (const char *fname, 
						  int*year, int*month, int*day, int*href, int*hour);
		static bool substring2int (int *val, const char *str,int start,int size);
		static bool readPosition  (char *line, float *x, float *y);
};

//------------------------------------------------------
class MbzLine
{
	public:
		float x, y;
		int   hour;
		std::vector <float> data;
		void print() const;
};

//---------------------------------------------------
// MBZfile : read a file in MBZ format
//---------------------------------------------------
class MbzFile
{
	public:
		MbzFile ()   
			{ ok = false; }
			
		MbzFile (const char *fname, LongTaskProgress *taskProgress);
		~MbzFile ();
		
		void read_MbzFile  (const char *fname, LongTaskProgress *taskProgress);

		int getDataCodeIndex (uint32_t code);
		int getDataCodeIndex (DataCode dtc)  {return getDataCodeIndex(dtc.toInt32());}
		
		bool isOk () const {return ok;}
		void debugmbz () const;
		
		int   year,month,day,href; 
		float xmin,xmax, ymin,ymax;
		
		std::vector <MbzLine*>  vlines;
		std::vector <uint32_t>  vcodes;		// DataCode
		
	private:
		bool  ok;
		int   version;
		int   nbData, nbLines;
		
		void read_header (ZUFILE *f);
		void read_data_codes  (ZUFILE *f);
		void read_data_lines  (ZUFILE *f, LongTaskProgress *taskProgress);
};


#endif