LCOV - code coverage report
Current view: top level - frmts/aaigrid - aaigriddataset.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 7 7 100.0 %
Date: 2025-07-02 23:05:47 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  Implements Arc/Info ASCII Grid Format.
       5             :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2001, Frank Warmerdam (warmerdam@pobox.com)
       9             :  * Copyright (c) 2007-2012, Even Rouault <even dot rouault at spatialys.com>
      10             :  * Copyright (c) 2014, Kyle Shannon <kyle at pobox dot com>
      11             :  *
      12             :  * SPDX-License-Identifier: MIT
      13             :  ****************************************************************************/
      14             : 
      15             : #ifndef GDAL_FRMTS_AAIGRID_AAIGRIDDATASET_H_INCLUDED
      16             : #define GDAL_FRMTS_AAIGRID_AAIGRIDDATASET_H_INCLUDED
      17             : 
      18             : // We need cpl_port as first include to avoid VSIStatBufL being not
      19             : // defined on i586-mingw32msvc.
      20             : #include "cpl_port.h"
      21             : #include "gdal_frmts.h"
      22             : 
      23             : #include <cctype>
      24             : #include <climits>
      25             : #include <cmath>
      26             : #include <cstddef>
      27             : #include <cstdio>
      28             : #include <cstdlib>
      29             : #include <cstring>
      30             : #if HAVE_FCNTL_H
      31             : #include <fcntl.h>
      32             : #endif
      33             : 
      34             : #include <algorithm>
      35             : #include <limits>
      36             : #include <string>
      37             : 
      38             : #include "cpl_conv.h"
      39             : #include "cpl_error.h"
      40             : #include "cpl_progress.h"
      41             : #include "cpl_string.h"
      42             : #include "cpl_vsi.h"
      43             : #include "gdal.h"
      44             : #include "gdal_pam.h"
      45             : #include "gdal_priv.h"
      46             : #include "ogr_core.h"
      47             : #include "ogr_spatialref.h"
      48             : 
      49             : typedef enum
      50             : {
      51             :     FORMAT_AAIG,
      52             :     FORMAT_GRASSASCII,
      53             :     FORMAT_ISG,
      54             : } GridFormat;
      55             : 
      56             : /************************************************************************/
      57             : /* ==================================================================== */
      58             : /*                              AAIGDataset                             */
      59             : /* ==================================================================== */
      60             : /************************************************************************/
      61             : 
      62             : class AAIGRasterBand;
      63             : 
      64             : class AAIGDataset CPL_NON_FINAL : public GDALPamDataset
      65             : {
      66             :     friend class AAIGRasterBand;
      67             : 
      68             :     VSILFILE *fp;
      69             : 
      70             :     char **papszPrj;
      71             :     CPLString osPrjFilename{};
      72             :     OGRSpatialReference m_oSRS{};
      73             : 
      74             :     unsigned char achReadBuf[256];
      75             :     GUIntBig nBufferOffset;
      76             :     int nOffsetInBuffer;
      77             : 
      78             :     char Getc();
      79             :     GUIntBig Tell() const;
      80             :     int Seek(GUIntBig nOffset);
      81             : 
      82             :     CPL_DISALLOW_COPY_ASSIGN(AAIGDataset)
      83             : 
      84             :   protected:
      85             :     GDALDataType eDataType;
      86             :     GDALGeoTransform m_gt{};
      87             :     bool bNoDataSet;
      88             :     double dfNoDataValue;
      89             :     CPLString osUnits{};
      90             : 
      91             :     virtual int ParseHeader(const char *pszHeader, const char *pszDataType);
      92             : 
      93             :   public:
      94             :     AAIGDataset();
      95             :     ~AAIGDataset() override;
      96             : 
      97             :     char **GetFileList(void) override;
      98             : 
      99             :     static GDALDataset *CommonOpen(GDALOpenInfo *poOpenInfo,
     100             :                                    GridFormat eFormat);
     101             : 
     102             :     static GDALDataset *Open(GDALOpenInfo *);
     103             :     static int Identify(GDALOpenInfo *);
     104             :     static CPLErr Delete(const char *pszFilename);
     105             :     static CPLErr Remove(const char *pszFilename, int bRepError);
     106             :     static GDALDataset *CreateCopy(const char *pszFilename,
     107             :                                    GDALDataset *poSrcDS, int bStrict,
     108             :                                    char **papszOptions,
     109             :                                    GDALProgressFunc pfnProgress,
     110             :                                    void *pProgressData);
     111             : 
     112             :     CPLErr GetGeoTransform(GDALGeoTransform &gt) const override;
     113             :     const OGRSpatialReference *GetSpatialRef() const override;
     114             : };
     115             : 
     116             : /************************************************************************/
     117             : /* ==================================================================== */
     118             : /*                        GRASSASCIIDataset                             */
     119             : /* ==================================================================== */
     120             : /************************************************************************/
     121             : 
     122             : class GRASSASCIIDataset final : public AAIGDataset
     123             : {
     124             :     int ParseHeader(const char *pszHeader, const char *pszDataType) override;
     125             : 
     126             :   public:
     127           2 :     GRASSASCIIDataset() : AAIGDataset()
     128             :     {
     129           2 :     }
     130             : 
     131           4 :     ~GRASSASCIIDataset() override
     132           2 :     {
     133           4 :     }
     134             : 
     135             :     static GDALDataset *Open(GDALOpenInfo *);
     136             :     static int Identify(GDALOpenInfo *);
     137             : };
     138             : 
     139             : /************************************************************************/
     140             : /* ==================================================================== */
     141             : /*                           ISGDataset                                 */
     142             : /* ==================================================================== */
     143             : /************************************************************************/
     144             : 
     145             : class ISGDataset final : public AAIGDataset
     146             : {
     147             :     int ParseHeader(const char *pszHeader, const char *pszDataType) override;
     148             : 
     149             :   public:
     150           8 :     ISGDataset() : AAIGDataset()
     151             :     {
     152           8 :     }
     153             : 
     154             :     static GDALDataset *Open(GDALOpenInfo *);
     155             :     static int Identify(GDALOpenInfo *);
     156             : };
     157             : 
     158             : /************************************************************************/
     159             : /* ==================================================================== */
     160             : /*                            AAIGRasterBand                             */
     161             : /* ==================================================================== */
     162             : /************************************************************************/
     163             : 
     164             : class AAIGRasterBand final : public GDALPamRasterBand
     165             : {
     166             :     friend class AAIGDataset;
     167             : 
     168             :     GUIntBig *panLineOffset;
     169             : 
     170             :     CPL_DISALLOW_COPY_ASSIGN(AAIGRasterBand)
     171             : 
     172             :   public:
     173             :     AAIGRasterBand(AAIGDataset *, int);
     174             :     ~AAIGRasterBand() override;
     175             : 
     176             :     double GetNoDataValue(int *) override;
     177             :     CPLErr SetNoDataValue(double) override;
     178             :     CPLErr IReadBlock(int, int, void *) override;
     179             : };
     180             : 
     181             : #endif  // GDAL_FRMTS_AAIGRID_AAIGRIDDATASET_H_INCLUDED

Generated by: LCOV version 1.14