Esempio n. 1
0
/*!
 * Opens the archive, returning true if successful;
 * otherwise false.
 * \sa isOpen(), close()
 */
bool Archive::open()
{
	return !_archiveIO->exists() // Create the file
			|| (_archiveIO->open(QIODevice::ReadOnly)
				&& openHeader());
}
bool ossimLandsatTileSource::open()
{
   static const char MODULE[] = "ossimLandsatTileSource::open";

   if (traceDebug())
   {
      CLOG << " Entered..." << std::endl
           << " trying to open file " << theImageFile << std::endl;
   }
   
   ossimFilename tempFilename = theImageFile;
   // See if the file passed in is a header file.
   
   openHeader(theImageFile);

   if (!theFfHdr) return false;

   // Start building the keyword list for the general raster base class.
   ossimKeywordlist kwl;

   //***
   // There can be up to seven (six for L7) files that belong to the header.
   // Note that it seems the file names in the header are always upper case.
   // So test the file given to us to see if they should be downcased.  This
   // is assuming that all files in the directory have the same case.
   //***
   vector<ossimFilename> fileList;
   
   for (ossim_uint32 i=0; i<theFfHdr->getBandCount(); ++i)
   {
      bool addFile = false;
      ossimFilename f1 = theFfHdr->getBandFilename(i);
      if (f1.trim() != "")
      {
         // Make the file name.
         ossimFilename f2 = theImageFile.path();
         f2 = f2.dirCat(f1);
         
         if (f2.exists())
         {
            addFile = true;
         }
         else
         {
            // Try it downcased...
            f2 = theImageFile.path();
            f1.downcase();
            f2 = f2.dirCat(f1);
            if (f2.exists())
            {
               addFile = true;
            }
            else
            {
               // Try is upcased...
               f2 = theImageFile.path();
               f1.upcase();
               f2 = f2.dirCat(f1);
               if (f2.exists())
               {
                  addFile = true;
               }
            }
         }
         
         if (addFile)
         {
            if (traceDebug())
            {
               CLOG << "\nAdding file:  " << f2 << std::endl;
            }
            fileList.push_back(f2);
         }
         else 
         {
            if (traceDebug())
            {
               f2 = theImageFile.path();
               f1 = theFfHdr->getBandFilename(i);
               f1.trim();
               f2 = f2.dirCat(f1);
               CLOG << "\nCould not find:  " << f2 << std::endl;
            }
         }
      }
   }
   
   if(fileList.size() == 0)
   {
      close();
      return false;
   }
   
   ossimGeneralRasterInfo generalRasterInfo(fileList,
					    OSSIM_UINT8,
					    OSSIM_BSQ_MULTI_FILE,
					    (ossim_uint32)fileList.size(),
					    theFfHdr->getLinesPerBand(),
					    theFfHdr->getPixelsPerLine(),
					    0,
					    ossimGeneralRasterInfo::NONE,
					    0);
   if(fileList.size() == 1)
   {
      generalRasterInfo = ossimGeneralRasterInfo(fileList,
                                                 OSSIM_UINT8,
                                                 OSSIM_BSQ,
                                                 (ossim_uint32)fileList.size(),
                                                 theFfHdr->getLinesPerBand(),
                                                 theFfHdr->getPixelsPerLine(),
                                                 0,
                                                 ossimGeneralRasterInfo::NONE,
                                                 0);
   }
   theMetaData.clear();
   theMetaData.setScalarType(OSSIM_UINT8);
   theMetaData.setNumberOfBands((ossim_uint32)fileList.size());   
   m_rasterInfo = generalRasterInfo;
   if(initializeHandler())
   {
      theImageFile = tempFilename;
      
      completeOpen();
   }
   else
   {
      if (traceDebug()) CLOG << " Exited..." << std::endl;
      return false;
   }
   
   if (traceDebug()) CLOG << " Exited..." << std::endl;
   
   return true;
}