LCOV - code coverage report
Current view: top level - frmts/aaigrid - aaigriddataset.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 2 2 100.0 %
Date: 2025-08-01 10:10:57 Functions: 2 2 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 bool 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             :     bool ParseHeader(const char *pszHeader, const char *pszDataType) override;
     125             : 
     126             :   public:
     127           2 :     GRASSASCIIDataset() = default;
     128             : 
     129             :     static GDALDataset *Open(GDALOpenInfo *);
     130             :     static int Identify(GDALOpenInfo *);
     131             : };
     132             : 
     133             : /************************************************************************/
     134             : /* ==================================================================== */
     135             : /*                           ISGDataset                                 */
     136             : /* ==================================================================== */
     137             : /************************************************************************/
     138             : 
     139             : class ISGDataset final : public AAIGDataset
     140             : {
     141             :     bool ParseHeader(const char *pszHeader, const char *pszDataType) override;
     142             : 
     143             :   public:
     144           8 :     ISGDataset() = default;
     145             : 
     146             :     static GDALDataset *Open(GDALOpenInfo *);
     147             :     static int Identify(GDALOpenInfo *);
     148             : };
     149             : 
     150             : /************************************************************************/
     151             : /* ==================================================================== */
     152             : /*                            AAIGRasterBand                             */
     153             : /* ==================================================================== */
     154             : /************************************************************************/
     155             : 
     156             : class AAIGRasterBand final : public GDALPamRasterBand
     157             : {
     158             :     friend class AAIGDataset;
     159             : 
     160             :     GUIntBig *panLineOffset;
     161             : 
     162             :     CPL_DISALLOW_COPY_ASSIGN(AAIGRasterBand)
     163             : 
     164             :   public:
     165             :     AAIGRasterBand(AAIGDataset *, int);
     166             :     ~AAIGRasterBand() override;
     167             : 
     168             :     double GetNoDataValue(int *) override;
     169             :     CPLErr SetNoDataValue(double) override;
     170             :     CPLErr IReadBlock(int, int, void *) override;
     171             : };
     172             : 
     173             : #endif  // GDAL_FRMTS_AAIGRID_AAIGRIDDATASET_H_INCLUDED

Generated by: LCOV version 1.14