18
18
19
19
#include < vector>
20
20
21
- enum Interleave
22
- {
23
- BSQ,
24
- BIL,
25
- BIP
26
- };
27
-
28
21
/* ***********************************************************************/
29
22
/* ==================================================================== */
30
23
/* CPGDataset */
@@ -53,7 +46,7 @@ class CPGDataset final : public RawDataset
53
46
int nLoadedStokesLine;
54
47
float *padfStokesMatrix;
55
48
56
- int nInterleave ;
49
+ Interleave eInterleave = Interleave::BSQ ;
57
50
static int AdjustFilename (char **, const char *, const char *);
58
51
static int FindType1 (const char *pszWorkname);
59
52
static int FindType2 (const char *pszWorkname);
@@ -101,7 +94,7 @@ class CPGDataset final : public RawDataset
101
94
102
95
CPGDataset::CPGDataset ()
103
96
: nGCPCount(0 ), pasGCPList(nullptr ), nLoadedStokesLine(-1 ),
104
- padfStokesMatrix(nullptr ), nInterleave( 0 )
97
+ padfStokesMatrix(nullptr )
105
98
{
106
99
m_oSRS.SetAxisMappingStrategy (OAMS_TRADITIONAL_GIS_ORDER);
107
100
m_oGCPSRS.SetAxisMappingStrategy (OAMS_TRADITIONAL_GIS_ORDER);
@@ -377,7 +370,7 @@ CPLErr CPGDataset::LoadStokesLine(int iLine, int bNativeOrder)
377
370
/* Load all the pixel data associated with this scanline. */
378
371
/* Retains same interleaving as original dataset. */
379
372
/* -------------------------------------------------------------------- */
380
- if (nInterleave == BIP)
373
+ if (eInterleave == Interleave:: BIP)
381
374
{
382
375
const int offset = nRasterXSize * iLine * nDataSize * 16 ;
383
376
const int nBytesToRead = nDataSize * nRasterXSize * 16 ;
@@ -396,7 +389,7 @@ CPLErr CPGDataset::LoadStokesLine(int iLine, int bNativeOrder)
396
389
return CE_Failure;
397
390
}
398
391
}
399
- else if (nInterleave == BIL)
392
+ else if (eInterleave == Interleave:: BIL)
400
393
{
401
394
for (int band_index = 0 ; band_index < 16 ; band_index++)
402
395
{
@@ -810,7 +803,8 @@ GDALDataset *CPGDataset::InitializeType1Or2Dataset(const char *pszFilename)
810
803
GDALDataset *CPGDataset::InitializeType3Dataset (const char *pszFilename)
811
804
{
812
805
int iBytesPerPixel = 0 ;
813
- int iInterleave = -1 ;
806
+ Interleave::eInterleave = Interleave::BSQ;
807
+ bool bInterleaveSpecified = false ;
814
808
int nLines = 0 ;
815
809
int nSamples = 0 ;
816
810
int nBands = 0 ;
@@ -845,11 +839,20 @@ GDALDataset *CPGDataset::InitializeType3Dataset(const char *pszFilename)
845
839
{
846
840
847
841
if (STARTS_WITH_CI (papszTokens[2 ], " BSQ" ))
848
- iInterleave = BSQ;
842
+ {
843
+ bInterleaveSpecified = true ;
844
+ eInterleave = Interleave::BSQ;
845
+ }
849
846
else if (STARTS_WITH_CI (papszTokens[2 ], " BIL" ))
850
- iInterleave = BIL;
847
+ {
848
+ bInterleaveSpecified = true ;
849
+ eInterleave = Interleave::BIL;
850
+ }
851
851
else if (STARTS_WITH_CI (papszTokens[2 ], " BIP" ))
852
- iInterleave = BIP;
852
+ {
853
+ bInterleaveSpecified = true ;
854
+ eInterleave = Interleave::BIP;
855
+ }
853
856
else
854
857
{
855
858
CPLError (
@@ -979,7 +982,7 @@ GDALDataset *CPGDataset::InitializeType3Dataset(const char *pszFilename)
979
982
}
980
983
981
984
if (!GDALCheckDatasetDimensions (nSamples, nLines) ||
982
- !GDALCheckBandCount (nBands, FALSE ) || iInterleave == - 1 ||
985
+ !GDALCheckBandCount (nBands, FALSE ) || !bInterleaveSpecified ||
983
986
iBytesPerPixel == 0 )
984
987
{
985
988
CPLError (CE_Failure, CPLE_AppDefined,
@@ -998,13 +1001,7 @@ GDALDataset *CPGDataset::InitializeType3Dataset(const char *pszFilename)
998
1001
999
1002
poDS->nRasterXSize = nSamples;
1000
1003
poDS->nRasterYSize = nLines;
1001
-
1002
- if (iInterleave == BSQ)
1003
- poDS->nInterleave = BSQ;
1004
- else if (iInterleave == BIL)
1005
- poDS->nInterleave = BIL;
1006
- else
1007
- poDS->nInterleave = BIP;
1004
+ poDS->eInterleave = eInterleave;
1008
1005
1009
1006
/* -------------------------------------------------------------------- */
1010
1007
/* Open the 16 bands. */
@@ -1395,7 +1392,7 @@ CPLErr CPG_STOKESRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff,
1395
1392
float *M = poGDS->padfStokesMatrix ;
1396
1393
float *pafLine = reinterpret_cast <float *>(pImage);
1397
1394
1398
- if (poGDS->nInterleave == BIP)
1395
+ if (poGDS->eInterleave == RawDataset::Interleave:: BIP)
1399
1396
{
1400
1397
step = 16 ;
1401
1398
m11 = M11;
0 commit comments