LCOV - code coverage report
Current view: top level - frmts/msgn - msg_reader_core.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 49 0.0 %
Date: 2024-04-27 17:22:41 Functions: 0 25 0.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  * $Id$
       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             : #include "cpl_vsi.h"
      36             : 
      37             : namespace msg_native_format
      38             : {
      39             : 
      40             : const unsigned int MSG_NUM_CHANNELS = 12;
      41             : 
      42             : typedef struct
      43             : {
      44             :     double vc;
      45             :     double A;
      46             :     double B;
      47             : } Blackbody_lut_type;
      48             : 
      49             : typedef enum
      50             : {
      51             :     VIS0_6 = 2,
      52             :     VIS0_8 = 4,
      53             :     NIR1_6 = 8,
      54             :     IR3_9 = 16,
      55             :     IR6_2 = 32,
      56             :     IR7_3 = 64,
      57             :     IR8_7 = 128,
      58             :     IR9_7 = 256,
      59             :     IR10_8 = 512,
      60             :     IR12_0 = 1024,
      61             :     IR13_4 = 2048,
      62             :     HRV = 4096
      63             : } Msg_channel_names;
      64             : 
      65             : class Msg_reader_core
      66             : {
      67             :   public:
      68             :     explicit Msg_reader_core(const char *fname);
      69             :     explicit Msg_reader_core(VSILFILE *fp);
      70             : 
      71           0 :     virtual ~Msg_reader_core()
      72           0 :     {
      73           0 :     }
      74             : 
      75           0 :     bool get_open_success() const
      76             :     {
      77           0 :         return _open_success;
      78             :     }
      79             : 
      80             : #ifndef GDAL_SUPPORT
      81             :     virtual void radiance_to_blackbody(
      82             :         int using_chan_no =
      83             :             0) = 0;  // can override which channel's parameters to use
      84             :     virtual double *get_data(int chan_no = 0) = 0;
      85             : #endif
      86             : 
      87           0 :     unsigned int get_lines() const
      88             :     {
      89           0 :         return _lines;
      90             :     }
      91             : 
      92           0 :     unsigned int get_columns() const
      93             :     {
      94           0 :         return _columns;
      95             :     }
      96             : 
      97             :     void get_pixel_geo_coordinates(unsigned int line, unsigned int column,
      98             :                                    double &longitude, double &latitude)
      99             :         const;  // x and y relative to this image, not full disc image
     100             :     void get_pixel_geo_coordinates(
     101             :         double line, double column, double &longitude,
     102             :         double
     103             :             &latitude);  // x and y relative to this image, not full disc image
     104             :     double compute_pixel_area_sqkm(double line, double column);
     105             : 
     106             :     static const Blackbody_lut_type Blackbody_LUT[MSG_NUM_CHANNELS + 1];
     107             : 
     108           0 :     unsigned int get_year() const
     109             :     {
     110           0 :         return _year;
     111             :     }
     112             : 
     113           0 :     unsigned int get_month() const
     114             :     {
     115           0 :         return _month;
     116             :     }
     117             : 
     118           0 :     unsigned int get_day() const
     119             :     {
     120           0 :         return _day;
     121             :     }
     122             : 
     123           0 :     unsigned int get_hour() const
     124             :     {
     125           0 :         return _hour;
     126             :     }
     127             : 
     128           0 :     unsigned int get_minute() const
     129             :     {
     130           0 :         return _minute;
     131             :     }
     132             : 
     133           0 :     unsigned int get_line_start() const
     134             :     {
     135           0 :         return _line_start;
     136             :     }
     137             : 
     138           0 :     unsigned int get_col_start() const
     139             :     {
     140           0 :         return _col_start;
     141             :     }
     142             : 
     143           0 :     float get_col_dir_step() const
     144             :     {
     145           0 :         return _col_dir_step;
     146             :     }
     147             : 
     148           0 :     float get_line_dir_step() const
     149             :     {
     150           0 :         return _line_dir_step;
     151             :     }
     152             : 
     153           0 :     float get_hrv_col_dir_step() const
     154             :     {
     155           0 :         return _hrv_col_dir_step;
     156             :     }
     157             : 
     158           0 :     float get_hrv_line_dir_step() const
     159             :     {
     160           0 :         return _hrv_line_dir_step;
     161             :     }
     162             : 
     163           0 :     unsigned int get_f_data_offset() const
     164             :     {
     165           0 :         return _f_data_offset;
     166             :     }
     167             : 
     168           0 :     unsigned int get_visir_bytes_per_line() const
     169             :     {
     170           0 :         return _visir_bytes_per_line;
     171             :     }
     172             : 
     173           0 :     unsigned int get_visir_packet_size() const
     174             :     {
     175           0 :         return _visir_packet_size;
     176             :     }
     177             : 
     178           0 :     unsigned int get_hrv_bytes_per_line() const
     179             :     {
     180           0 :         return _hrv_bytes_per_line;
     181             :     }
     182             : 
     183           0 :     unsigned int get_hrv_packet_size() const
     184             :     {
     185           0 :         return _hrv_packet_size;
     186             :     }
     187             : 
     188           0 :     unsigned int get_interline_spacing() const
     189             :     {
     190           0 :         return _interline_spacing;
     191             :     }
     192             : 
     193           0 :     const unsigned char *get_band_map() const
     194             :     {
     195           0 :         return _bands;
     196             :     }
     197             : 
     198           0 :     const CALIBRATION *get_calibration_parameters() const
     199             :     {
     200           0 :         return _calibration;
     201             :     }
     202             : 
     203           0 :     const IMAGE_DESCRIPTION_RECORD &get_image_description_record() const
     204             :     {
     205           0 :         return _img_desc_record;
     206             :     }
     207             : 
     208             :   private:
     209             :     void read_metadata_block(VSILFILE *fp);
     210             : 
     211             :   protected:
     212             :     static int _chan_to_idx(Msg_channel_names channel);
     213             : 
     214             :     unsigned int _lines;
     215             :     unsigned int _columns;
     216             : 
     217             :     unsigned int _line_start;
     218             :     unsigned int _col_start;
     219             : 
     220             :     float _col_dir_step;
     221             :     float _line_dir_step;
     222             :     float _hrv_col_dir_step;
     223             :     float _hrv_line_dir_step;
     224             : 
     225             :     MAIN_PROD_HEADER _main_header;
     226             :     SECONDARY_PROD_HEADER _sec_header;
     227             :     CALIBRATION _calibration[MSG_NUM_CHANNELS];
     228             :     IMAGE_DESCRIPTION_RECORD _img_desc_record;
     229             : 
     230             :     unsigned int _f_data_offset;
     231             :     unsigned int _f_data_size;
     232             :     unsigned int _f_header_offset;
     233             :     unsigned int _f_header_size;
     234             :     unsigned int _f_trailer_offset;
     235             :     unsigned int _f_trailer_size;
     236             : 
     237             :     unsigned int _visir_bytes_per_line;  // packed length of a VISIR line,
     238             :                                          // without headers
     239             :     unsigned int _visir_packet_size;  // effectively, the spacing between lines
     240             :                                       // of consecutive bands in bytes
     241             :     unsigned int _hrv_bytes_per_line;
     242             :     unsigned int _hrv_packet_size;
     243             :     unsigned int _interline_spacing;
     244             : 
     245             :     unsigned char _bands[MSG_NUM_CHANNELS];
     246             : 
     247             :     unsigned int _year;
     248             :     unsigned int _month;
     249             :     unsigned int _day;
     250             :     unsigned int _hour;
     251             :     unsigned int _minute;
     252             : 
     253             :     bool _open_success;
     254             : };
     255             : 
     256             : }  // namespace msg_native_format
     257             : 
     258             : #endif

Generated by: LCOV version 1.14