bool CRSImage::ReadMetaData(const char* lpstrMetaFilePath)
{
ifstream ifs; //input file stream
string strLine;
string strSubTxt;
stringstream ss; //string stream
char sBuff[260];
ifs.open(lpstrMetaFilePath, ios_base::in);
if (!ifs.is_open())
return false;
while (!ifs.eof()) //end of file
{
ifs.getline(sBuff, 260);
strLine = sBuff;
ss.clear();
ss.str(strLine); //"samples = 640"
ss >> strSubTxt;
if (strSubTxt == "samples")
{
ss >> strSubTxt >> m_nSamples;
}
else if (strSubTxt == "lines")
{
ss >> strSubTxt >> m_nLines;
}
else if (strSubTxt == "bands")
{
ss >> strSubTxt >> m_nBands;
}
else if (strSubTxt == "interleave")
{
ss >> strSubTxt >> strSubTxt;
if (strSubTxt == "bsq")
{
m_eInterleave = BSQ;
}
else if (strSubTxt == "bip")
{
m_eInterleave = BIP;
}
else if (strSubTxt == "bil")
{
m_eInterleave = BIL;
}
else
{
// blank
}
}
else if (strSubTxt == "data")
{
ss >> strSubTxt;
if (strSubTxt == "type")
{
ss >> strSubTxt >> m_nDataType;
}
}
else
{
}
}
return true;
}