/src/gdal/frmts/rcm/rcmdataset.h
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Project: DRDC Ottawa GEOINT |
4 | | * Purpose: Radarsat Constellation Mission - XML Products (product.xml) driver |
5 | | * Author: Roberto Caron, MDA |
6 | | * on behalf of DRDC Ottawa |
7 | | * |
8 | | ****************************************************************************** |
9 | | * Copyright (c) 2020, DRDC Ottawa |
10 | | * |
11 | | * Based on the RS2 Dataset Class |
12 | | * |
13 | | * SPDX-License-Identifier: MIT |
14 | | ****************************************************************************/ |
15 | | |
16 | | #ifndef GDAL_RCM_H_INCLUDED |
17 | | #define GDAL_RCM_H_INCLUDED |
18 | | |
19 | | #include "gdal_pam.h" |
20 | | |
21 | | typedef enum eCalibration_t |
22 | | { |
23 | | Sigma0 = 0, |
24 | | Gamma, |
25 | | Beta0, |
26 | | Uncalib, |
27 | | None |
28 | | } eCalibration; |
29 | | |
30 | | /************************************************************************/ |
31 | | /* ==================================================================== */ |
32 | | /* RCMDataset */ |
33 | | /* ==================================================================== */ |
34 | | /************************************************************************/ |
35 | | |
36 | | class RCMDataset final : public GDALPamDataset |
37 | | { |
38 | | CPLXMLTreeCloser psProduct{nullptr}; |
39 | | |
40 | | int nGCPCount = 0; |
41 | | GDAL_GCP *pasGCPList = nullptr; |
42 | | OGRSpatialReference m_oSRS{}; |
43 | | OGRSpatialReference m_oGCPSRS{}; |
44 | | char **papszSubDatasets = nullptr; |
45 | | double adfGeoTransform[6]; |
46 | | bool bHaveGeoTransform = false; |
47 | | bool bPerPolarizationScaling = false; |
48 | | bool isComplexData = false; |
49 | | int magnitudeBits = 16; |
50 | | int realBitsComplexData = 32; |
51 | | int imaginaryBitsComplexData = 32; |
52 | | char **papszExtraFiles = nullptr; |
53 | | double *m_nfIncidenceAngleTable = nullptr; |
54 | | int m_IncidenceAngleTableSize = 0; |
55 | | |
56 | | CPL_DISALLOW_COPY_ASSIGN(RCMDataset) |
57 | | |
58 | | protected: |
59 | | virtual int CloseDependentDatasets() override; |
60 | | |
61 | | public: |
62 | | RCMDataset(); |
63 | | virtual ~RCMDataset(); |
64 | | |
65 | | virtual int GetGCPCount() override; |
66 | | |
67 | | const OGRSpatialReference *GetGCPSpatialRef() const override; |
68 | | virtual const GDAL_GCP *GetGCPs() override; |
69 | | |
70 | | const OGRSpatialReference *GetSpatialRef() const override; |
71 | | virtual CPLErr GetGeoTransform(double *) override; |
72 | | |
73 | | virtual char **GetMetadataDomainList() override; |
74 | | virtual char **GetMetadata(const char *pszDomain = "") override; |
75 | | virtual char **GetFileList(void) override; |
76 | | |
77 | | static GDALDataset *Open(GDALOpenInfo *); |
78 | | |
79 | | CPLXMLNode *GetProduct() |
80 | 0 | { |
81 | 0 | return psProduct.get(); |
82 | 0 | } |
83 | | |
84 | | /* If False, this is Magnitude, True, Complex data with Real and |
85 | | * Imaginary*/ |
86 | | bool IsComplexData() |
87 | 0 | { |
88 | 0 | return isComplexData; |
89 | 0 | } |
90 | | |
91 | | /* These 2 variables are used in case of Complex Data */ |
92 | | int GetRealBitsComplexData() |
93 | 0 | { |
94 | 0 | return realBitsComplexData; |
95 | 0 | } |
96 | | |
97 | | int GetImaginaryBitsComplexData() |
98 | 0 | { |
99 | 0 | return imaginaryBitsComplexData; |
100 | 0 | } |
101 | | |
102 | | /* This variable is used in case of Magnitude */ |
103 | | int GetMagnitudeBits() |
104 | 0 | { |
105 | 0 | return magnitudeBits; |
106 | 0 | } |
107 | | |
108 | | /* This variable is used to hold the Incidence Angle */ |
109 | | double *GetIncidenceAngle() |
110 | 0 | { |
111 | 0 | return m_nfIncidenceAngleTable; |
112 | 0 | } |
113 | | |
114 | | /* This variable is used to hold the Incidence Angle Table Size */ |
115 | | int GetIncidenceAngleSize() |
116 | 0 | { |
117 | 0 | return m_IncidenceAngleTableSize; |
118 | 0 | } |
119 | | }; |
120 | | |
121 | | /************************************************************************/ |
122 | | /* ==================================================================== */ |
123 | | /* RCMRasterBand */ |
124 | | /* ==================================================================== */ |
125 | | /************************************************************************/ |
126 | | |
127 | | class RCMRasterBand final : public GDALPamRasterBand |
128 | | { |
129 | | private: |
130 | | eCalibration m_eCalib = eCalibration::Uncalib; |
131 | | GDALDataset *poBandFile = nullptr; |
132 | | RCMDataset *poRCMDataset = nullptr; |
133 | | GDALDataset *m_poBandDataset = nullptr; |
134 | | |
135 | | double *m_nfTable = nullptr; |
136 | | int m_nTableSize = 0; |
137 | | double m_nfOffset = 0; |
138 | | char *m_pszLUTFile = nullptr; |
139 | | int pixelFirstLutValue = 0; |
140 | | int stepSize = 0; |
141 | | int numberOfValues = 0; |
142 | | GDALRasterBand *poBand = nullptr; |
143 | | |
144 | | // 2 bands representing I+Q -> one complex band |
145 | | // otherwise poBandFile is passed straight through |
146 | | bool twoBandComplex = false; |
147 | | |
148 | | bool isOneFilePerPol = false; |
149 | | bool isNITF = false; |
150 | | |
151 | | CPL_DISALLOW_COPY_ASSIGN(RCMRasterBand) |
152 | | |
153 | | public: |
154 | | RCMRasterBand(RCMDataset *poDSIn, int nBandIn, GDALDataType eDataTypeIn, |
155 | | const char *pszPole, GDALDataset *poBandFile, |
156 | | bool bTwoBandComplex, bool isOneFilePerPol, bool isNITF); |
157 | | |
158 | | virtual ~RCMRasterBand(); |
159 | | |
160 | | virtual CPLErr IReadBlock(int, int, void *) override; |
161 | | |
162 | | static GDALDataset *Open(GDALOpenInfo *); |
163 | | }; |
164 | | |
165 | | /************************************************************************/ |
166 | | /* ==================================================================== */ |
167 | | /* RCMCalibRasterBand */ |
168 | | /* ==================================================================== */ |
169 | | /************************************************************************/ |
170 | | /* Returns data that has been calibrated to sigma nought, gamma */ |
171 | | /* or beta nought. */ |
172 | | /************************************************************************/ |
173 | | |
174 | | class RCMCalibRasterBand final : public GDALPamRasterBand |
175 | | { |
176 | | private: |
177 | | eCalibration m_eCalib = eCalibration::Uncalib; |
178 | | GDALDataset *m_poBandDataset = nullptr; |
179 | | /* data type that used to be before transformation */ |
180 | | GDALDataType m_eOriginalType = GDT_Unknown; |
181 | | |
182 | | double *m_nfTable = nullptr; |
183 | | int m_nTableSize = 0; |
184 | | double m_nfOffset = 0; |
185 | | char *m_pszLUTFile = nullptr; |
186 | | int pixelFirstLutValue = 0; |
187 | | int stepSize = 0; |
188 | | int numberOfValues = 0; |
189 | | |
190 | | char *m_pszNoiseLevelsFile = nullptr; |
191 | | double *m_nfTableNoiseLevels = nullptr; |
192 | | int pixelFirstLutValueNoiseLevels = 0; |
193 | | int stepSizeNoiseLevels = 0; |
194 | | int numberOfValuesNoiseLevels = 0; |
195 | | int m_nTableNoiseLevelsSize = 0; |
196 | | |
197 | | void ReadLUT(); |
198 | | void ReadNoiseLevels(); |
199 | | |
200 | | CPL_DISALLOW_COPY_ASSIGN(RCMCalibRasterBand) |
201 | | |
202 | | public: |
203 | | RCMCalibRasterBand(RCMDataset *poDataset, const char *pszPolarization, |
204 | | GDALDataType eType, GDALDataset *poBandDataset, |
205 | | eCalibration eCalib, const char *pszLUT, |
206 | | const char *pszNoiseLevels, GDALDataType eOriginalType); |
207 | | ~RCMCalibRasterBand(); |
208 | | |
209 | | CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) override; |
210 | | }; |
211 | | |
212 | | #endif /* ndef GDAL_RCM_H_INCLUDED */ |