double rspfBandMergeSource::getMaxPixelValue(rspf_uint32 band)const
{
   rspf_uint32 currentBandCount = 0;
   rspf_uint32 idx              = 0;

   rspf_uint32 maxBands = getNumberOfOutputBands();
   if(!maxBands) return 0.0;
   
   while((currentBandCount < maxBands)&&
	 (idx < getNumberOfInputs()))
   {
      rspfImageSource* temp = PTR_CAST(rspfImageSource, getInput(idx));
      if(temp)
      {
	rspf_uint32 previousCount = currentBandCount;
	currentBandCount += temp->getNumberOfOutputBands();

         if(band < currentBandCount)
         {
            return temp->getMaxPixelValue(band - previousCount);
         }
      }
      ++idx;
   }
   
   return rspf::nan();
}
Beispiel #2
0
bool ossimHdfReader::getTile(ossimImageData* result,
                             ossim_uint32 resLevel)
{
   bool status = false;

   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref();  // Increment ref count.

      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);

      if (!status) // Did not get an overview tile.
      {
         status = true;

         ossimIrect tile_rect = result->getImageRectangle();     

         if (getImageRectangle().intersects(tile_rect))
         {
            // Make a clip rect.
            ossimIrect clipRect = tile_rect.clipToRect(getImageRectangle());

            if (tile_rect.completely_within(clipRect) == false)
            {
               // Not filling whole tile so blank it out first.
               result->makeBlank();
            }

            if (m_gdalTileSource.valid())
            {
               ossimRefPtr<ossimImageData> imageData =
                  m_gdalTileSource->getTile(tile_rect, resLevel);
               result->loadTile(imageData->getBuf(), tile_rect, clipRect, OSSIM_BSQ);
            }
     
         }
         else // No intersection...
         {
            result->makeBlank();
         }
      }
      result->validate();

      result->unref();  // Decrement ref count.
   }

   return status;
}
Beispiel #3
0
void ossimImageSource::getOutputBandList(std::vector<ossim_uint32>& bandList) const
{
   bandList.clear();
   const ossim_uint32 BANDS = getNumberOfOutputBands();
   for (ossim_uint32 band = 0; band < BANDS; ++band)
   {
      bandList.push_back(band);
   }
}
Beispiel #4
0
bool ossimAdrgTileSource::getTile(ossimImageData* result,
                                  ossim_uint32 resLevel)
{
   bool status = false;

   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref();  // Increment ref count.

      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         ossimIrect tile_rect = result->getImageRectangle();
         
         ossimIrect image_rect = getImageRectangle(resLevel);
         
         result->makeBlank();
         
         //---
         // See if any point of the requested tile is in the image.
         //---
         if ( tile_rect.intersects(image_rect) )
         {
            ossimIrect clip_rect = tile_rect.clipToRect(image_rect);
            
            // Load the tile buffer with data from the adrg.
            status = fillBuffer(tile_rect, clip_rect, result);

            if (status)
            {
               result->validate();
            }
         }
      }

      result->unref();  // Decrement ref count.
   }

   return status;
}
Beispiel #5
0
void ossimTableRemapper::allocate(const ossimIrect& rect)
{
   //---
   // It's either first getTile or we've had either a resize, so allocate
   // needed stuff...
   //---
   destroy();

   if (theInputConnection)
   {
      ossim_uint32 width  = rect.width();
      ossim_uint32 height = rect.height();
    
      theTile =  ossimImageDataFactory::instance()->create(this,this);
      theTile->setImageRectangle(rect); 
     // theTile =
     //    ossimImageDataFactory::instance()->create(this,
     //                                              getOutputScalarType(),
     //                                              getNumberOfOutputBands(),
     //                                              width,x
     //                                              height);
      theTile->initialize();


      if (theInputScalarType !=  getOutputScalarType() &&
          theTableType == ossimTableRemapper::NATIVE)
      {
         //---
         // We need a temp tile so we can do two remaps
         // inputTile->remapTable->tmpTile then
         // tmpTile->normalize->theTile(unnormalize to new scalar)...
         //---
         theTmpTile 
         = ossimImageDataFactory::instance()->create(this,
                                                     theInputScalarType,
                                                     getNumberOfOutputBands(),
                                                     width,
                                                     height);
         theTmpTile->setMinPix(theTile->getMinPix(), theTile->getNumberOfBands());
         theTmpTile->initialize();

      }

      if (theTableType == ossimTableRemapper::NORMALIZED ||
          theInputScalarType != theOutputScalarType)
      {
         theNormBuf = new ossim_float64[theTile->getSize()];
      }
   }
}
Beispiel #6
0
void ossimLasReader::initTile()
{
   const ossim_uint32 BANDS = getNumberOfOutputBands();

   m_tile = new ossimImageData(this,
                               getOutputScalarType(),
                               BANDS,
                               getTileWidth(),
                               getTileHeight());

   for(ossim_uint32 band = 0; band < BANDS; ++band)
   {
      m_tile->setMinPix(getMinPixelValue(band),   band);
      m_tile->setMaxPix(getMaxPixelValue(band),   band);
      m_tile->setNullPix(getNullPixelValue(band), band);
   }

   m_tile->initialize();
}
ossimRefPtr<ossimImageData> ossimMemoryImageSource::getTile(const ossimIrect& rect,
                                                            ossim_uint32 /* resLevel */)
{
   if(!isSourceEnabled()||!m_image.valid()||m_boundingRect.hasNans()) return 0;
   if(!m_result.valid())
   {
      m_result = new ossimImageData(0, getOutputScalarType(), getNumberOfOutputBands(), rect.width(), rect.height());
      m_result->initialize();       
   }

   m_result->setImageRectangle(rect);
   m_result->makeBlank();
   ossimIrect clampRect = m_image->getImageRectangle().clipToRect(rect);
	
   m_result->loadTile(m_image->getBuf(),
	                    m_boundingRect,
	                    OSSIM_BSQ);

	m_result->validate();
   return m_result;
}
Beispiel #8
0
bool rspfHdfReader::getTile(rspfImageData* result,
                             rspf_uint32 resLevel)
{
   bool status = false;
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref();  // Increment ref count.
      status = getOverviewTile(resLevel, result);
      if (!status) // Did not get an overview tile.
      {
         status = true;
         rspfIrect tile_rect = result->getImageRectangle();     
         if (getImageRectangle().intersects(tile_rect))
         {
            rspfIrect clipRect = tile_rect.clipToRect(getImageRectangle());
            if (tile_rect.completely_within(clipRect) == false)
            {
               result->makeBlank();
            }
            if (m_gdalTileSource.valid())
            {
               rspfRefPtr<rspfImageData> imageData =
                  m_gdalTileSource->getTile(tile_rect, resLevel);
               result->loadTile(imageData->getBuf(), tile_rect, clipRect, RSPF_BSQ);
            }
     
         }
         else // No intersection...
         {
            result->makeBlank();
         }
      }
      result->validate();
      result->unref();  // Decrement ref count.
   }
   return status;
}
bool ossimKakaduJ2kReader::getOverviewTile(ossim_uint32 resLevel,
                                           ossimImageData* result)
{
   bool status = false;

   if ( (resLevel < getNumberOfDecimationLevels()) && result &&
        (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      if (resLevel <= theMinDwtLevels)
      {
         // Internal overviews...
         try
         {
            status = ossim::copyRegionToTile(theCodestream,
                                             static_cast<int>(resLevel),
                                             theThreadEnv,
                                             theOpenTileThreadQueue,
                                             result);
         }
         catch(const ossimException& e)
         {
            ossimNotify(ossimNotifyLevel_WARN)
               << __FILE__ << " " << __LINE__ << " caught exception\n"
               << e.what();
            status = false;
         }

      } // matches:  if (resLevel <= theMinDwtLevels)
      else
      {
         // External overviews...
         status = theOverview->getTile(result, resLevel - theMinDwtLevels);
      }
   }

   return status;
}
Beispiel #10
0
//*******************************************************************
// Public method:
//*******************************************************************
ossimRefPtr<ossimImageGeometry> ossimAdrgTileSource::getImageGeometry()
{
   if ( !theGeometry )
   {
      // Check for external geom:
      theGeometry = getExternalImageGeometry();
      
      if ( !theGeometry )
      {
         // origin of latitude
         ossim_float64 originLatitude = (m_AdrgHeader->maxLatitude() +
                                         m_AdrgHeader->minLatitude()) / 2.0;
         
         // central meridian.
         ossim_float64 centralMeridian = (m_AdrgHeader->maxLongitude() +
                                          m_AdrgHeader->minLongitude()) / 2.0;
         
         //---
         // Compute the pixel size in latitude and longitude direction.  This will
         // be full image extents divided by full image lines and samples.
         //---
         
         // Samples in full image (used to compute degPerPixelX).
         ossim_float64 samples = m_AdrgHeader->samples();
         
         // Lines in full image (used to compute degPerPixelX).
         ossim_float64 lines = m_AdrgHeader->lines();
         
         // Degrees in latitude direction of the full image.
         ossim_float64 degrees_in_lat_dir = m_AdrgHeader->maxLatitude() -
            m_AdrgHeader->minLatitude();
         
         // Degrees in longitude direction of the full image.
         ossim_float64 degrees_in_lon_dir = m_AdrgHeader->maxLongitude() -
            m_AdrgHeader->minLongitude();
         
         ossim_float64 degPerPixelY = degrees_in_lat_dir / lines;
         ossim_float64 degPerPixelX = degrees_in_lon_dir / samples;
         
         //---
         // The tie is determined with the following assumptions that need to be
         // verified:
         // 1) Rows and columns start at 1.
         // 2) The min / max latitudes longitudes go to the edge of the pixel.
         // 3) Latitude decreases by degPerPixelY with each line.
         // 4) Longitude increases by degPerPixelX with each sample.
         //---
         ossim_float64 ul_lat = (m_AdrgHeader->maxLatitude() - 
                                 ( (m_AdrgHeader->startRow() - 1) *
                                   degPerPixelY ) - ( degPerPixelY * 0.5 ) );
         ossim_float64 ul_lon = (m_AdrgHeader->minLongitude() +
                                 ( (m_AdrgHeader->startCol() -1) *
                                   degPerPixelX ) +  ( degPerPixelX * 0.5 ) );
         
         // projection type
         ossimKeywordlist kwl;
         const char* prefix = 0;
         kwl.add(prefix,
                 ossimKeywordNames::TYPE_KW,
                 "ossimEquDistCylProjection",
                 true);
         
         // datum.
         kwl.add(prefix,
                 ossimKeywordNames::DATUM_KW,
                 "WGE",
                 true);
         
         // origin latitude
         kwl.add(prefix,
                 ossimKeywordNames::ORIGIN_LATITUDE_KW,
                 originLatitude,
                 true);

         // central meridin
         kwl.add(prefix,
                 ossimKeywordNames::CENTRAL_MERIDIAN_KW,
                 centralMeridian,
                 true);

         // Save the tie point.
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_XY_KW,
                 ossimDpt(ul_lon, ul_lat).toString().c_str(),
                 true);
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_UNITS_KW,
                 ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES),
                 true);

         // Save the scale.
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_LAT_KW,
                 ul_lat,
                 true);
   
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_LON_KW,
                 ul_lon,
                 true);

         // Save the scale.
         kwl.add(prefix,
                 ossimKeywordNames::PIXEL_SCALE_XY_KW,
                 ossimDpt(degPerPixelX, degPerPixelY).toString().c_str(),
                 true);
         kwl.add(prefix,
                 ossimKeywordNames::PIXEL_SCALE_UNITS_KW,
                 ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES),
                 true);  

         // lines
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_LINES_KW,
                 getNumberOfLines());

         // samples
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_SAMPLES_KW,
                 getNumberOfSamples());

         // res sets
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_REDUCED_RES_SETS_KW,
                 getNumberOfDecimationLevels());

         // bands
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_INPUT_BANDS_KW,
                 getNumberOfInputBands());

         // bands
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_OUTPUT_BANDS_KW,
                 getNumberOfOutputBands());
   
         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()
               << "\nstartRow:           " << m_AdrgHeader->startRow()
               << "\nstartCol:           " << m_AdrgHeader->startCol()
               << "\nstopRow:            " << m_AdrgHeader->stopRow()
               << "\nstopCol:            " << m_AdrgHeader->stopCol()
               << "\nfull image lines:   " << lines
               << "\nfull image samples: " << samples
               << "\nkwl:\n"               << kwl
               << std::endl;
         }

         ossimProjection* new_proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
         theGeometry = new ossimImageGeometry;
         theGeometry->setProjection(new_proj);  // assumes management of projection instance
         
      } // matches (after getExternalImageGeometry()):  if ( !theGeometry ) 
      
      // Set image things the geometry object should know about.
      initImageParameters( theGeometry.get() );
      
   } // matches: if ( !theGeometry )

   return theGeometry;
}
Beispiel #11
0
bool ossimH5Reader::getTile(ossimImageData* result, ossim_uint32 resLevel)
{
   bool status = false;

   m_mutex.lock();
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref(); // Increment ref count.
      
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);

      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         ossimIrect tile_rect = result->getImageRectangle();

         if ( ! tile_rect.completely_within(getImageRectangle(0)) )
         {
            // We won't fill totally so make blank first.
            result->makeBlank();
         }
         
         if (getImageRectangle(0).intersects(tile_rect))
         {
            // Make a clip rect.
            ossimIrect clipRect = tile_rect.clipToRect(getImageRectangle(0));
            
            if (tile_rect.completely_within( clipRect) == false)
            {
               // Not filling whole tile so blank it out first.
               result->makeBlank();
            }

            // Create buffer to hold the clip rect for a single band.
            ossim_uint32 clipRectSizeInBytes = clipRect.area() *
               ossim::scalarSizeInBytes( m_entries[m_currentEntry].getScalarType() );
            vector<char> dataBuffer(clipRectSizeInBytes);

            // Get the data.
            for (ossim_uint32 band = 0; band < getNumberOfInputBands(); ++band)
            {
               // Hdf5 file to buffer:
               m_entries[m_currentEntry].getTileBuf(&dataBuffer.front(), clipRect, band);

               if ( m_entries[m_currentEntry].getScalarType() == OSSIM_FLOAT32 )
               {
                  //---
                  // NPP VIIRS data has null of "-999.3".
                  // Scan and fix non-standard null value.
                  //---
                  const ossim_float32 NP = getNullPixelValue(band);
                  const ossim_uint32 COUNT = clipRect.area();
                  ossim_float32* float_buffer = (ossim_float32*)&dataBuffer.front();
                  for ( ossim_uint32 i = 0; i < COUNT; ++i )
                  {
                     if ( float_buffer[i] <= -999.0 ) float_buffer[i] = NP;
                  }
               }

               // Buffer to tile:
               result->loadBand((void*)&dataBuffer.front(), clipRect, band);
            }

            // Validate the tile, i.e. full, partial, empty.
            result->validate();
         }
         else // No intersection...
         {
            result->makeBlank();
         }
      }

      result->unref();  // Decrement ref count.
   }

   m_mutex.unlock();

   return status;
}
Beispiel #12
0
bool ossimPngReader::getTile(ossimImageData* result,
                             ossim_uint32 resLevel)
{
   bool status = false;
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel) &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      result->ref(); // Increment ref count.
      
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);

      if (status)
      {
         if(m_outputScalarType == OSSIM_UINT16)
         {
            //---
            // Temp fix:
            // The overview handler could return a tile of OSSIM_USHORT11 if
            // the max sample value was not set to 2047.
            //
            // To prevent a scalar mismatch set 
            //---
            result->setScalarType(m_outputScalarType);
         }
      }
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         ossimIrect tile_rect = result->getImageRectangle();

         if ( ! tile_rect.completely_within(getImageRectangle(0)) )
         {
            // We won't fill totally so make blank first.
            m_tile->makeBlank();
         }
         
         if (getImageRectangle(0).intersects(tile_rect))
         {
            // Make a clip rect.
            ossimIrect clip_rect = tile_rect.clipToRect(getImageRectangle(0));
            
            // This will validate the tile at the end.
            fillTile(clip_rect, result);
         }
      }

      result->unref();  // Decrement ref count.
   }

   return status;
}
void ossimCFARFilter::computeNullMinMax()
{
   const ossim_uint32 BANDS = getNumberOfOutputBands();

   theNullPixValue.resize(BANDS);
   theMinPixValue.resize(BANDS);
   theMaxPixValue.resize(BANDS);

   ossim_float64 defaultNull = ossim::defaultNull(getOutputScalarType());
   ossim_float64 defaultMin = ossim::defaultMin(getOutputScalarType());
   ossim_float64 defaultMax = ossim::defaultMax(getOutputScalarType());
  
   for (ossim_uint32 band = 0; band < BANDS; ++band)
   {
      if(theInputConnection)
      {
         ossim_float64 inputNull = theInputConnection->getNullPixelValue(band);
         ossim_float64 inputMin  = theInputConnection->getMinPixelValue(band);
         ossim_float64 inputMax  = theInputConnection->getMaxPixelValue(band);
         ossim_float64 tempMin   = 0.0;
         ossim_float64 tempMax   = 0.0;
         ossim_float64 k         = 0.0;
         for(int i=0;i<5;++i)
         {
            for(int j=0;j<5;++j)
            {
               k=theKernel[i][j];
               tempMin += (k<0.0) ? k*inputMax : k*inputMin;
               tempMax += (k>0.0) ? k*inputMax : k*inputMin;
            }
         }

         if((inputNull < getMinPixelValue(band)) ||
            (inputNull > getMaxPixelValue(band)))
         {
            theNullPixValue[band] = inputNull;
         }
         else
         {
            theNullPixValue[band] = defaultNull;
         }

         if((tempMin >= defaultMin) && (tempMin <= defaultMax))
         {
            theMinPixValue[band] = tempMin;
         }
         else
         {
            theMinPixValue[band] = defaultMin;
         }

         if((tempMax >= defaultMin) && (tempMax <= defaultMax))
         {
            theMaxPixValue[band] = tempMax;
         }
         else
         {
            theMaxPixValue[band] = defaultMax;
         }
         
      }
      else // No input connection...
      {
         theNullPixValue[band] = defaultNull;
         theMinPixValue[band]  = defaultMin;
         theMaxPixValue[band]  = defaultMax;
      }
      
   } // End of band loop.
}
bool ossimGeneralRasterTileSource::getTile(ossimImageData* result,
                                           ossim_uint32 resLevel)
{
   bool status = false;
   
   //---
   // Not open, this tile source bypassed, or invalid res level,
   // return a blank tile.
   //---
   if( isOpen() && isSourceEnabled() && isValidRLevel(resLevel)  &&
       result && (result->getNumberOfBands() == getNumberOfOutputBands()) )
   {
      //---
      // Check for overview tile.  Some overviews can contain r0 so always
      // call even if resLevel is 0.  Method returns true on success, false
      // on error.
      //---
      status = getOverviewTile(resLevel, result);
      if (status)
      {
         if(getOutputScalarType() == OSSIM_USHORT11)
         {
            //---
            // Temp fix:
            // The overview handler could return a tile of OSSIM_UINT16 if
            // the max sample value was not set to 2047.
            //---
            result->setScalarType(OSSIM_USHORT11);
         }
      }
      
      if (!status) // Did not get an overview tile.
      {
         status = true;
         
         //---
         // Subtract any sub image offset to get the zero based image space
         // rectangle.
         //---
         ossimIrect tile_rect = result->getImageRectangle();
         
         // This should be the zero base image rectangle for this res level.
         ossimIrect image_rect = getImageRectangle(resLevel);
         
         //---
         // See if any point of the requested tile is in the image.
         //---
         if ( tile_rect.intersects(image_rect) )
         {
            // Make the tile rectangle zero base.
            result->setImageRectangle(tile_rect);

            // Initialize the tile if needed as we're going to stuff it.
            if (result->getDataObjectStatus() == OSSIM_NULL)
            {
               result->initialize();
            }

            ossimIrect clip_rect = tile_rect.clipToRect(image_rect);

            if ( ! tile_rect.completely_within(m_bufferRect) )
            {
               // A new buffer must be loaded.
               if ( !tile_rect.completely_within(clip_rect) )
               {
                  //---
                  // Start with a blank tile since the whole tile buffer will
                  // not be
                  // filled.
                  //---
                  result->makeBlank();
               }

               // Reallocate the buffer if needed.
               if ( m_bufferSizeInPixels != result->getSize() )
               {
                  allocateBuffer( result );
               }

               ossimIpt size(static_cast<ossim_int32>(result->getWidth()),
                             static_cast<ossim_int32>(result->getHeight()));

               if( !fillBuffer(clip_rect.ul(), size) )
               {
                  ossimNotify(ossimNotifyLevel_WARN)
                     << "Error from fill buffer..."
                     << std::endl;
                  //---
                  // Error in filling buffer.
                  //---
                  setErrorStatus();
                  status = false;
               }
            }
            
            result->loadTile(m_buffer,
                             m_bufferRect,
                             clip_rect,
                             m_bufferInterleave);
            result->validate();

            // Set the rectangle back.
            result->setImageRectangle(tile_rect);
            
         }
         else // No intersection.
         {
            result->makeBlank();
         }
      }
   }
   return status;
}
ossimRefPtr<ossimImageData> ossimClosestToCenterCombiner::getTile(const ossimIrect& rect,
                                                                  ossim_uint32 resLevel)
{
   ossim_uint32 layerIdx = 0;
   if(!isSourceEnabled())
   {
      return ossimImageMosaic::getTile(rect, resLevel);
   }
   if(!theTile.valid())
   {
      allocate();
      if(!theTile.valid())
      {
         return 0;
      }
   }
   theTile->setImageRectangle(rect);
   theTile->makeBlank();
   std::vector<ossimClosestToCenterCombinerInfo > normTileList;
   ossimRefPtr<ossimImageData> currentTile = getNextNormTile(layerIdx, 0, rect);
   while(currentTile.valid())
   {
      normTileList.push_back(ossimClosestToCenterCombinerInfo((ossimImageData*)currentTile->dup(),
                                                              layerIdx));
      currentTile = getNextNormTile(layerIdx, rect, resLevel);
   }

   
   if(normTileList.size() == 1)
   {
      theTile->copyNormalizedBufferToTile((ossim_float32*)normTileList[0].theTile->getBuf());
   }
   else if(normTileList.size() > 1)
   {
      ossimRefPtr<ossimImageData> copyTile    = ossimImageDataFactory::instance()->create(0,
                                                                                          OSSIM_NORMALIZED_FLOAT);
      copyTile->setImageRectangleAndBands(rect,
                                          getNumberOfOutputBands());
      copyTile->initialize();
                                                                                          
      ossim_int32 idx   = 0;
      ossim_uint32 w     = rect.width();
      ossim_uint32 h     = rect.height();
      ossim_uint32 idxW  = 0;
      ossim_uint32 idxH  = 0;
      ossimIpt origin    = rect.ul();
      ossimIpt ulPt      = rect.ul();
      ossim_uint32 band  = 0;
      ossim_uint32 bands = copyTile->getNumberOfBands();
      ossim_uint32 srcBandIdx = 0;
      std::vector<ossim_float32*> bandList(bands);

      for(band = 0; band < bands; ++band)
      {
         bandList[band] = (ossim_float32*)copyTile->getBuf(band);
      }
      ossim_uint32 offset   = 0;
      origin.y = ulPt.y;
      for(idxH = 0; idxH < h; ++idxH)
      {
         origin.x = ulPt.x;
         for(idxW = 0; idxW < w;++idxW)
         {
            idx = findIdx(normTileList, origin, offset);

            if(idx >=0)
            {
               ossim_uint32 tileBands = normTileList[idx].theTile->getNumberOfBands();
               if (tileBands > 0)
               {
                  tileBands -= 1;
                  for(band = 0; band < bands; ++band)
                  {
                     srcBandIdx = ossim::min( tileBands, band );
                     bandList[band][offset] = *(((ossim_float32*)normTileList[idx].theTile->getBuf(srcBandIdx))+offset);
                  }
               }
            }
            ++offset;
            ++origin.x;
         }
         ++origin.y;
      }
      theTile->copyNormalizedBufferToTile((ossim_float32*)copyTile->getBuf());
   }

   theTile->validate();
   
   return theTile;

}