1 : /******************************************************************************
2 : * $Id: msg_reader_core.h 11698 2007-06-25 16:33:06Z warmerdam $
3 : *
4 : * Project: MSG Native Reader
5 : * Purpose: Base class for reading in the headers of MSG native images
6 : * Author: Frans van den Bergh, fvdbergh@csir.co.za
7 : *
8 : ******************************************************************************
9 : * Copyright (c) 2005, Frans van den Bergh <fvdbergh@csir.co.za>
10 : *
11 : * Permission is hereby granted, free of charge, to any person obtaining a
12 : * copy of this software and associated documentation files (the "Software"),
13 : * to deal in the Software without restriction, including without limitation
14 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 : * and/or sell copies of the Software, and to permit persons to whom the
16 : * Software is furnished to do so, subject to the following conditions:
17 : *
18 : * The above copyright notice and this permission notice shall be included
19 : * in all copies or substantial portions of the Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 : * DEALINGS IN THE SOFTWARE.
28 : ****************************************************************************/
29 :
30 : #ifndef MSG_READER_CORE_H
31 : #define MSG_READER_CORE_H
32 :
33 : #include "msg_basic_types.h"
34 : #include <stdio.h>
35 :
36 : namespace msg_native_format {
37 :
38 : const unsigned int MSG_NUM_CHANNELS = 12;
39 :
40 : typedef struct {
41 : double vc;
42 : double A;
43 : double B;
44 : } Blackbody_lut_type;
45 :
46 : typedef enum {
47 : VIS0_6 = 2,
48 : VIS0_8 = 4,
49 : NIR1_6 = 8,
50 : IR3_9 = 16,
51 : IR6_2 = 32,
52 : IR7_3 = 64,
53 : IR8_7 = 128,
54 : IR9_7 = 256,
55 : IR10_8 = 512,
56 : IR12_0 = 1024,
57 : IR13_4 = 2048,
58 : HRV = 4096
59 : } Msg_channel_names;
60 :
61 : class Msg_reader_core {
62 : public:
63 : Msg_reader_core(const char* fname);
64 : Msg_reader_core(FILE* fp);
65 0 : virtual ~Msg_reader_core(void) {};
66 :
67 0 : bool get_open_success(void) { return _open_success; }
68 :
69 : #ifndef GDAL_SUPPORT
70 : virtual void radiance_to_blackbody(int using_chan_no = 0) = 0; // can override which channel's parameters to use
71 : virtual double* get_data(int chan_no=0) = 0;
72 : #endif
73 :
74 0 : unsigned int get_lines(void) { return _lines; }
75 0 : unsigned int get_columns(void) { return _columns; }
76 :
77 : void get_pixel_geo_coordinates(unsigned int line, unsigned int column, double& longitude, double& latitude); // x and y relative to this image, not full disc image
78 : void get_pixel_geo_coordinates(double line, double column, double& longitude, double& latitude); // x and y relative to this image, not full disc image
79 : double compute_pixel_area_sqkm(double line, double column);
80 :
81 : static const Blackbody_lut_type Blackbody_LUT[MSG_NUM_CHANNELS+1];
82 :
83 0 : unsigned int get_year(void) { return _year; }
84 0 : unsigned int get_month(void) { return _month; }
85 0 : unsigned int get_day(void) { return _day; }
86 0 : unsigned int get_hour(void) { return _hour; }
87 0 : unsigned int get_minute(void) { return _minute; }
88 :
89 0 : unsigned int get_line_start(void) { return _line_start; }
90 0 : unsigned int get_col_start(void) { return _col_start; }
91 :
92 0 : float get_col_dir_step(void) { return _col_dir_step; }
93 0 : float get_line_dir_step(void) { return _line_dir_step; }
94 :
95 0 : unsigned int get_f_data_offset(void) { return _f_data_offset; }
96 0 : unsigned int get_visir_bytes_per_line(void) { return _visir_bytes_per_line; }
97 0 : unsigned int get_visir_packet_size(void) { return _visir_packet_size; }
98 0 : unsigned int get_hrv_bytes_per_line(void) { return _hrv_bytes_per_line; }
99 0 : unsigned int get_hrv_packet_size(void) { return _hrv_packet_size; }
100 0 : unsigned int get_interline_spacing(void) { return _interline_spacing; }
101 :
102 0 : unsigned char* get_band_map(void) { return _bands; }
103 :
104 0 : CALIBRATION* get_calibration_parameters(void) { return _calibration; }
105 :
106 : private:
107 : void read_metadata_block(FILE* fp);
108 :
109 : protected:
110 :
111 : int _chan_to_idx(Msg_channel_names channel);
112 :
113 : unsigned int _lines;
114 : unsigned int _columns;
115 :
116 : unsigned int _line_start;
117 : unsigned int _col_start;
118 :
119 : float _col_dir_step;
120 : float _line_dir_step;
121 :
122 : MAIN_PROD_HEADER _main_header;
123 : SECONDARY_PROD_HEADER _sec_header;
124 : CALIBRATION _calibration[MSG_NUM_CHANNELS];
125 :
126 : unsigned int _f_data_offset;
127 : unsigned int _f_data_size;
128 : unsigned int _f_header_offset;
129 : unsigned int _f_header_size;
130 :
131 : unsigned int _visir_bytes_per_line; // packed length of a VISIR line, without headers
132 : unsigned int _visir_packet_size; // effectively, the spacing between lines of consecutive bands in bytes
133 : unsigned int _hrv_bytes_per_line;
134 : unsigned int _hrv_packet_size;
135 : unsigned int _interline_spacing;
136 :
137 : unsigned char _bands[MSG_NUM_CHANNELS];
138 :
139 : unsigned int _year;
140 : unsigned int _month;
141 : unsigned int _day;
142 : unsigned int _hour;
143 : unsigned int _minute;
144 :
145 : bool _open_success;
146 : };
147 :
148 : }// namespace msg_native_format
149 :
150 : #endif
151 :
|