LCOV - code coverage report
Current view: top level - frmts/raw - envidataset.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 3 3 100.0 %
Date: 2025-09-10 17:48:50 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  ENVI .hdr Driver
       4             :  * Purpose:  Implementation of ENVI .hdr labelled raw raster support.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  * Maintainer: Chris Padwick (cpadwick at ittvis.com)
       7             :  *
       8             :  ******************************************************************************
       9             :  * Copyright (c) 2002, Frank Warmerdam
      10             :  * Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
      11             :  *
      12             :  * SPDX-License-Identifier: MIT
      13             :  ****************************************************************************/
      14             : 
      15             : #ifndef GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED
      16             : #define GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED
      17             : 
      18             : #include "cpl_port.h"
      19             : #include "rawdataset.h"
      20             : 
      21             : #include <climits>
      22             : #include <cmath>
      23             : #include <cstdlib>
      24             : #include <cstring>
      25             : 
      26             : #include <algorithm>
      27             : #include <limits>
      28             : #include <string>
      29             : 
      30             : #include "cpl_conv.h"
      31             : #include "cpl_error.h"
      32             : #include "cpl_string.h"
      33             : #include "cpl_vsi.h"
      34             : #include "gdal.h"
      35             : #include "gdal_frmts.h"
      36             : #include "gdal_priv.h"
      37             : #include "ogr_core.h"
      38             : #include "ogr_spatialref.h"
      39             : #include "ogr_srs_api.h"
      40             : 
      41             : class ENVIRasterBand;
      42             : 
      43             : class ENVIDataset final : public RawDataset
      44             : {
      45             :     friend class ENVIRasterBand;
      46             : 
      47             :     VSILFILE *fpImage;  // Image data file.
      48             :     VSILFILE *fp;       // Header file
      49             :     char *pszHDRFilename;
      50             : 
      51             :     bool bFoundMapinfo;
      52             :     bool bHeaderDirty;
      53             :     bool bFillFile;
      54             : 
      55             :     GDALGeoTransform m_gt{};
      56             : 
      57             :     OGRSpatialReference m_oSRS{};
      58             : 
      59             :     CPLStringList m_aosHeader{};
      60             : 
      61             :     CPLString osStaFilename{};
      62             : 
      63             :     std::vector<GDAL_GCP> m_asGCPs{};
      64             : 
      65             :     Interleave eInterleave = Interleave::BSQ;
      66             : 
      67             :     bool ReadHeader(VSILFILE *);
      68             :     bool ProcessMapinfo(const char *);
      69             :     void ProcessRPCinfo(const char *, int, int);
      70             :     void ProcessGeoPoints(const char *);
      71             :     void ProcessStatsFile();
      72             :     static int byteSwapInt(int);
      73             :     static float byteSwapFloat(float);
      74             :     static double byteSwapDouble(double);
      75             :     static void SetENVIDatum(OGRSpatialReference *, const char *);
      76             :     static void SetENVIEllipse(OGRSpatialReference *, char **);
      77             :     void WriteProjectionInfo();
      78             :     bool ParseRpcCoeffsMetaDataString(const char *psName, char *papszVal[],
      79             :                                       int &idx);
      80             :     bool WriteRpcInfo();
      81             :     bool WritePseudoGcpInfo();
      82             : 
      83          93 :     void SetFillFile()
      84             :     {
      85          93 :         bFillFile = true;
      86          93 :     }
      87             : 
      88             :     static char **SplitList(const char *);
      89             : 
      90             :     static int GetEnviType(GDALDataType eType);
      91             : 
      92             :     CPL_DISALLOW_COPY_ASSIGN(ENVIDataset)
      93             : 
      94             :     CPLErr Close() override;
      95             : 
      96             :   public:
      97             :     ENVIDataset();
      98             :     ~ENVIDataset() override;
      99             : 
     100             :     CPLErr FlushCache(bool bAtClosing) override;
     101             :     CPLErr GetGeoTransform(GDALGeoTransform &gt) const override;
     102             :     CPLErr SetGeoTransform(const GDALGeoTransform &gt) override;
     103             : 
     104             :     const OGRSpatialReference *GetSpatialRef() const override;
     105             :     CPLErr SetSpatialRef(const OGRSpatialReference *poSRS) override;
     106             : 
     107             :     char **GetFileList() override;
     108             : 
     109             :     void SetDescription(const char *) override;
     110             : 
     111             :     CPLErr SetMetadata(char **papszMetadata,
     112             :                        const char *pszDomain = "") override;
     113             :     CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
     114             :                            const char *pszDomain = "") override;
     115             :     CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
     116             :                    const OGRSpatialReference *poSRS) override;
     117             :     int GetGCPCount() override;
     118             :     const GDAL_GCP *GetGCPs() override;
     119             : 
     120             :     bool GetRawBinaryLayout(GDALDataset::RawBinaryLayout &) override;
     121             : 
     122             :     static GDALDataset *Open(GDALOpenInfo *);
     123             :     static ENVIDataset *Open(GDALOpenInfo *, bool bFileSizeCheck);
     124             :     static GDALDataset *Create(const char *pszFilename, int nXSize, int nYSize,
     125             :                                int nBands, GDALDataType eType,
     126             :                                char **papszOptions);
     127             : };
     128             : 
     129             : /************************************************************************/
     130             : /* ==================================================================== */
     131             : /*                            ENVIRasterBand                            */
     132             : /* ==================================================================== */
     133             : /************************************************************************/
     134             : 
     135             : class ENVIRasterBand final : public RawRasterBand
     136             : {
     137             :     CPL_DISALLOW_COPY_ASSIGN(ENVIRasterBand)
     138             : 
     139             :   public:
     140             :     ENVIRasterBand(GDALDataset *poDSIn, int nBandIn, VSILFILE *fpRawIn,
     141             :                    vsi_l_offset nImgOffsetIn, int nPixelOffsetIn,
     142             :                    int nLineOffsetIn, GDALDataType eDataTypeIn,
     143             :                    RawRasterBand::ByteOrder eByteOrderIn);
     144             : 
     145             :     void SetDescription(const char *) override;
     146             :     CPLErr SetNoDataValue(double) override;
     147             :     CPLErr SetColorInterpretation(GDALColorInterp eColorInterp) override;
     148             :     CPLErr SetOffset(double) override;
     149             :     CPLErr SetScale(double) override;
     150             : 
     151             :     CPLErr SetCategoryNames(char **) override;
     152             : };
     153             : 
     154             : #endif  // GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED

Generated by: LCOV version 1.14