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& )