LCOV - code coverage report
Current view: top level - frmts/msgn - msg_reader_core.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 0 189 0.0 %
Date: 2024-11-21 22:18:42 Functions: 0 5 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             : #include "cpl_port.h"
      14             : #include "cpl_error.h"
      15             : 
      16             : #include "msg_reader_core.h"
      17             : #include "msg_basic_types.h"
      18             : #include <stdio.h>
      19             : #include <string.h>
      20             : #include <math.h>
      21             : 
      22             : #ifdef DEBUG
      23             : #ifdef GDAL_SUPPORT
      24             : #undef DEBUG
      25             : #endif
      26             : #endif
      27             : 
      28             : #ifdef GDAL_SUPPORT
      29             : #include "cpl_vsi.h"
      30             : 
      31             : #else
      32             : #define VSIFSeek(fp, pos, ref) CPL_IGNORE_RET_VAL(fseek(fp, pos, ref))
      33             : #define VSIFRead(p, bs, nb, fp) CPL_IGNORE_RET_VAL(fread(p, bs, nb, fp))
      34             : #endif
      35             : 
      36             : namespace msg_native_format
      37             : {
      38             : 
      39             : const Blackbody_lut_type Msg_reader_core::Blackbody_LUT[MSG_NUM_CHANNELS + 1] =
      40             :     {
      41             :         {0, 0, 0},  // dummy channel
      42             :         {0, 0, 0},  // N/A
      43             :         {0, 0, 0},  // N/A
      44             :         {0, 0, 0},  // N/A
      45             :         {2569.094, 0.9959, 3.471},
      46             :         {1598.566, 0.9963, 2.219},
      47             :         {1362.142, 0.9991, 0.485},
      48             :         {1149.083, 0.9996, 0.181},
      49             :         {1034.345, 0.9999, 0.060},
      50             :         {930.659, 0.9983, 0.627},
      51             :         {839.661, 0.9988, 0.397},
      52             :         {752.381, 0.9981, 0.576},
      53             :         {0, 0, 0}  // N/A
      54             : };
      55             : 
      56           0 : static void PhDataInit(PH_DATA *data)
      57             : {
      58           0 :     data->name[0] = '\0';
      59           0 :     data->value[0] = '\0';
      60           0 : }
      61             : 
      62           0 : static void SecondaryProdHeaderInit(SECONDARY_PROD_HEADER *header)
      63             : {
      64           0 :     PhDataInit(&header->abid);
      65           0 :     PhDataInit(&header->smod);
      66           0 :     PhDataInit(&header->apxs);
      67           0 :     PhDataInit(&header->avpa);
      68           0 :     PhDataInit(&header->lscd);
      69           0 :     PhDataInit(&header->lmap);
      70           0 :     PhDataInit(&header->qdlc);
      71           0 :     PhDataInit(&header->qdlp);
      72           0 :     PhDataInit(&header->qqai);
      73           0 :     PhDataInit(&header->selectedBandIds);
      74           0 :     PhDataInit(&header->southLineSelectedRectangle);
      75           0 :     PhDataInit(&header->northLineSelectedRectangle);
      76           0 :     PhDataInit(&header->eastColumnSelectedRectangle);
      77           0 :     PhDataInit(&header->westColumnSelectedRectangle);
      78           0 : }
      79             : 
      80           0 : Msg_reader_core::Msg_reader_core(const char *fname)
      81             :     : _lines(0), _columns(0), _line_start(0), _col_start(0),
      82             :       _col_dir_step(0.0f), _line_dir_step(0.0f), _hrv_col_dir_step(0.0f),
      83             :       _hrv_line_dir_step(0.0f), _f_data_offset(0), _f_data_size(0),
      84             :       _f_header_offset(0), _f_header_size(0), _f_trailer_offset(0),
      85             :       _f_trailer_size(0), _visir_bytes_per_line(0), _visir_packet_size(0),
      86             :       _hrv_bytes_per_line(0), _hrv_packet_size(0), _interline_spacing(0),
      87           0 :       _year(0), _month(0), _day(0), _hour(0), _minute(0), _open_success(false)
      88             : {
      89           0 :     memset(&_main_header, 0, sizeof(_main_header));
      90           0 :     memset(&_sec_header, 0, sizeof(_sec_header));
      91           0 :     SecondaryProdHeaderInit(&_sec_header);
      92           0 :     for (size_t i = 0; i < MSG_NUM_CHANNELS; ++i)
      93             :     {
      94           0 :         _calibration[i].cal_slope = 0.0;
      95           0 :         _calibration[i].cal_offset = 0.0;
      96             :     }
      97           0 :     memset(&_img_desc_record, 0, sizeof(_img_desc_record));
      98             : 
      99           0 :     VSILFILE *fin = VSIFOpenL(fname, "rb");
     100           0 :     if (!fin)
     101             :     {
     102           0 :         CPLError(CE_Failure, CPLE_OpenFailed, "Could not open file %s", fname);
     103           0 :         return;
     104             :     }
     105           0 :     read_metadata_block(fin);
     106           0 :     VSIFCloseL(fin);
     107             : }
     108             : 
     109           0 : Msg_reader_core::Msg_reader_core(VSILFILE *fp)
     110             :     : _lines(0), _columns(0), _line_start(0), _col_start(0),
     111             :       _col_dir_step(0.0f), _line_dir_step(0.0f), _hrv_col_dir_step(0.0f),
     112             :       _hrv_line_dir_step(0.0f), _f_data_offset(0), _f_data_size(0),
     113             :       _f_header_offset(0), _f_header_size(0), _f_trailer_offset(0),
     114             :       _f_trailer_size(0), _visir_bytes_per_line(0), _visir_packet_size(0),
     115             :       _hrv_bytes_per_line(0), _hrv_packet_size(0), _interline_spacing(0),
     116           0 :       _year(0), _month(0), _day(0), _hour(0), _minute(0), _open_success(false)
     117             : {
     118           0 :     memset(&_main_header, 0, sizeof(_main_header));
     119           0 :     memset(&_sec_header, 0, sizeof(_sec_header));
     120             : 
     121           0 :     SecondaryProdHeaderInit(&_sec_header);
     122           0 :     for (size_t i = 0; i < MSG_NUM_CHANNELS; ++i)
     123             :     {
     124           0 :         _calibration[i].cal_slope = 0.0;
     125           0 :         _calibration[i].cal_offset = 0.0;
     126             :     }
     127           0 :     memset(&_img_desc_record, 0, sizeof(_img_desc_record));
     128             : 
     129           0 :     read_metadata_block(fp);
     130           0 : }
     131             : 
     132           0 : void Msg_reader_core::read_metadata_block(VSILFILE *fin)
     133             : {
     134           0 :     _open_success = true;
     135             : 
     136             :     unsigned int i;
     137             : 
     138           0 :     CPL_IGNORE_RET_VAL(VSIFReadL(&_main_header, sizeof(_main_header), 1, fin));
     139           0 :     CPL_IGNORE_RET_VAL(VSIFReadL(&_sec_header, sizeof(_sec_header), 1, fin));
     140             : 
     141             :     PH_DATA_ID *hdi;
     142             : 
     143             : #ifdef DEBUG
     144             :     // print out all the fields in the header
     145             :     PH_DATA *hd = (PH_DATA *)&_main_header;
     146             :     for (i = 0; i < 6; i++)
     147             :     {
     148             :         to_string(*hd);
     149             :         printf("[%02u] %s %s", i, hd->name, hd->value); /*ok*/
     150             :         hd++;
     151             :     }
     152             : 
     153             :     hdi = (PH_DATA_ID *)&_main_header.dataSetIdentification;
     154             :     for (i = 0; i < 5; i++)
     155             :     {
     156             :         printf("%s %s %s", hdi->name, hdi->size, hdi->address); /*ok*/
     157             :         hdi++;
     158             :     }
     159             : 
     160             :     hd = (PH_DATA *)(&_main_header.totalFileSize);
     161             :     for (i = 0; i < 19; i++)
     162             :     {
     163             :         to_string(*hd);
     164             :         printf("[%02u] %s %s", i, hd->name, hd->value); /*ok*/
     165             :         hd++;
     166             :     }
     167             : #endif  // DEBUG
     168             : 
     169             :     // extract data & header positions
     170             : 
     171           0 :     for (i = 0; i < 5; i++)
     172             :     {
     173           0 :         hdi = (PH_DATA_ID *)&_main_header.dataSetIdentification[i];
     174           0 :         if (STARTS_WITH(hdi->name, "15Header"))
     175             :         {
     176           0 :             sscanf(hdi->size, "%u", &_f_header_size);
     177           0 :             sscanf(hdi->address, "%u", &_f_header_offset);
     178             :         }
     179           0 :         else if (STARTS_WITH(hdi->name, "15Trailer"))
     180             :         {
     181           0 :             sscanf(hdi->size, "%u", &_f_trailer_size);
     182           0 :             sscanf(hdi->address, "%u", &_f_trailer_offset);
     183             :         }
     184           0 :         else if (STARTS_WITH(hdi->name, "15Data"))
     185             :         {
     186           0 :             sscanf(hdi->size, "%u", &_f_data_size);
     187           0 :             sscanf(hdi->address, "%u", &_f_data_offset);
     188             :         }
     189             :     }
     190             : #ifdef DEBUG
     191             :     printf("Data: %u %u\n", _f_data_offset, _f_data_size);          /*ok*/
     192             :     printf("Header: %u %u\n", _f_header_offset, _f_header_size);    /*ok*/
     193             :     printf("Trailer: %u %u\n", _f_trailer_offset, _f_trailer_size); /*ok*/
     194             : #endif                                                              // DEBUG
     195             : 
     196             :     unsigned int lines;
     197           0 :     sscanf(_sec_header.northLineSelectedRectangle.value, "%u", &_lines);
     198           0 :     sscanf(_sec_header.southLineSelectedRectangle.value, "%u", &lines);
     199           0 :     _line_start = lines;
     200           0 :     if (lines > 0 &&
     201           0 :         _lines >=
     202           0 :             lines -
     203             :                 1)  // if starting N of S edge, _lines counts what's there...
     204           0 :         _lines -= lines - 1;
     205             : 
     206             :     unsigned int cols;
     207           0 :     sscanf(_sec_header.westColumnSelectedRectangle.value, "%u", &_columns);
     208           0 :     sscanf(_sec_header.eastColumnSelectedRectangle.value, "%u", &cols);
     209           0 :     _col_start = cols;
     210           0 :     if (cols > 0 &&
     211           0 :         _columns >=
     212           0 :             cols - 1)  // if starting W of the E edge, _cols counts what's there
     213           0 :         _columns -= cols - 1;
     214             : 
     215             : #ifdef DEBUG
     216             :     printf("lines = %u, cols = %u\n", _lines, _columns); /*ok*/
     217             :     int records_per_line = 0;
     218             : #endif  // DEBUG
     219             : 
     220           0 :     for (i = 0; i < MSG_NUM_CHANNELS; i++)
     221             :     {
     222           0 :         if (_sec_header.selectedBandIds.value[i] == 'X')
     223             :         {
     224           0 :             _bands[i] = 1;
     225             : #ifdef DEBUG
     226             :             records_per_line += (i == (MSG_NUM_CHANNELS - 1)) ? 3 : 1;
     227             : #endif  // DEBUG
     228             :         }
     229             :         else
     230             :         {
     231           0 :             _bands[i] = 0;
     232             :         }
     233             :     }
     234             : 
     235             : #ifdef DEBUG
     236             :     printf("reading a total of %d records per line\n", records_per_line); /*ok*/
     237             : #endif  // DEBUG
     238             : 
     239             :     // extract time fields, assume that SNIT is the correct field:
     240           0 :     sscanf(_main_header.snit.value + 0, "%04u", &_year);
     241           0 :     sscanf(_main_header.snit.value + 4, "%02u", &_month);
     242           0 :     sscanf(_main_header.snit.value + 6, "%02u", &_day);
     243           0 :     sscanf(_main_header.snit.value + 8, "%02u", &_hour);
     244           0 :     sscanf(_main_header.snit.value + 10, "%02u", &_minute);
     245             : 
     246             :     // read radiometric block
     247             :     RADIOMETRIC_PROCESSING_RECORD rad;
     248           0 :     off_t offset = RADIOMETRICPROCESSING_RECORD_OFFSET + _f_header_offset +
     249           0 :                    sizeof(GP_PK_HEADER) + sizeof(GP_PK_SH1) + 1;
     250           0 :     CPL_IGNORE_RET_VAL(VSIFSeekL(fin, offset, SEEK_SET));
     251           0 :     CPL_IGNORE_RET_VAL(
     252           0 :         VSIFReadL(&rad, sizeof(RADIOMETRIC_PROCESSING_RECORD), 1, fin));
     253           0 :     to_native(rad);
     254           0 :     memcpy((void *)_calibration, (void *)&rad.level1_5ImageCalibration,
     255             :            sizeof(_calibration));
     256             : 
     257             : #ifdef DEBUG
     258             :     for (i = 0; i < MSG_NUM_CHANNELS; i++)
     259             :     {
     260             :         if (_calibration[i].cal_slope < 0 || _calibration[i].cal_slope > 0.4)
     261             :         {
     262             :             printf(/*ok*/ "Warning: calibration slope (%f) out of nominal "
     263             :                           "range. MSG "
     264             :                           "reader probably broken\n",
     265             :                    _calibration[i].cal_slope);
     266             :         }
     267             :         if (_calibration[i].cal_offset > 0 || _calibration[i].cal_offset < -20)
     268             :         {
     269             :             printf(/*ok*/ "Warning: calibration offset (%f) out of nominal "
     270             :                           "range. MSG "
     271             :                           "reader probably broken\n",
     272             :                    _calibration[i].cal_offset);
     273             :         }
     274             :     }
     275             : #endif
     276             : 
     277             :     // read image description block
     278           0 :     IMAGE_DESCRIPTION_RECORD &idr = _img_desc_record;
     279           0 :     offset = RADIOMETRICPROCESSING_RECORD_OFFSET -
     280           0 :              IMAGEDESCRIPTION_RECORD_LENGTH + _f_header_offset +
     281           0 :              sizeof(GP_PK_HEADER) + sizeof(GP_PK_SH1) + 1;
     282           0 :     CPL_IGNORE_RET_VAL(VSIFSeekL(fin, offset, SEEK_SET));
     283           0 :     CPL_IGNORE_RET_VAL(
     284           0 :         VSIFReadL(&idr, sizeof(IMAGE_DESCRIPTION_RECORD), 1, fin));
     285           0 :     to_native(idr);
     286           0 :     CPLDebugOnly("MSGN", "idr.longitudeOfSSP = %g", idr.longitudeOfSSP);
     287           0 :     CPLDebugOnly("MSGN",
     288             :                  "referencegrid_visir.numberOfLines = %d, "
     289             :                  "referencegrid_visir.numberOfColumns = %d",
     290             :                  idr.referencegrid_visir.numberOfLines,
     291             :                  idr.referencegrid_visir.numberOfColumns);
     292           0 :     _line_dir_step = idr.referencegrid_visir.lineDirGridStep;
     293           0 :     _col_dir_step = idr.referencegrid_visir.columnDirGridStep;
     294           0 :     _hrv_line_dir_step = idr.referencegrid_hrv.lineDirGridStep;
     295           0 :     _hrv_col_dir_step = idr.referencegrid_hrv.columnDirGridStep;
     296             : 
     297           0 :     CPLDebugOnly("MSGN",
     298             :                  "referencegrid_hrv.numberOfLines = %d, "
     299             :                  "referencegrid_hrv.numberOfColumns = %d",
     300             :                  idr.referencegrid_hrv.numberOfLines,
     301             :                  idr.referencegrid_hrv.numberOfColumns);
     302             : 
     303           0 :     CPLDebugOnly("MSGN",
     304             :                  "plannedCoverage_hrv.lowerSouthLinePlanned = %d, \n"
     305             :                  "plannedCoverage_hrv.lowerNorthLinePlanned = %d, \n"
     306             :                  "plannedCoverage_hrv.lowerEastColumnPlanned = %d, \n "
     307             :                  "plannedCoverage_hrv.lowerWestColumnPlanned = %d",
     308             :                  idr.plannedCoverage_hrv.lowerSouthLinePlanned,
     309             :                  idr.plannedCoverage_hrv.lowerNorthLinePlanned,
     310             :                  idr.plannedCoverage_hrv.lowerEastColumnPlanned,
     311             :                  idr.plannedCoverage_hrv.lowerWestColumnPlanned);
     312             : 
     313           0 :     CPLDebugOnly("MSGN",
     314             :                  "plannedCoverage_hrv.upperSouthLinePlanned = %d, \n"
     315             :                  "plannedCoverage_hrv.upperNorthLinePlanned = %d, \n"
     316             :                  "plannedCoverage_hrv.upperEastColumnPlanned = %d, \n "
     317             :                  "plannedCoverage_hrv.upperWestColumnPlanned = %d",
     318             :                  idr.plannedCoverage_hrv.upperSouthLinePlanned,
     319             :                  idr.plannedCoverage_hrv.upperNorthLinePlanned,
     320             :                  idr.plannedCoverage_hrv.upperEastColumnPlanned,
     321             :                  idr.plannedCoverage_hrv.upperWestColumnPlanned);
     322             : 
     323             :     // Rather convoluted, but this code is required to compute the real data
     324             :     // block sizes It does this by reading in the first line of every band, to
     325             :     // get to the packet size field
     326             :     GP_PK_HEADER gp_header;
     327             :     GP_PK_SH1 sub_header;
     328             :     SUB_VISIRLINE visir_line;
     329             : 
     330           0 :     CPL_IGNORE_RET_VAL(VSIFSeekL(fin, _f_data_offset, SEEK_SET));
     331             : 
     332           0 :     _hrv_packet_size = 0;
     333           0 :     _interline_spacing = 0;
     334           0 :     visir_line.channelId = 0;
     335             : 
     336             :     int scanned_bands[MSG_NUM_CHANNELS];
     337           0 :     int band_count = 0;
     338           0 :     for (i = 0; i < MSG_NUM_CHANNELS; i++)
     339             :     {
     340           0 :         scanned_bands[i] = _bands[i];
     341           0 :         band_count += _bands[i];
     342             :     }
     343             : 
     344           0 :     do
     345             :     {
     346           0 :         if (VSIFReadL(&gp_header, sizeof(GP_PK_HEADER), 1, fin) != 1 ||
     347           0 :             VSIFReadL(&sub_header, sizeof(GP_PK_SH1), 1, fin) != 1 ||
     348           0 :             VSIFReadL(&visir_line, sizeof(SUB_VISIRLINE), 1, fin) != 1)
     349             :         {
     350           0 :             _open_success = false;
     351           0 :             break;
     352             :         }
     353           0 :         to_native(visir_line);
     354           0 :         to_native(gp_header);
     355             : 
     356           0 :         CPLDebugOnly("MSGN",
     357             :                      "channelId = %d, lineNumber = %d, packetLength = %u",
     358             :                      visir_line.channelId, visir_line.lineNumberInVisirGrid,
     359             :                      gp_header.packetLength);
     360             : 
     361           0 :         to_native(sub_header);
     362             : 
     363           0 :         CPLDebugOnly("MSGN",
     364             :                      "subheader spacecraft  = %d,  day = %u, sec = %.3f",
     365             :                      sub_header.spacecraftId, sub_header.packetTime.day,
     366             :                      sub_header.packetTime.ms / 1000.0);
     367             : 
     368             :         // Sanity checks
     369           0 :         if (gp_header.packetLength <
     370           0 :                 sizeof(GP_PK_SH1) + sizeof(SUB_VISIRLINE) - 1 ||
     371           0 :             gp_header.packetLength > 100 * 1024 * 1024)
     372             :         {
     373           0 :             _open_success = false;
     374           0 :             break;
     375             :         }
     376             : 
     377             :         // skip over the actual line data
     378           0 :         CPL_IGNORE_RET_VAL(
     379           0 :             VSIFSeekL(fin,
     380           0 :                       gp_header.packetLength -
     381             :                           (sizeof(GP_PK_SH1) + sizeof(SUB_VISIRLINE) - 1),
     382             :                       SEEK_CUR));
     383             : 
     384           0 :         if (visir_line.channelId == 0 ||
     385           0 :             visir_line.channelId > MSG_NUM_CHANNELS)
     386             :         {
     387           0 :             _open_success = false;
     388           0 :             break;
     389             :         }
     390             : 
     391           0 :         if (scanned_bands[visir_line.channelId - 1])
     392             :         {
     393           0 :             scanned_bands[visir_line.channelId - 1] = 0;
     394           0 :             band_count--;
     395             : 
     396           0 :             if (visir_line.channelId != 12)
     397             :             {  // not the HRV channel
     398           0 :                 _visir_bytes_per_line =
     399           0 :                     gp_header.packetLength -
     400             :                     (unsigned int)(sizeof(GP_PK_SH1) + sizeof(SUB_VISIRLINE) -
     401             :                                    1);
     402           0 :                 _visir_packet_size = gp_header.packetLength +
     403           0 :                                      (unsigned int)sizeof(GP_PK_HEADER) + 1;
     404           0 :                 _interline_spacing += _visir_packet_size;
     405             :             }
     406             :             else
     407             :             {
     408           0 :                 _hrv_bytes_per_line = gp_header.packetLength -
     409             :                                       (unsigned int)(sizeof(GP_PK_SH1) +
     410             :                                                      sizeof(SUB_VISIRLINE) - 1);
     411           0 :                 _hrv_packet_size = gp_header.packetLength +
     412           0 :                                    (unsigned int)sizeof(GP_PK_HEADER) + 1;
     413           0 :                 _interline_spacing += _hrv_packet_size;
     414             : 
     415             :                 // The HRV channel has 3 consecutive lines
     416           0 :                 const int lineNumberInVisirGrid =
     417             :                     visir_line.lineNumberInVisirGrid;
     418           0 :                 const auto packetLength = gp_header.packetLength;
     419           0 :                 for (int extraLines = 0; extraLines < 2; extraLines++)
     420             :                 {
     421           0 :                     if (VSIFReadL(&gp_header, sizeof(GP_PK_HEADER), 1, fin) !=
     422           0 :                             1 ||
     423           0 :                         VSIFReadL(&sub_header, sizeof(GP_PK_SH1), 1, fin) !=
     424           0 :                             1 ||
     425           0 :                         VSIFReadL(&visir_line, sizeof(SUB_VISIRLINE), 1, fin) !=
     426             :                             1)
     427             :                     {
     428           0 :                         _open_success = false;
     429           0 :                         return;
     430             :                     }
     431           0 :                     to_native(visir_line);
     432           0 :                     to_native(gp_header);
     433             : 
     434           0 :                     CPLDebugOnly(
     435             :                         "MSGN",
     436             :                         "channelId = %d, lineNumber = %d, packetLength = %u",
     437             :                         visir_line.channelId, visir_line.lineNumberInVisirGrid,
     438             :                         gp_header.packetLength);
     439             : 
     440           0 :                     if (visir_line.channelId != 12 ||
     441           0 :                         visir_line.lineNumberInVisirGrid !=
     442           0 :                             lineNumberInVisirGrid + extraLines + 1 ||
     443           0 :                         gp_header.packetLength != packetLength)
     444             :                     {
     445           0 :                         CPLDebugOnly("MSGN", "Inconsistent records");
     446           0 :                         _open_success = false;
     447           0 :                         return;
     448             :                     }
     449             : 
     450             :                     // skip over the actual line data
     451           0 :                     CPL_IGNORE_RET_VAL(VSIFSeekL(
     452             :                         fin,
     453           0 :                         gp_header.packetLength -
     454             :                             (sizeof(GP_PK_SH1) + sizeof(SUB_VISIRLINE) - 1),
     455             :                         SEEK_CUR));
     456             : 
     457           0 :                     _interline_spacing += _hrv_packet_size;
     458             :                 }
     459             :             }
     460             :         }
     461           0 :     } while (band_count > 0);
     462             : 
     463             :     TRAILER trailer;
     464             : 
     465           0 :     CPL_IGNORE_RET_VAL(VSIFSeekL(fin, _f_trailer_offset, SEEK_SET));
     466             : 
     467           0 :     if (VSIFReadL(&gp_header, sizeof(GP_PK_HEADER), 1, fin) != 1 ||
     468           0 :         VSIFReadL(&sub_header, sizeof(GP_PK_SH1), 1, fin) != 1 ||
     469           0 :         VSIFReadL(&trailer, sizeof(TRAILER), 1, fin) != 1)
     470             :     {
     471           0 :         _open_success = false;
     472           0 :         fprintf(stderr, "Trailer fail\n"); /*ok*/
     473           0 :         return;
     474             :     }
     475             : 
     476           0 :     to_native(trailer.imageProductionStats.actualL15CoverageVisir);
     477           0 :     to_native(trailer.imageProductionStats.actualL15CoverageHrv);
     478             : 
     479           0 :     CPLDebugOnly("MSGN", "Trailer Version %d, satellite %d",
     480             :                  trailer.trailerHeaderVersion,
     481             :                  trailer.imageProductionStats.satelliteId);
     482             : 
     483           0 :     CPLDebugOnly(
     484             :         "MSGN",
     485             :         "\nactualL15CoverageVisir.SouthernLineActual = %d, \n"
     486             :         "actualL15CoverageVisir.NorthernLineActual = %d, \n"
     487             :         "actualL15CoverageVisir.EasternColumnActual = %d, \n "
     488             :         "actualL15CoverageVisir.WesternColumnActual = %d",
     489             :         trailer.imageProductionStats.actualL15CoverageVisir.southernLineActual,
     490             :         trailer.imageProductionStats.actualL15CoverageVisir.northernLineActual,
     491             :         trailer.imageProductionStats.actualL15CoverageVisir.easternColumnActual,
     492             :         trailer.imageProductionStats.actualL15CoverageVisir
     493             :             .westernColumnActual);
     494             : 
     495           0 :     CPLDebugOnly(
     496             :         "MSGN",
     497             :         "\nactualCoverage_hrv.lowerSouthLineActual = %d, \n"
     498             :         "actualCoverage_hrv.lowerNorthLineActual = %d, \n"
     499             :         "actualCoverage_hrv.lowerEastColumnActual = %d, \n "
     500             :         "actualCoverage_hrv.lowerWestColumnActual = %d",
     501             :         trailer.imageProductionStats.actualL15CoverageHrv.lowerSouthLineActual,
     502             :         trailer.imageProductionStats.actualL15CoverageHrv.lowerNorthLineActual,
     503             :         trailer.imageProductionStats.actualL15CoverageHrv.lowerEastColumnActual,
     504             :         trailer.imageProductionStats.actualL15CoverageHrv
     505             :             .lowerWestColumnActual);
     506             : 
     507           0 :     CPLDebugOnly(
     508             :         "MSGN",
     509             :         "\nactualCoverage_hrv.upperSouthLineActual = %d, \n"
     510             :         "actualCoverage_hrv.upperNorthLineActual = %d, \n"
     511             :         "actualCoverage_hrv.upperEastColumnActual = %d, \n "
     512             :         "actualCoverage_hrv.upperWestColumnActual = %d",
     513             :         trailer.imageProductionStats.actualL15CoverageHrv.upperSouthLineActual,
     514             :         trailer.imageProductionStats.actualL15CoverageHrv.upperNorthLineActual,
     515             :         trailer.imageProductionStats.actualL15CoverageHrv.upperEastColumnActual,
     516             :         trailer.imageProductionStats.actualL15CoverageHrv
     517             :             .upperWestColumnActual);
     518             : }
     519             : 
     520             : #ifndef GDAL_SUPPORT
     521             : 
     522             : int Msg_reader_core::_chan_to_idx(Msg_channel_names channel)
     523             : {
     524             :     unsigned int idx = 0;
     525             :     while (idx < MSG_NUM_CHANNELS)
     526             :     {
     527             :         if ((1 << (idx + 1)) == (int)channel)
     528             :         {
     529             :             return idx;
     530             :         }
     531             :         idx++;
     532             :     }
     533             :     return 0;
     534             : }
     535             : 
     536             : void Msg_reader_core::get_pixel_geo_coordinates(unsigned int line,
     537             :                                                 unsigned int column,
     538             :                                                 double &longitude,
     539             :                                                 double &latitude) const
     540             : {
     541             :     Conversions::convert_pixel_to_geo((double)(line + _line_start),
     542             :                                       (double)(column + _col_start), longitude,
     543             :                                       latitude);
     544             :     longitude += _img_desc_record.longitudeOfSSP;
     545             : }
     546             : 
     547             : void Msg_reader_core::get_pixel_geo_coordinates(double line, double column,
     548             :                                                 double &longitude,
     549             :                                                 double &latitude)
     550             : {
     551             :     Conversions::convert_pixel_to_geo(line + _line_start, column + _col_start,
     552             :                                       longitude, latitude);
     553             :     longitude += _img_desc_record.longitudeOfSSP;
     554             : }
     555             : 
     556             : double Msg_reader_core::compute_pixel_area_sqkm(double line, double column)
     557             : {
     558             :     return Conversions::compute_pixel_area_sqkm(line + _line_start,
     559             :                                                 column + _col_start);
     560             : }
     561             : 
     562             : #endif  // GDAL_SUPPORT
     563             : 
     564             : }  // namespace msg_native_format

Generated by: LCOV version 1.14