forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvidataset.h
178 lines (144 loc) · 5.82 KB
/
envidataset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/******************************************************************************
* $Id$
*
* Project: ENVI .hdr Driver
* Purpose: Implementation of ENVI .hdr labelled raw raster support.
* Author: Frank Warmerdam, [email protected]
* Maintainer: Chris Padwick (cpadwick at ittvis.com)
*
******************************************************************************
* Copyright (c) 2002, Frank Warmerdam
* Copyright (c) 2007-2013, Even Rouault <even dot rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED
#define GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED
#include "cpl_port.h"
#include "rawdataset.h"
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
#include <algorithm>
#include <limits>
#include <string>
#include "cpl_conv.h"
#include "cpl_error.h"
#include "cpl_string.h"
#include "cpl_vsi.h"
#include "gdal.h"
#include "gdal_frmts.h"
#include "gdal_priv.h"
#include "ogr_core.h"
#include "ogr_spatialref.h"
#include "ogr_srs_api.h"
class ENVIRasterBand;
class ENVIDataset final : public RawDataset
{
friend class ENVIRasterBand;
VSILFILE *fpImage; // Image data file.
VSILFILE *fp; // Header file
char *pszHDRFilename;
bool bFoundMapinfo;
bool bHeaderDirty;
bool bFillFile;
double adfGeoTransform[6];
OGRSpatialReference m_oSRS{};
CPLStringList m_aosHeader{};
CPLString osStaFilename{};
std::vector<GDAL_GCP> m_asGCPs{};
bool ReadHeader(VSILFILE *);
bool ProcessMapinfo(const char *);
void ProcessRPCinfo(const char *, int, int);
void ProcessGeoPoints(const char *);
void ProcessStatsFile();
static int byteSwapInt(int);
static float byteSwapFloat(float);
static double byteSwapDouble(double);
static void SetENVIDatum(OGRSpatialReference *, const char *);
static void SetENVIEllipse(OGRSpatialReference *, char **);
void WriteProjectionInfo();
bool ParseRpcCoeffsMetaDataString(const char *psName, char *papszVal[],
int &idx);
bool WriteRpcInfo();
bool WritePseudoGcpInfo();
void SetFillFile()
{
bFillFile = true;
}
static char **SplitList(const char *);
enum Interleave
{
BSQ,
BIL,
BIP
} interleave;
static int GetEnviType(GDALDataType eType);
CPL_DISALLOW_COPY_ASSIGN(ENVIDataset)
CPLErr Close() override;
public:
ENVIDataset();
~ENVIDataset() override;
CPLErr FlushCache(bool bAtClosing) override;
CPLErr GetGeoTransform(double *padfTransform) override;
CPLErr SetGeoTransform(double *) override;
const OGRSpatialReference *GetSpatialRef() const override;
CPLErr SetSpatialRef(const OGRSpatialReference *poSRS) override;
char **GetFileList() override;
void SetDescription(const char *) override;
CPLErr SetMetadata(char **papszMetadata,
const char *pszDomain = "") override;
CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
const char *pszDomain = "") override;
CPLErr SetGCPs(int nGCPCount, const GDAL_GCP *pasGCPList,
const OGRSpatialReference *poSRS) override;
int GetGCPCount() override;
const GDAL_GCP *GetGCPs() override;
bool GetRawBinaryLayout(GDALDataset::RawBinaryLayout &) override;
static GDALDataset *Open(GDALOpenInfo *);
static ENVIDataset *Open(GDALOpenInfo *, bool bFileSizeCheck);
static GDALDataset *Create(const char *pszFilename, int nXSize, int nYSize,
int nBands, GDALDataType eType,
char **papszOptions);
};
/************************************************************************/
/* ==================================================================== */
/* ENVIRasterBand */
/* ==================================================================== */
/************************************************************************/
class ENVIRasterBand final : public RawRasterBand
{
CPL_DISALLOW_COPY_ASSIGN(ENVIRasterBand)
public:
ENVIRasterBand(GDALDataset *poDSIn, int nBandIn, VSILFILE *fpRawIn,
vsi_l_offset nImgOffsetIn, int nPixelOffsetIn,
int nLineOffsetIn, GDALDataType eDataTypeIn,
RawRasterBand::ByteOrder eByteOrderIn);
void SetDescription(const char *) override;
CPLErr SetNoDataValue(double) override;
CPLErr SetColorInterpretation(GDALColorInterp eColorInterp) override;
CPLErr SetOffset(double) override;
CPLErr SetScale(double) override;
CPLErr SetCategoryNames(char **) override;
};
#endif // GDAL_FRMTS_RAW_ENVIDATASET_H_INCLUDED