bool ossimGeneralRasterTileSource::open( const ossimGeneralRasterInfo& info ) { if( isOpen() ) { close(); } m_rasterInfo = info; bool 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 ); } } return result; }
bool ossimplugins::ossimRadarSat2TiffReader::open(const ossimFilename& file) { static const char MODULE[] = "ossimplugins::ossimRadarSat2TiffReader::open"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n" << "file: " << file << "\n"; } bool result = false; if ( isOpen() ) { close(); } // Check extension to see if it's xml. if ( file.ext().downcase() == "xml" ) { ossimXmlDocument* xdoc = new ossimXmlDocument(); if ( xdoc->openFile(file) ) { // See if it's a TerraSAR-X product xml file. if ( isRadarSat2ProductFile(xdoc) ) { ossimString s; ossimRadarSat2ProductDoc helper; if ( helper.getImageFile(xdoc, s) ) { ossimFilename imageFile = file.expand().path(); imageFile = imageFile.dirCat(s); setFilename(imageFile); result = ossimTiffTileSource::open(); if (result) { theProductXmlFile = file; completeOpen(); } } } } delete xdoc; xdoc = 0; } // matches: if ( file.ext().downcase() == "xml" ) if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }
bool ossimPngReader::open( std::istream* str, std::streamoff restartPosition, bool youOwnIt ) { bool result = false; if (isOpen()) { close(); } if ( str ) { str->seekg( m_restartPosition, std::ios_base::beg ); if ( checkSignature( str ) ) { // Store the pointer: m_str = str; m_restartPosition = restartPosition; m_ownsStream = youOwnIt; result = readPngInit(); if ( result ) { result = initReader(); if ( result ) { completeOpen(); } } else { destroy(); } } else { if ( youOwnIt ) { delete str; str = 0; } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimPngReader::open NOTICE:\n" << "Could not open: " << theImageFile.c_str() << endl; } } } return result; }
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 ossimH5Reader::setCurrentEntry( ossim_uint32 entryIdx ) { bool result = true; if (m_currentEntry != entryIdx) { if ( isOpen() ) { // Entries always start at zero and increment sequentially.. if ( entryIdx < m_entries.size() ) { // Clear the geometry. theGeometry = 0; // Must clear or openOverview will use last entries. theOverviewFile.clear(); m_currentEntry = entryIdx; //--- // Since we were previously open and the the entry has changed we // need to reinitialize some things. Setting tile to 0 will force an // allocate call on first getTile. //--- // ossimRefPtr so assign to 0(unreferencing) will handle memory. m_tile = 0; completeOpen(); } else { result = false; // Entry index out of range. } } else { //--- // Not open. // Allow this knowing that open will check for out of range. //--- m_currentEntry = entryIdx; } } return result; }
bool ossimKakaduJ2kReader::open() { static const char MODULE[] = "ossimKakaduJ2kReader::open"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = false; if(isOpen()) { closeEntry(); } // Open up a stream to the file. theFileStr.open(theImageFile.c_str(), ios::in | ios::binary); if ( theFileStr.good() ) { //--- // Check for the Start Of Codestream (SOC) and Size (SIZ) markers which // are required as first and second fields in the main header. //--- ossim_uint16 soc; ossim_uint16 siz; theFileStr.read((char*)&soc, 2); theFileStr.read((char*)&siz, 2); if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN) // Alway big endian. { ossimEndian().swap(soc); ossimEndian().swap(siz); } if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) ) { // Read in and store the size record. theSizRecord.parseStream(theFileStr); // Position to start of code stream prior to create call. theFileStr.seekg(0); //--- // Initialize the codestream. The class ossimKakaduNitfReader is a // kdu_compressed source so we feed ourself to the codestream. // // TODO: Currently no kdu_thread_env. This should be implemented for // speed... //--- //--- // Construct multi-threaded processing environment if required. // Temp hard coded to a single thread. //--- if (theThreadEnv) { theThreadEnv->terminate(NULL, true); theThreadEnv->destroy(); } else { theThreadEnv = new kdu_thread_env(); } theThreadEnv->create(); // Creates the single "owner" thread // Check for threads in prefs file. ossim_uint32 threads = 1; const char* lookup = ossimPreferences::instance()->findPreference("kakadu_threads"); if ( lookup ) { threads = ossimString::toUInt32(lookup); if ( threads > 1 ) { for (ossim_uint32 nt=1; nt < threads; ++nt) { if ( !theThreadEnv->add_thread() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unable to create thread!\n"; } } } } } theOpenTileThreadQueue = theThreadEnv->add_queue(NULL,NULL,"open_tile_q"); theCodestream.create(this, theThreadEnv); if ( theCodestream.exists() ) { //--- // We have to store things here in this non-const method because // NONE of the kakadu methods are const. //--- theMinDwtLevels = theCodestream.get_min_dwt_levels(); theCodestream.set_persistent(); // ???? theCodestream.enable_restart(); // ???? kdu_dims region_of_interest; region_of_interest.pos.x = 0; region_of_interest.pos.y = 0; region_of_interest.size.x = getNumberOfSamples(0); region_of_interest.size.y = getNumberOfLines(0); theCodestream.apply_input_restrictions( 0, // first_component 0, // max_components (0 = all remaining will appear) 0, // highest resolution level 0, // max_layers (0 = all layers retained) ®ion_of_interest, // expanded out to block boundary. //KDU_WANT_CODESTREAM_COMPONENTS); KDU_WANT_OUTPUT_COMPONENTS); // Set the scalar: theScalarType = theSizRecord.getScalarType(); if (theScalarType != OSSIM_SCALAR_UNKNOWN) { //--- // NOTE: Please leave commented out code for now. //--- // Capture the sub image offset. // theSubImageOffset.x = theSizRecord.theXOsiz; // theSubImageOffset.y = theSizRecord.theYOsiz; // Initialize the image rect. theImageRect = ossimIrect(0, 0, theSizRecord.theXsiz-1, theSizRecord.theYsiz-1); // Initialize the cache. if (theCacheId != -1) { ossimAppFixedTileCache::instance()->deleteCache(theCacheId); theCacheId = -1; } ossimIpt tileSize(theSizRecord.theXTsiz, theSizRecord.theYTsiz); // Stretch to tile boundary for the cache. ossimIrect fullImgRect = theImageRect; fullImgRect.stretchToTileBoundary(tileSize); // Set up the tile cache. theCacheId = ossimAppFixedTileCache::instance()-> newTileCache(fullImgRect, tileSize); // Add the sub image rect after the // Initialize the tile we will return. initializeTile(); // Call the base complete open to pick up overviews. completeOpen(); // We should be good now so set the return result to true. result = true; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "\nSIZ marker segment" << theSizRecord << "theCodestream.get_num_components(false): " << theCodestream.get_num_components(false) << "\ntheCodestream.get_num_components(true): " << theCodestream.get_num_components(true) << "\ntheCodestream.get_bit_depth(0, true): " << theCodestream.get_bit_depth(0, true) << "\ntheCodestream.get_signed(0, true): " << theCodestream.get_signed(0, true) << "\ntheCodestream.get_min_dwt_levels(): " << theCodestream.get_min_dwt_levels() << "\ntheImageRect: " << theImageRect << "\nFull image rect: " << fullImgRect << "\nthreads: " << threads << "\n"; vector<ossimDpt> decimations; getDecimationFactors(decimations); for (ossim_uint32 i = 0; i < decimations.size(); ++i) { ossimNotify(ossimNotifyLevel_DEBUG) << theCodestream.get_min_dwt_levels() << "Decimation factor[" << i << "]: " << decimations[i] << "\nsamples[" << i << "]: " << getNumberOfSamples(i) << "\nlines[" << i << "]: " << getNumberOfLines(i) << std::endl; } } } } // matches: if ( theCodestream.exists() ) } // matches: if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) ) } // matches: if ( theFileStr.good() ) else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " ERROR:" << "\nCannot open: " << theImageFile.c_str() << endl; } } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }
//******************************************************************* // Public method: //******************************************************************* bool ossimAdrgTileSource::open() { static const char MODULE[] = "ossimAdrgTileSource::open"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << "Entered..."<<std::endl; } if(isOpen()) { close(); } if(m_AdrgHeader) { delete m_AdrgHeader; m_AdrgHeader = 0; } // Instantiate support data class to parse header file. m_AdrgHeader = new ossimAdrgHeader(theImageFile); // Check for errors. if (m_AdrgHeader->errorStatus() == ossimErrorCodes::OSSIM_ERROR) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Error in ossimAdrg header detected." << std::endl; } close(); return false; } m_FileStr.open(m_AdrgHeader->imageFile().c_str(), ios::in | ios::binary); // Check the file pointer. if(!m_FileStr) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCannot open: " << m_AdrgHeader->imageFile().c_str() << std::endl; } close(); return false; } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << "File is opened -> "<< m_AdrgHeader->imageFile()<<std::endl; } // allow the base handler to check for other overrides completeOpen(); // Allocate memory. m_Tile = ossimImageDataFactory::instance()->create(this, this); m_Tile->initialize(); m_TileBuffer = new ossim_uint8[ADRG_TILE_SIZE]; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "\nminLon: " << m_AdrgHeader->minLon() << "\nminLond: " << m_AdrgHeader->minLongitude() << "\nminLat: " << m_AdrgHeader->minLat() << "\nminLatd: " << m_AdrgHeader->minLatitude() << "\nmaxLon: " << m_AdrgHeader->maxLon() << "\nmaxLond: " << m_AdrgHeader->maxLongitude() << "\nmaxLat: " << m_AdrgHeader->maxLat() << "\nmaxLatd: " << m_AdrgHeader->maxLatitude() << std::endl; } return true; }
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 toprsGadlReader::open() { if(isOpen()) { close(); } std::string driverNameTmp; if (theSubDatasets.size() == 0) { // Note: Cannot feed GDALOpen a NULL string! if (theImageFile.size()) { theDataset = GDALOpen(theImageFile.c_str(), GA_ReadOnly); if( theDataset == 0 ) { return false; } } else { return false; } // Check if it is nitf data for deciding whether or not open each sub-dataset //This will be removed eventually when toprs can handle 2GB nitf file. GDALDriverH driverTmp = GDALGetDatasetDriver(theDataset); bool isNtif = false; if (driverTmp != 0) { driverNameTmp = std::string(GDALGetDriverShortName(driverTmp)); std::transform(driverNameTmp.begin(), driverNameTmp.end(), driverNameTmp.begin(), [&](char ch){return toupper(ch);}); if (driverNameTmp == "NITF") { isNtif = true; } } // Check for sub data sets... char** papszMetadata = GDALGetMetadata( theDataset, "SUBDATASETS" ); if( CSLCount(papszMetadata) > 0 ) { theSubDatasets.clear(); for( int i = 0; papszMetadata[i] != 0; ++i ) { std::string os = papszMetadata[i]; if (os.find("_NAME=") != std::string::npos) { //Sub sets have already been set. Open each sub-dataset really slow down the process //specially for hdf data which sometimes has over 100 sub-datasets. Since following code //only for ntif cloud checking, so only open each sub-dataset here if the dataset is //nitf. This will be removed eventually when toprs can handle 2GB nitf file. //Otherwise open a sub-dataset when setCurrentEntry() gets called. if (isNtif) { GDALDatasetH subDataset = GDALOpen(filterSubDatasetsString(os).c_str(), GA_ReadOnly); if ( subDataset != 0 ) { // "Worldview ingest should ignore subimages when NITF_ICAT=CLOUD" // Hack: Ignore NITF subimages marked as cloud layers. std::string nitfIcatTag( GDALGetMetadataItem( subDataset, "NITF_ICAT", "" ) ); if ( nitfIcatTag.find("CLOUD") == std::string::npos ) { theSubDatasets.push_back(filterSubDatasetsString(os)); } } GDALClose(subDataset); } else { theSubDatasets.push_back(filterSubDatasetsString(os)); } } } //--- // Have multiple entries. We're going to default to open the first // entry like cidcadrg. //--- close(); theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(), GA_ReadOnly); if (theDataset == 0) { return false; } } // End of has subsets block. } // End of "if (theSubdatasets.size() == 0)" else { // Sub sets have already been set. theDataset = GDALOpen(theSubDatasets[theEntryNumberToRender].c_str(), GA_ReadOnly); if (theDataset == 0) { return false; } } // Set the driver. theDriver = GDALGetDatasetDriver( theDataset ); if(!theDriver) return false; theGdtType = GDT_Byte; theOutputGdtType = GDT_Byte; if(getNumberOfInputBands() < 1 ) { if(CSLCount(GDALGetMetadata(theDataset, "SUBDATASETS"))) { std::cout << "torsGdalReader::open WARNING:" << "\nHas multiple sub datasets and need to set the data before" << " we can get to the bands" << std::endl; } close(); std::cout << "torsGdalReader::open WARNING:" << "\nNo band data present in torsGdalReader::open" << std::endl; return false; } toprs_int32 i = 0; GDALRasterBandH bBand = GDALGetRasterBand( theDataset, 1 ); theGdtType = GDALGetRasterDataType(bBand); char** papszMetadata = GDALGetMetadata( bBand, NULL ); if (CSLCount(papszMetadata) > 0) { for(int i = 0; papszMetadata[i] != NULL; i++ ) { std::string metaStr = papszMetadata[i]; if (metaStr.find("AREA_OR_POINT") != std::string::npos) { //std::string pixel_is_point_or_area = metaStr.split("=")[1]; //pixel_is_point_or_area.downcase(); //if (pixel_is_point_or_area.contains("area")) // thePixelType = TOPRS_PIXEL_IS_AREA; break; } } } if(!isIndexed(1)) { for(i = 0; i < GDALGetRasterCount(theDataset); ++i) { if(theGdtType != GDALGetRasterDataType(GDALGetRasterBand( theDataset,i+1 ))) { std::cout << "torsGdalReader::open WARNING" << "\nWe currently do not support different scalar type bands." << std::endl; close(); return false; } } } theOutputGdtType = theGdtType; switch(theGdtType) { case GDT_CInt16: { // theOutputGdtType = GDT_Int16; theIsComplexFlag = true; break; } case GDT_CInt32: { // theOutputGdtType = GDT_Int32; theIsComplexFlag = true; break; } case GDT_CFloat32: { // theOutputGdtType = GDT_Float32; theIsComplexFlag = true; break; } case GDT_CFloat64: { // theOutputGdtType = GDT_Float64; theIsComplexFlag = true; break; } default: { theIsComplexFlag = false; break; } } if((std::string(GDALGetDriverShortName( theDriver )) == "PNG")&& (getNumberOfInputBands() == 4)) { theAlphaChannelFlag = true; } populateLut(); computeMinMax(); completeOpen(); theTile = toprsImgFactory::instance()->create(this); theSingleBandTile = toprsImgFactory::instance()->create(getInputScalarType(), 1); if ( m_preservePaletteIndexesFlag ) { theTile->setIndexedFlag(true); theSingleBandTile->setIndexedFlag(true); } theTile->initialize(); theSingleBandTile->initialize(); theGdalBuffer.resize(0); if(theIsComplexFlag) { theGdalBuffer.resize(theSingleBandTile->getSizePerBandInBytes()*2); } theImageBound = toprsIRect(0 ,0 ,GDALGetRasterXSize(theDataset)-1 ,GDALGetRasterYSize(theDataset)-1); int xSize=0, ySize=0; GDALGetBlockSize(GDALGetRasterBand( theDataset, 1 ), &xSize, &ySize); if (driverNameTmp.find("JPIP")!= std::string::npos || driverNameTmp.find("JP2")!= std::string::npos) { m_isBlocked = ((xSize > 1)&&(ySize > 1)); } else { m_isBlocked = false; } //if(m_isBlocked) //{ // setRlevelCache(); //} return true; }
bool rspfHdfReader::open() { static const char MODULE[] = "rspfHdfReader::open"; if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << MODULE << " entered...\n" << "image: " << theImageFile << "\n"; } bool result = false; if (!isSupportedExtension()) { return false; } if (m_entryFileList.size() == 0) { if(isOpen()) { close(); } m_gdalTileSource = new rspfGdalTileSource; m_gdalTileSource->setFilename(theImageFile); if ( m_gdalTileSource->open() == false ) { m_gdalTileSource = 0; return false; } std::vector<rspfString> entryStringList; if (m_gdalTileSource != 0) { m_gdalTileSource->getEntryStringList(entryStringList); } if (entryStringList.size() > 0) { for (rspf_uint32 i = 0; i < entryStringList.size(); i++) { m_entryFileList.push_back(i); } } else { result = false; } } if (m_currentEntryRender < m_entryFileList.size()) { m_gdalTileSource->setCurrentEntry(m_currentEntryRender); m_numberOfBands = m_gdalTileSource->getNumberOfInputBands(); m_tile = rspfImageDataFactory::instance()->create(this, this); m_tile->initialize(); completeOpen(); result = true; } else { result = false; } if (result == false) { close(); } if (traceDebug()) { rspfNotify(rspfNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }
bool ossimH5Reader::open() { static const char MODULE[] = "ossimH5Reader::open"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered..." << "File: " << theImageFile.c_str() << std::endl; } bool status = false; // Start with a clean slate. if (isOpen()) { close(); } // Check for empty filename. if (theImageFile.size()) { try { //-- // Turn off the auto-printing when failure occurs so that we can // handle the errors appropriately //--- // H5::Exception::dontPrint(); theImageFile = theImageFile.expand(); if ( H5::H5File::isHdf5( theImageFile.c_str() ) ) { m_h5File = new H5::H5File(); H5::FileAccPropList access_plist = H5::FileAccPropList::DEFAULT; m_h5File->openFile( theImageFile.string(), H5F_ACC_RDONLY, access_plist ); std::vector<std::string> names; ossim_hdf5::getDatasetNames( m_h5File, names ); if ( names.size() ) { if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG\nDataset names:\n"; for ( ossim_uint32 i = 0; i < names.size(); ++i ) { ossimNotify(ossimNotifyLevel_DEBUG) << "dataset[" << i << "]: " << names[i] << "\n"; } } // Add the image dataset entries. addImageDatasetEntries( names ); if ( m_entries.size() ) { // Set the return status. status = true; } else { m_h5File->close(); delete m_h5File; m_h5File = 0; } } } } // End: try block catch( const H5::FileIException& error ) { if ( traceDebug() ) { error.printError(); } } // catch failure caused by the DataSet operations catch( const H5::DataSetIException& error ) { if ( traceDebug() ) { error.printError(); } } // catch failure caused by the DataSpace operations catch( const H5::DataSpaceIException& error ) { if ( traceDebug() ) { error.printError(); } } // catch failure caused by the DataSpace operations catch( const H5::DataTypeIException& error ) { if ( traceDebug() ) { error.printError(); } } catch( ... ) { } if ( status ) { completeOpen(); } } return status; }
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; }
bool ossimMrSidReader::open() { static const char MODULE[] = "ossimMrSidReader::open"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n" << "image: " << theImageFile << "\n"; } bool result = false; if(isOpen()) { closeEntry(); } LT_STATUS sts = LT_STS_Uninit; const LTFileSpec fileSpec(theImageFile.c_str()); theReader = MrSIDImageReader::create(); sts = theReader->initialize(fileSpec, true); if (LT_SUCCESS(sts) == false) { return false; } theImageNavigator = new LTINavigator(*theReader); theImageRect = ossimIrect(0, 0, theReader->getWidth()-1, theReader->getHeight()-1); theNumberOfBands = theReader->getNumBands(); theMinDwtLevels = theReader->getNumLevels(); getDataType(); if (getImageDimensions(theMrSidDims)) { if (theScalarType != OSSIM_SCALAR_UNKNOWN) { ossim_uint32 width = theReader->getWidth(); ossim_uint32 height = theReader->getHeight(); // Check for zero width, height. if ( !width || !height ) { ossimIpt tileSize; ossim::defaultTileSize(tileSize); width = tileSize.x; height = tileSize.y; } theTile = ossimImageDataFactory::instance()->create(this, this); theTile->initialize(); // Call the base complete open to pick up overviews. computeMinMax(); completeOpen(); result = true; } } if (result == false) { closeEntry(); } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }