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

Generated by: LCOV version 1.14