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: 2025-02-20 10:14:44 Functions: 0 25 0.0 %

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

Generated by: LCOV version 1.14