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

Generated by: LCOV version 1.14