Coverage Report

Created: 2025-12-03 08:24

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gdal/frmts/aaigrid/aaigriddataset.h
Line
Count
Source
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
31
#include <algorithm>
32
#include <limits>
33
#include <string>
34
35
#include "cpl_conv.h"
36
#include "cpl_error.h"
37
#include "cpl_progress.h"
38
#include "cpl_string.h"
39
#include "cpl_vsi.h"
40
#include "gdal.h"
41
#include "gdal_pam.h"
42
#include "gdal_priv.h"
43
#include "ogr_core.h"
44
#include "ogr_spatialref.h"
45
46
typedef enum
47
{
48
    FORMAT_AAIG,
49
    FORMAT_GRASSASCII,
50
    FORMAT_ISG,
51
} GridFormat;
52
53
/************************************************************************/
54
/* ==================================================================== */
55
/*                              AAIGDataset                             */
56
/* ==================================================================== */
57
/************************************************************************/
58
59
class AAIGRasterBand;
60
61
class AAIGDataset CPL_NON_FINAL : public GDALPamDataset
62
{
63
    friend class AAIGRasterBand;
64
65
    VSILFILE *fp;
66
67
    char **papszPrj;
68
    CPLString osPrjFilename{};
69
    OGRSpatialReference m_oSRS{};
70
71
    unsigned char achReadBuf[256];
72
    GUIntBig nBufferOffset;
73
    int nOffsetInBuffer;
74
75
    char Getc();
76
    GUIntBig Tell() const;
77
    int Seek(GUIntBig nOffset);
78
79
    CPL_DISALLOW_COPY_ASSIGN(AAIGDataset)
80
81
  protected:
82
    GDALDataType eDataType;
83
    GDALGeoTransform m_gt{};
84
    bool bNoDataSet;
85
    double dfNoDataValue;
86
    CPLString osUnits{};
87
88
    virtual bool ParseHeader(const char *pszHeader, const char *pszDataType);
89
90
  public:
91
    AAIGDataset();
92
    ~AAIGDataset() override;
93
94
    char **GetFileList(void) override;
95
96
    static GDALDataset *CommonOpen(GDALOpenInfo *poOpenInfo,
97
                                   GridFormat eFormat);
98
99
    static GDALDataset *Open(GDALOpenInfo *);
100
    static int Identify(GDALOpenInfo *);
101
    static CPLErr Delete(const char *pszFilename);
102
    static CPLErr Remove(const char *pszFilename, int bRepError);
103
    static GDALDataset *CreateCopy(const char *pszFilename,
104
                                   GDALDataset *poSrcDS, int bStrict,
105
                                   char **papszOptions,
106
                                   GDALProgressFunc pfnProgress,
107
                                   void *pProgressData);
108
109
    CPLErr GetGeoTransform(GDALGeoTransform &gt) const override;
110
    const OGRSpatialReference *GetSpatialRef() const override;
111
};
112
113
/************************************************************************/
114
/* ==================================================================== */
115
/*                        GRASSASCIIDataset                             */
116
/* ==================================================================== */
117
/************************************************************************/
118
119
class GRASSASCIIDataset final : public AAIGDataset
120
{
121
    bool ParseHeader(const char *pszHeader, const char *pszDataType) override;
122
123
  public:
124
39
    GRASSASCIIDataset() = default;
125
126
    static GDALDataset *Open(GDALOpenInfo *);
127
    static int Identify(GDALOpenInfo *);
128
};
129
130
/************************************************************************/
131
/* ==================================================================== */
132
/*                           ISGDataset                                 */
133
/* ==================================================================== */
134
/************************************************************************/
135
136
class ISGDataset final : public AAIGDataset
137
{
138
    bool ParseHeader(const char *pszHeader, const char *pszDataType) override;
139
140
  public:
141
1.64k
    ISGDataset() = default;
142
143
    static GDALDataset *Open(GDALOpenInfo *);
144
    static int Identify(GDALOpenInfo *);
145
};
146
147
/************************************************************************/
148
/* ==================================================================== */
149
/*                            AAIGRasterBand                             */
150
/* ==================================================================== */
151
/************************************************************************/
152
153
class AAIGRasterBand final : public GDALPamRasterBand
154
{
155
    friend class AAIGDataset;
156
157
    GUIntBig *panLineOffset;
158
159
    CPL_DISALLOW_COPY_ASSIGN(AAIGRasterBand)
160
161
  public:
162
    AAIGRasterBand(AAIGDataset *, int);
163
    ~AAIGRasterBand() override;
164
165
    double GetNoDataValue(int *) override;
166
    CPLErr SetNoDataValue(double) override;
167
    CPLErr IReadBlock(int, int, void *) override;
168
};
169
170
#endif  // GDAL_FRMTS_AAIGRID_AAIGRIDDATASET_H_INCLUDED