bool ossimWavelength::initialize( const ossimEnviHeader& hdr ) { //--- // Example envi wavelength format: // wavelength = { 374.323608, 382.530487, 390.737427 } //--- ossimString value; // Check the units... ossimString key = "wavelength units"; if ( hdr.getValue( key, value ) ) { if ( value.downcase() == "nanometers" ) { // Check for wavelength key: key = "wavelength"; if ( hdr.getValue( key, value ) ) { if ( value.size() ) { // Split into array. value.trim( ossimString("{}") ); std::vector<ossimString> list; value.split( list, ossimString(","), true ); if ( list.size() ) { // Initialize the map: std::vector<ossimString>::const_iterator i = list.begin(); ossim_uint32 band = 0; ossim_float32 wavelength = 0.0; while ( i != list.end() ) { wavelength = (*i).toFloat64(); m_map.insert( std::make_pair( wavelength, band ) ); ++band; ++i; } } } } } } return ( m_map.size() ? true : false); } // End: bool ossimWavelength::initialize(const ossimEnviHeader&)
bool ossimGeneralRasterInfo::initializeFromEnviHdr( const ossimEnviHeader& enviHdr ) { bool result = false; while( 1 ) { //--- // Go through the data members in order. // If a required item is not found break from loop. //-- theMetaData.clear(); // scalar ( required ) : if( enviHdr.getOssimScalarType() != OSSIM_SCALAR_UNKNOWN ) { theMetaData.setScalarType( enviHdr.getOssimScalarType() ); } else { break; } theImageFileList.clear(); // interleave ( required ): theInterleaveType = enviHdr.getOssimInterleaveType(); if ( theInterleaveType == OSSIM_INTERLEAVE_UNKNOWN ) { break; } // bands ( required ): if ( !enviHdr.getBands() ) { break; } theMetaData.setNumberOfBands( enviHdr.getBands() ); // lines ( required ): ossim_uint32 lines = enviHdr.getLines(); if ( !lines ) { break; } // samples ( required ): ossim_uint32 samples = enviHdr.getSamples(); if ( !samples ) { break; } // Set the rectangles: theRawImageRect = ossimIrect( 0, 0, samples - 1, lines - 1 ); theValidImageRect = theRawImageRect; theImageRect = theRawImageRect; // sample start ( not required ): theSubImageOffset.x = enviHdr.getXStart(); // line start ( not required ): theSubImageOffset.y = enviHdr.getYStart(); // header offset ( not required ): theHeaderSize = enviHdr.getHeaderOffset(); // null mode: theSetNullsMode = ossimGeneralRasterInfo::NONE; // pixels to chop: thePixelsToChop = 0; // Byte order, this will be system if not found. theImageDataByteOrder = enviHdr.getByteOrder(); result = true; break; // Trailing break to get out. } return result; } // End: ossimGeneralRasterInfo::initializeFromEnviHdr( const ossimEnviHeader& )
bool ossimAlphaSensorSupportData::readSupportFiles(const ossimEnviHeader& hdr) { bool readOK = readHdrFile(hdr); ossimFilename txtFile = hdr.getFile(); if ( readOK ) { // Derive associated insgps.txt file name if (m_isHSI) { // HSI: // Associated file is located in /NavData, sub-directory of current container // example: // .hdr = "/data/AH/2012-06-15_20-00-29/HSI/Scan_00002/2012-06-15_20-00-29.HSI.Scan_00002.scene.corrected.hsi.hdr" // .txt = "/data/AH/2012-06-15_20-00-29/HSI/Scan_00002/NavData/2012-06-15_20-00-29.HSI.Scan_00002.scene.insgps.txt" // txtFile.insert(hdr.getFile().find_last_of('/'), "/NavData"); // txtFile.gsub("corrected.hsi.hdr", "insgps.txt"); ossimFilename navDir = hdr.getFile().path(); navDir = navDir.dirCat("NavData"); if ( navDir.exists() ) { txtFile = navDir.dirCat( hdr.getFile().file() ); txtFile.gsub("corrected.hsi.hdr", "insgps.txt"); } else { //-- // Example header and inertial nav support(INS) data file paths: // // Header: /data/20131113/hsi/cal/001_001_hsi_cal_001.hsi.hdr // INS: /data/20131113/hsi/nav/001_001_hsi_cal_001.txt //--- // Expand header file out to absolute path: txtFile = hdr.getFile().expand(); // Substitute the "cal" directory with "nav". txtFile.gsub("cal/", "nav/"); // Substitute the "hsi.hdr" directory with "txt". txtFile.gsub("hsi.hdr", "txt"); } } else { // HRI: // Associated file is located in ../NavData, parallel to current container // There is one insgps.txt file common to multiple hdr files // example: // .hdr = "/data/AH/2012-06-15_20-00-29/HRI/HRI_2/2012-06-15_20-00-29.HRI_2.Strip_00004.corrected.hri.hdr" // .txt = "/data/AH/2012-06-15_20-00-29/HRI/NavData/2012-06-15_20-00-29.HRI.Strip_00004.insgps.txt" // Replaced: 29 July 2013 (drb) // txtFile = hdr.getFile().path(); // if ( txtFile.empty() ) // { // txtFile = txtFile.dirCat("../NavData"); // } // else // { // txtFile.replace(txtFile.find("HRI_"), 5, "NavData"); // } // txtFile = txtFile.dirCat( hdr.getFile().file() ); // txtFile.replace(txtFile.find("HRI_"), 5, "HRI"); // txtFile.gsub("corrected.hri.hdr", "insgps.txt"); // // with: ossimFilename navDir = hdr.getFile().path(); if ( navDir.empty() ) { navDir = navDir.dirCat("../NavData"); } else { std::string::size_type pos = navDir.find("HRI_"); if(pos!=std::string::npos) { navDir = navDir.replace(pos, 5, "NavData"); } } if ( navDir.exists() ) { txtFile = navDir.dirCat( hdr.getFile().file() ); std::string::size_type pos = txtFile.find("HRI_"); if(pos!=std::string::npos) { txtFile.replace(pos, 5, "HRI"); } txtFile.gsub("corrected.hri.hdr", "insgps.txt"); } else { navDir = "../nav"; txtFile = navDir.dirCat( hdr.getFile().file() ); txtFile.gsub("hri.hdr", "txt"); } } // Read .txt file readOK = readInsGpsFile(txtFile); } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimAlphaSensorSupportData::readSupportFiles DEBUG:" << "\n hdrFile = " << hdr.getFile() << "\n txtFile = " << txtFile << std::endl; } return readOK; }
bool ossimAlphaSensorSupportData::readHdrFile(const ossimEnviHeader& hdr) { bool result = false; while( 1 ) { // Required stuff will break from loop if not found/valid. m_sensorType = hdr.getSensorType(); if ( m_sensorType.empty() ) break; if ( m_sensorType == "Unknown" ) { // Make an assumption from file name... if ( hdr.getFile().file().contains( ossimString("HSI") ) ) { m_sensorType = "ACES_YOGI-HSI"; } else if ( hdr.getFile().file().contains( ossimString("HRI") ) ) { m_sensorType = "ACES_YOGI-HRI2"; } } if ( m_sensorType == "Unknown" ) { break; // Get out... } // Set the hsi flag: if ( m_sensorType.contains("HSI") || (hdr.getBands() > 63 ) ) // arbitrary... { m_isHSI = true; } else { m_isHSI = false; } m_imageSize.x = hdr.getSamples(); m_imageSize.y = hdr.getLines(); if ( !m_imageSize.x || !m_imageSize.y ) break; ossimString value; hdr.getValue("roll bias", value); if ( value.size() ) { m_rollBias = ossimString::toDouble(value); } else { break; } hdr.getValue("pitch bias", value); if ( value.size() ) { m_pitchBias = ossimString::toDouble(value); } else { break; } hdr.getValue("heading bias", value); if ( value.size() ) { m_headingBias = ossimString::toDouble(value); } else { break; } hdr.getValue("fpa fov deg", value); if ( value.size() ) { m_fov = ossimString::toDouble(value); } else { break; } hdr.getValue("slit rotation deg", value); if ( value.size() ) { m_slitRot = ossimString::toDouble(value); } else { // Removed requirement. Missing in some support data and always 0 when present. if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_NOTICE) << "Missing: \"slit rotation deg\"\n"; } } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimAlphaSensorSupportData::readHdrFile DEBUG:" << "\n getSensorType = " << m_sensorType << "\n getSamples = " << m_imageSize.x << "\n getLines = " << m_imageSize.y << "\n roll bias = " << m_rollBias << "\n pitch bias = " << m_pitchBias << "\n heading bias = " << m_headingBias << "\n fpa fov deg = " << m_fov << "\n slit rotation deg = " << m_slitRot << "\n"; } // Last two lines of while forever. If we get here, set status true and break out. result = true; break; } return result; } // End: bool ossimAlphaSensorSupportData::readHdrFile(const ossimEnviHeader& )