bool LandsatEtmPlusImporter::readHeader(const string& strInFstHeaderFileName) { if (strInFstHeaderFileName.empty()) { return false; } //The HTM header file contains information for Band 6 Channel 1 and 2. //This set extracts the info needed to process HTM(band 6) header mFieldHTM.clear(); string baseFileName = strInFstHeaderFileName.substr(0, strInFstHeaderFileName.length() - 7); FactoryResource<Filename> filename; filename->setFullPathAndName(baseFileName); FactoryResource<FileFinder> fileFinder; string htmFileName = filename->getFileName() + "HTM.FST"; if (fileFinder->findFile(filename->getPath(), htmFileName)) { fileFinder->findNextFile(); fileFinder->getFullPath(htmFileName); } LargeFileResource htmFile; if (htmFile.open(htmFileName, O_RDONLY, S_IREAD)) { //process HTM header vector<char> buf(5120); size_t count = static_cast<size_t>(htmFile.read(&buf.front(), 5120)); VERIFY(htmFile.eof()); string htmHeaderFull(&buf.front(), count); vector<string> htmHeaderLines = StringUtilities::split(htmHeaderFull, '\n'); if (!parseHeader(htmHeaderLines, mFieldHTM)) //parse band 6 header { mFieldHTM.clear(); } } htmFile.close(); // The HRF Header file contains the parameters for Bands 1-5 and 7. mFieldHRF.clear(); string hrfFileName = filename->getFileName() + "HRF.FST"; if (fileFinder->findFile(filename->getPath(), hrfFileName)) { fileFinder->findNextFile(); fileFinder->getFullPath(hrfFileName); } LargeFileResource hrfFile; if (hrfFile.open(hrfFileName, O_RDONLY, S_IREAD)) { //process HRF header vector<char> buf(5120); size_t count = static_cast<size_t>(hrfFile.read(&buf.front(), 5120)); VERIFY(hrfFile.eof()); string hrfHeaderFull(&buf.front(), count); vector<string> hrfHeaderLines = StringUtilities::split(hrfHeaderFull, '\n'); if (!parseHeader(hrfHeaderLines, mFieldHRF)) //parse bands 1-5 and 7 header { mFieldHRF.clear(); } } hrfFile.close(); // The HPN Header file contains the parameters for Band 8. mFieldHPN.clear(); string hpnFileName = filename->getFileName() + "HPN.FST"; if (fileFinder->findFile(filename->getPath(), hpnFileName)) { fileFinder->findNextFile(); fileFinder->getFullPath(hpnFileName); } LargeFileResource hpnFile; if (hpnFile.open(hpnFileName, O_RDONLY, S_IREAD)) { //process HPN header vector<char> buf(5120); size_t count = static_cast<size_t>(hpnFile.read(&buf.front(), 5120)); VERIFY(hpnFile.eof()); string hpnHeaderFull(&buf.front(), count); vector<string> hpnHeaderLines = StringUtilities::split(hpnHeaderFull, '\n'); if (!parseHeader(hpnHeaderLines, mFieldHPN)) //parse band 8 header { mFieldHPN.clear(); } } hpnFile.close(); return (!mFieldHRF.empty() || !mFieldHTM.empty() || !mFieldHPN.empty()); }