bool ossimTiledElevationDatabase::processFile(const ossimFilename& file, bool& recurseFlag) { static const char M[] = "ossimTiledElevationDatabase::processFile"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n" << "file: " << file << "\n"; } bool continueFlag = true; ossimRefPtr<ossimSingleImageChain> sic = new ossimSingleImageChain(); if ( sic->open(file, false) ) // False for do not open overviews. { // Set the directory walker flag. recurseFlag = !(isDirectoryBasedImage(sic->getImageHandler())); ossimRefPtr<ossimImageHandler> ih = sic->getImageHandler(); if ( ih.valid() && (m_requestedRect.isLonLatNan() == false) ) { ossimRefPtr<ossimImageGeometry> geom = ih->getImageGeometry(); if ( geom.valid() == false ) { std::string errMsg = M; errMsg += " ERROR:\nNo image geometry for image: "; errMsg += ih->getFilename().string(); throw ossimException(errMsg); } ossimRefPtr<ossimProjection> proj = geom->getProjection(); if ( proj.valid() == false ) { std::string errMsg = M; errMsg += " ERROR:\nNo image projection for image: "; errMsg += ih->getFilename().string(); throw ossimException(errMsg); } // Get the bounding rect: ossimGrect boundingRect; getBoundingRect(geom, boundingRect); if ( boundingRect.isLonLatNan() ) { std::string errMsg = M; errMsg += " ERROR:\nBounding rect has nans for image: "; errMsg += ih->getFilename().string(); throw ossimException(errMsg); } if ( boundingRect.intersects(m_requestedRect) ) { bool addEntryToList = false; if ( m_entries.size() == 0 ) // First time through. { addEntryToList = true; m_entryListRect = boundingRect; m_referenceProj = proj; m_meanSpacing = (geom->getMetersPerPixel().x + geom->getMetersPerPixel().y) / 2.0; } else { addEntryToList = isCompatible( ih.get(), geom.get(), proj.get() ); if ( addEntryToList ) { // Expand the rectangle. m_entryListRect.combine(boundingRect); } } if ( addEntryToList ) { // If we're keeping it add a cache to the chain. sic->addCache(); //--- // Create the entry and give to addEntry which checks for duplicates in case // mapRegion was called consecutively. //--- ossimTiledElevationEntry entry(boundingRect, sic); addEntry(entry); continueFlag = m_requestedRect.completely_within(m_entryListRect); } } } else { std::string errMsg = M; errMsg += " ERROR:\nNo image geometry for image: "; errMsg += ih->getFilename().string(); throw ossimException(errMsg); } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " recurseFlag=" << recurseFlag << " continueFlag=" << continueFlag << "\n"; } return continueFlag; }
//--- // This method is called back by the ossimFileWalker::walk method for each file it finds that it // deems can be processed. //--- void ossimImageUtil::processFile(const ossimFilename& file) { static const char M[] = "ossimImageUtil::processFile"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n" << "file: " << file << "\n"; } bool processFileFlag = true; if ( !getOverrideFilteredImagesFlag() ) { processFileFlag = !isFiltered( file ); } if ( processFileFlag ) { ossimNotify(ossimNotifyLevel_NOTICE) << "Processing file: " << file << std::endl; m_mutex.lock(); ossimRefPtr<ossimImageHandler> ih = ossimImageHandlerRegistry::instance()->open(file, true, true); m_mutex.unlock(); if ( ih.valid() && !ih->hasError() ) { if ( isDirectoryBasedImage( ih.get() ) ) { // Tell the walker not to recurse this directory. m_mutex.lock(); m_fileWalker->setRecurseFlag(false); m_mutex.unlock(); } // Set any reader props: ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>(ih.get()); if ( pi ) setProps(pi); bool consumedHistogramOptions = false; bool consumedCmmOptionsOptions = false; if ( getOutputFileNamesFlag() ) { // Simply output the file name of any images we can open: ossimNotify(ossimNotifyLevel_NOTICE) << ih->getFilename().expand(); } if ( createOverviews() ) { // Skip shape files... if ( ih->getClassName() != "ossimOgrGdalTileSource" ) { createOverview(ih, consumedHistogramOptions, consumedCmmOptionsOptions); } } // Build stand alone histogram. Note the overview sequencer may have computed for us. if ( hasHistogramOption() && !consumedHistogramOptions) { createHistogram( ih ); } } else { ossimNotify(ossimNotifyLevel_WARN) << M << "\nCould not open: " << file << std::endl; } } else // Matches: if ( processFileFlag ) { ossimNotify(ossimNotifyLevel_NOTICE) << "Filtered file, not processing: " << file << std::endl; } if(traceDebug()) { // Since ossimFileWalker is threaded output the file so we know which job exited. ossimNotify(ossimNotifyLevel_DEBUG) << M << "\nfile: " << file << "\nexited...\n"; } }