bool ossimGeneralRasterTileSource::open( const ossimGeneralRasterInfo& info ) { if( isOpen() ) { close(); } m_rasterInfo = info; if( initializeHandler() ) { completeOpen(); if ( isBandSelector() && m_outputBandList.size() && ( isIdentityBandList( m_outputBandList ) == false ) ) { // This does range checking and will pass to overview if open. setOutputBandList( m_outputBandList ); } } else { return false; } return true; }
bool ossimGeneralRasterTileSource::open() { static const char MODULE[] = "ossimGeneralRasterTileSource::open"; if (traceDebug()) CLOG << " Entered..." << std::endl; bool result = false; if(isOpen()) { close(); } //--- // Find the header file: // // We need lines, samples, bands, scalar and interleave at a minimum: // // A general raster image requires a keyword list to get essential image // information or meta data as its sometimes called. The meta data file // can have four types of extensions: ".omd", ".hdr", ".kwl" and xml. // Look for them in that order. // Note that the ".omd" extension is for "Ossim Meta Data" and was made // up to avoid conflicting with other software packages ".hdr" files. //--- if ( m_rasterInfo.open( theImageFile ) ) { theMetaData = m_rasterInfo.getImageMetaData(); result = initializeHandler(); if ( result ) { completeOpen(); if ( isBandSelector() && m_outputBandList.size() && ( isIdentityBandList( m_outputBandList ) == false ) ) { // This does range checking and will pass to overview if open. setOutputBandList( m_outputBandList ); } } } if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " Exit status: " << (result?"true":"false") << std::endl; } return result; }
bool rspfEnviTileSource::open() { static const char MODULE[] = "rspfEnviTileSource::open"; if ( traceDebug() ) { rspfNotify(rspfNotifyLevel_DEBUG) << MODULE << " entered..." << "\nimage file: " << theImageFile << std::endl; } bool result = false; if(isOpen()) { close(); } // Look for a header file: rspfFilename hdr = theImageFile; hdr.setExtension("hdr"); // image.hdr if ( !hdr.exists() ) { hdr = theImageFile; hdr.string() += ".hdr"; // image.ras.hdr } if ( hdr.exists() ) { if ( traceDebug() ) { rspfNotify(rspfNotifyLevel_DEBUG) << "header file: " << hdr << std::endl; } if ( m_enviHdr.open( hdr ) ) { if ( m_rasterInfo.initializeFromEnviHdr( m_enviHdr ) ) { // Set image file for initializeHandler method. m_rasterInfo.setImageFile( theImageFile ); // Look for an omd file: rspfFilename omd = theImageFile; omd.setExtension("omd"); // image.omd if ( !omd.exists() ) { omd.setExtension("kwl"); // image.kwl } if ( omd.exists() ) { if ( traceDebug() ) { rspfNotify(rspfNotifyLevel_DEBUG) << "omd file: " << omd << std::endl; } // Pick up adjusted min / max values if present. rspfKeywordlist kwl( omd ); m_rasterInfo.getImageMetaData().updateMetaData( kwl, std::string("") ); } theMetaData = m_rasterInfo.getImageMetaData(); result = initializeHandler(); if ( result ) { completeOpen(); //--- // This will set default output band list if we are a band selector and // "default bands" key is found in the envi header. If "default bands" // is not found it will set to identity(input = output). //--- setDefaultBandList(); } } } } if ( traceDebug() ) { rspfNotify(rspfNotifyLevel_DEBUG) << MODULE << " Exit status: " << (result?"true":"false") << std::endl; } return result; }
bool ossimNdfTileSource::open() { // Ensure header file exists if(!theHeaderFile.exists()) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_WARN) << "ERROR: Missing Header File (" << theHeaderFile << ")" << std::endl; } return false; } try { // Validate Header to ensure we support this data type ossimNdfHeader lnh(theHeaderFile); if(lnh.getErrorStatus()) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; return false; } // Use General Raster classes to build NLAPS imagery ossimGeneralRasterInfo generalRasterInfo; if(lnh.getNumOfBands() == 1) { generalRasterInfo = ossimGeneralRasterInfo(lnh.getImageFileList(), OSSIM_UINT8, OSSIM_BSQ, lnh.getNumOfBands(), lnh.getLines(), lnh.getSamples(), 0, ossimGeneralRasterInfo::NONE, 0); } else { generalRasterInfo = ossimGeneralRasterInfo(lnh.getImageFileList(), OSSIM_UINT8, OSSIM_BSQ_MULTI_FILE, lnh.getNumOfBands(), lnh.getLines(), lnh.getSamples(), 0, ossimGeneralRasterInfo::NONE, 0); } theMetaData.clear(); theMetaData.setScalarType(OSSIM_UINT8); theMetaData.setNumberOfBands(lnh.getNumOfBands()); m_rasterInfo = generalRasterInfo; if(initializeHandler()) { completeOpen(); } else { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; return false; } } catch (const ossimException& e) { if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_WARN) << "ossimNdfTileSource::open caught exception:\n" << e.what() << std::endl; } return false; } return true; }
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; }